t0: fix wtime calculation, for real this time
ETU calculation is 1 etu = fi/di * 1/f as per chapter 7.1.
wtime/WWT is usually mentioned as being 9600 etu in iso 7816-3 - but
it's actually specified for t=0 as WT=WI*960*Fi/f in chapter 10.2 - no
di involved here, so the rightmost fraction is not ETU!
-> as soon as di is not 1 after a pps exchange the timeout value was off
by a factor of di if it was just used as a multiplier for ETU.
Change-Id: Icd4fa83e1177873e90200529331d3a1fce8be1c6
diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 2338919..18aa61f 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -246,6 +246,7 @@
uint16_t F = iso7816_3_fi_table[cs->proposed_pars.fi];
uint8_t D = iso7816_3_di_table[cs->proposed_pars.di];
uint32_t fmax = iso7816_3_fmax_table[cs->proposed_pars.fi];
+ uint8_t D_or_one = D > 0 ? D : 1;
/* 7816-3 5.2.3
* No information shall be exchanged when switching the
@@ -256,7 +257,7 @@
*/
card_uart_ctrl(ss->cuart, CUART_CTL_SET_CLOCK_FREQ, fmax);
card_uart_ctrl(ss->cuart, CUART_CTL_SET_FD, F/D);
- card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, cs->proposed_pars.t0.waiting_integer * 960);
+ card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, cs->proposed_pars.t0.waiting_integer * 960 * D_or_one);
cs->pars = cs->proposed_pars;
resp = ccid_gen_parameters_t0(cs, ss->seq, CCID_CMD_STATUS_OK, 0);