<p>Kévin Redon has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13846">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add ISO 7816-3 definitions and utilities<br><br>Change-Id: Ice4eba380126ff92089b71d0ea328b0110f7ffec<br>---<br>M sysmoOCTSIM/gcc/Makefile<br>A sysmoOCTSIM/iso7816_3.c<br>A sysmoOCTSIM/iso7816_3.h<br>3 files changed, 225 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/46/13846/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/sysmoOCTSIM/gcc/Makefile b/sysmoOCTSIM/gcc/Makefile</span><br><span>index 5d21cb0..cf0484c 100644</span><br><span>--- a/sysmoOCTSIM/gcc/Makefile</span><br><span>+++ b/sysmoOCTSIM/gcc/Makefile</span><br><span>@@ -83,6 +83,7 @@</span><br><span> octsim_i2c.o \</span><br><span> ncn8025.o \</span><br><span> command.o \</span><br><span style="color: hsl(120, 100%, 40%);">+iso7816_3.o \</span><br><span> hpl/osc32kctrl/hpl_osc32kctrl.o \</span><br><span> driver_init.o \</span><br><span> hal/src/hal_usart_async.o \</span><br><span>@@ -132,6 +133,7 @@</span><br><span> "octsim_i2c.o" \</span><br><span> "ncn8025.o" \</span><br><span> "command.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"iso7816_3.o" \</span><br><span> "hpl/osc32kctrl/hpl_osc32kctrl.o" \</span><br><span> "driver_init.o" \</span><br><span> "hal/src/hal_usart_async.o" \</span><br><span>@@ -188,7 +190,8 @@</span><br><span> "octsim_i2c.d" \</span><br><span> "ncn8025.d" \</span><br><span> "command.d" \</span><br><span style="color: hsl(0, 100%, 40%);">-"hal/src/hal_cache.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"iso7816_3.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"hal/src/halcache.d" \</span><br><span> "hal/src/hal_sleep.d" \</span><br><span> "hal/utils/src/utils_ringbuffer.d" \</span><br><span> "hpl/sercom/hpl_sercom.d" \</span><br><span>diff --git a/sysmoOCTSIM/iso7816_3.c b/sysmoOCTSIM/iso7816_3.c</span><br><span>new file mode 100644</span><br><span>index 0000000..f7262fb</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/iso7816_3.c</span><br><span>@@ -0,0 +1,123 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * as published by the Free Software Foundation; either version 2</span><br><span style="color: hsl(120, 100%, 40%);">+ * of the License, or (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</span><br><span style="color: hsl(120, 100%, 40%);">+*/</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stddef.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "utils.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "iso7816_3.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const uint16_t iso7816_3_fi_table[16] = {</span><br><span style="color: hsl(120, 100%, 40%);">+       372, 372, 558, 744, 1116, 1488, 1860, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+      0, 512, 768, 1024, 1536, 2048, 0, 0</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const uint32_t iso7816_3_fmax_table[16] = {</span><br><span style="color: hsl(120, 100%, 40%);">+        4000000, 5000000, 6000000, 8000000, 12000000, 16000000, 20000000, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+  0, 5000000, 7500000, 10000000, 15000000, 20000000, 0, 0</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const uint8_t iso7816_3_di_table[16] = {</span><br><span style="color: hsl(120, 100%, 40%);">+       0, 1, 2, 4, 8, 16, 32, 64,</span><br><span style="color: hsl(120, 100%, 40%);">+    12, 20, 0, 0, 0, 0, 0, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* all values are based on the Elementary Time Unit (ETU), defined in ISO/IEC 7816-3 section 7.1</span><br><span style="color: hsl(120, 100%, 40%);">+ * this is the time required to transmit a bit, and is calculated as follows: 1 ETU = (F / D) x (1 / f) where:</span><br><span style="color: hsl(120, 100%, 40%);">+ * - F is the clock rate conversion integer</span><br><span style="color: hsl(120, 100%, 40%);">+ * - D is the baud rate adjustment factor</span><br><span style="color: hsl(120, 100%, 40%);">+ * - f is the clock frequency</span><br><span style="color: hsl(120, 100%, 40%);">+ * the possible F, f(max), and D values are defined in ISO/IEC 7816-3 table 7 and 8</span><br><span style="color: hsl(120, 100%, 40%);">+ * - the initial value for F (after reset) is Fd = 372</span><br><span style="color: hsl(120, 100%, 40%);">+ * - the initial value for D (after reset) is Dd = 1</span><br><span style="color: hsl(120, 100%, 40%);">+ * - the initial maximum frequency f(max) is 5 MHz</span><br><span style="color: hsl(120, 100%, 40%);">+ * the card must measure the ETU based on the clock signal provided by the reader</span><br><span style="color: hsl(120, 100%, 40%);">+ * one ETU (e.g. 1 bit) takes F/D clock cycles, which the card must count</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * the card can indicate an alternative set of supported values Fi (with corresponding f(max)) and Di for higher baud rate in TA1 in the ATR (see ISO/IEC 7816-3 section 8.3)</span><br><span style="color: hsl(120, 100%, 40%);">+ * these values are selected according to ISO/IEC 7816-3 section 6.3.1:</span><br><span style="color: hsl(120, 100%, 40%);">+ * - card in specific mode: they are enforced if TA2 is present (the reader can deactivate the card if it does not support these values)</span><br><span style="color: hsl(120, 100%, 40%);">+ * - card in negotiable mode:</span><br><span style="color: hsl(120, 100%, 40%);">+ * -- they can be selected by the reader using the Protocol and Parameters Selection (PPS) procedure</span><br><span style="color: hsl(120, 100%, 40%);">+ * -- the first offered protocol and default values are used when no PPS is started</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * PPS is done with Fd and Dd (see ISO/IEC 7816-3 section 9)</span><br><span style="color: hsl(120, 100%, 40%);">+ * the reader can propose any F and D values between from Fd to Fi, and from Dd to Di (Fi and Di are indicated in TA1)</span><br><span style="color: hsl(120, 100%, 40%);">+ * the in PPS agreed values F and D are called Fn and Dn and are applied after a successful exchange, corresponding to PPS1_Response bit 5</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * the F and D values must be provided to the SAM3S USART peripheral (after reset and PPS)</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+bool iso7816_3_valid_f(uint16_t f)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     if (0 == f) {</span><br><span style="color: hsl(120, 100%, 40%);">+         return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t i = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+        for (i = 0; i < ARRAY_SIZE(iso7816_3_fi_table) && iso7816_3_fi_table[i] != f; i++);</span><br><span style="color: hsl(120, 100%, 40%);">+        return (i < ARRAY_SIZE(iso7816_3_fi_table) && iso7816_3_fi_table[i] == f);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+bool iso7816_3_valid_d(uint8_t d)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      if (0 == d) {</span><br><span style="color: hsl(120, 100%, 40%);">+         return false;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     uint8_t i = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+        for (i = 0; i < ARRAY_SIZE(iso7816_3_di_table) && iso7816_3_di_table[i] != d; i++);</span><br><span style="color: hsl(120, 100%, 40%);">+        return (i < ARRAY_SIZE(iso7816_3_di_table) && iso7816_3_di_table[i] == d);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * the ETU is not only used to define the baud rate, but also the Waiting Time (WT) (see ISO/IEC 7816-3 section 8.1)</span><br><span style="color: hsl(120, 100%, 40%);">+ * when exceeding WT without card response, the reader flags the card as unresponsive, and resets it</span><br><span style="color: hsl(120, 100%, 40%);">+ * this can be used by the card to indicate errors or unsupported operations</span><br><span style="color: hsl(120, 100%, 40%);">+ * if the card requires more time to respond, it shall send a procedure byte to restart WT</span><br><span style="color: hsl(120, 100%, 40%);">+ * WT is calculated as follows (for T=0, see ISO/IEC 7816-3 section 10.2): WT = WI x 960 x (Fi / f(max)) where</span><br><span style="color: hsl(120, 100%, 40%);">+ * - WI is encoded in TC2 in the ATR (10 if absent)</span><br><span style="color: hsl(120, 100%, 40%);">+ * - WI does not depend on D/Di (used for the ETU)</span><br><span style="color: hsl(120, 100%, 40%);">+ * - after reset WT is 9600 ETU</span><br><span style="color: hsl(120, 100%, 40%);">+ * - WI (e.g. the new WT) is applied when T=0 is used (after 6.3.1), even if Fi is not Fn (this WT extension is important to know for the reader so to have the right timeout)</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t iso7816_3_calculate_wt(uint8_t wi, uint16_t fi, uint8_t di, uint16_t f, uint8_t d)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  // sanity checks</span><br><span style="color: hsl(120, 100%, 40%);">+      if (0 == wi) {</span><br><span style="color: hsl(120, 100%, 40%);">+                return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!iso7816_3_valid_f(fi)) {</span><br><span style="color: hsl(120, 100%, 40%);">+         return -2;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!iso7816_3_valid_d(di)) {</span><br><span style="color: hsl(120, 100%, 40%);">+         return -3;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!iso7816_3_valid_f(f)) {</span><br><span style="color: hsl(120, 100%, 40%);">+          return -4;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!iso7816_3_valid_d(d)) {</span><br><span style="color: hsl(120, 100%, 40%);">+          return -5;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (f > fi) {</span><br><span style="color: hsl(120, 100%, 40%);">+              return -6;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (d > di) {</span><br><span style="color: hsl(120, 100%, 40%);">+              return -7;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return wi * 960UL * (fi/f) * (di/d); // calculate timeout value in ETU</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sysmoOCTSIM/iso7816_3.h b/sysmoOCTSIM/iso7816_3.h</span><br><span>new file mode 100644</span><br><span>index 0000000..738d2a2</span><br><span>--- /dev/null</span><br><span>+++ b/sysmoOCTSIM/iso7816_3.h</span><br><span>@@ -0,0 +1,98 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * as published by the Free Software Foundation; either version 2</span><br><span style="color: hsl(120, 100%, 40%);">+ * of the License, or (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</span><br><span style="color: hsl(120, 100%, 40%);">+*/</span><br><span style="color: hsl(120, 100%, 40%);">+/* this library provides utilities to handle the ISO-7816 part 3 communication aspects (e.g. related to F and D) */</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdbool.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** default clock rate conversion integer Fd</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.1</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_FD 372</span><br><span style="color: hsl(120, 100%, 40%);">+/** default baud rate adjustment factor Dd</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.1</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_DD 1</span><br><span style="color: hsl(120, 100%, 40%);">+/** default clock rate conversion integer Fi</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.3</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note non-default value is optionally specified in TA1</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_FI 372</span><br><span style="color: hsl(120, 100%, 40%);">+/** default baud rate adjustment factor Di</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.3</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note non-default value is optionally specified in TA1</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_DI 1</span><br><span style="color: hsl(120, 100%, 40%);">+/** default maximum clock frequency, in Hz</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.3</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note non-default value is optionally specified in TA1</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_FMAX 5000000UL</span><br><span style="color: hsl(120, 100%, 40%);">+/** default Waiting Integer (WI) value for T=0</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 10.2</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note non-default value is optionally specified in TC2</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_WI 10</span><br><span style="color: hsl(120, 100%, 40%);">+/** default Waiting Time (WT) value, in ETU</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.1</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note depends on Fi, Di, and WI if protocol T=0 is selected</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ISO7816_3_DEFAULT_WT 9600</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** Table encoding the clock rate conversion integer Fi</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note Fi is indicated in TA1, but the same table is used for F and Fn during PPS</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) table 7</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+extern const uint16_t iso7816_3_fi_table[];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** Table encoding the maximum clock frequency f_max in Hz</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) table 7</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note f_max is indicated in TA1, but the same table is used for F and Fn during PPS</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+extern const uint32_t iso7816_3_fmax_table[];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** Table encoding the baud rate adjust integer Di</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) table 8</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note Di is indicated in TA1, but the same table is used for D and Dn during PPS</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+extern const uint8_t iso7816_3_di_table[];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* verify if the clock rate conversion integer F value is valid</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param[in] f F value to be validated</span><br><span style="color: hsl(120, 100%, 40%);">+ * @return if F value is valid</span><br><span style="color: hsl(120, 100%, 40%);">+ * @note only values in ISO/IEC 7816-3:2006(E) table 7 are valid</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+bool iso7816_3_valid_f(uint16_t f);</span><br><span style="color: hsl(120, 100%, 40%);">+/* verify if the baud rate adjustment factor D value is valid</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param[in] d D value to be validated</span><br><span style="color: hsl(120, 100%, 40%);">+ * @return if D value is valid</span><br><span style="color: hsl(120, 100%, 40%);">+ * @note only values in ISO/IEC 7816-3:2006(E) table 8 are valid</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+bool iso7816_3_valid_d(uint8_t d);</span><br><span style="color: hsl(120, 100%, 40%);">+/** calculate Waiting Time (WT)</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] wi Waiting Integer</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] fi clock rate conversion integer Fi value</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] di baud rate adjustment factor Di value</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] f clock rate conversion integer F value</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @param[in] d baud rate adjustment factor D value</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @return Waiting Time WT, in ETU, or < 0 on error (see code for return codes)</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @note this should happen after reset and T=0 protocol select (through PPS or implicit)</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @implements ISO/IEC 7816-3:2006(E) section 8.1 and 10.2</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t iso7816_3_calculate_wt(uint8_t wi, uint16_t fi, uint8_t di, uint16_t f, uint8_t d);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13846">change 13846</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13846"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ccid-firmware </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ice4eba380126ff92089b71d0ea328b0110f7ffec </div>
<div style="display:none"> Gerrit-Change-Number: 13846 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kévin Redon <kredon@sysmocom.de> </div>