jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42797?usp=email )
Change subject: CCID: Send procedure byte, when not expected ......................................................................
CCID: Send procedure byte, when not expected
A case 1 APDU does not request any data from SIM to return. The SIM will only return a status byte with no procedure byte in advance.
The test sends a procedure byte in advance of the two status bytes towards the reader. The reader expects SW1 instead of the status byte, so that it returns it as SW1.
Change-Id: Icffd48d99f0eb48e0898efb027854eba8c22f4a4 --- M ccid/CCID_Tests.ttcn 1 file changed, 39 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/97/42797/1
diff --git a/ccid/CCID_Tests.ttcn b/ccid/CCID_Tests.ttcn index 1e2b99f..1ac1351 100644 --- a/ccid/CCID_Tests.ttcn +++ b/ccid/CCID_Tests.ttcn @@ -836,6 +836,44 @@ f_start_and_wait(); }
+/* Send a procedure byte where only a status is expected. */ +private function f_TC_unexpected_procedure_byte() runs on CardemSlot_CT +{ + var octetstring req := c_UICC_MANAGE_CHANNEL; + var octetstring res := '62'O; + var CCID_PDU ccid_pdu; + + f_cardem_manager(); + + f_ccid_power_on(CCID_PWRSEL_3V0); + + /* Send a request towards reader. */ + CCID.send(ts_CCID_XfrBlock(g_slot_nr, req, 0)); + /* Receive the request by SIM. */ + f_cardem_receive(tr_SIMTRACE_CEMU_RX_DATA(?, req)); + /* Transmit the response by SIM. */ + f_cardem_transmit(ts_SIMTRACE_CEMU_TX_DATA(ts_CardEmu_DataFlags(pb_and_tx := true, final := true), + req[1] & res)); + /* Receive the response from reader. */ + ccid_pdu := f_ccid_receive(tr_CCID_DataBlock(g_slot_nr, ?, ?, ?)); + if (ccid_pdu.u.DataBlock.abData != req[1] & res[0]) { + setverdict(fail, "Unexpected SW1/SW2"); + mtc.stop; + } + + /* Stop simtrace emulation, to prevent race condition. */ + vc_Cardem.stop; + vc_Cardem.done; +} +testcase TC_unexpected_procedure_byte() runs on Test_CT +{ + f_init(); + + f_start_handler(refers(f_TC_unexpected_procedure_byte), mp_simtrace_slot, true); + + f_start_and_wait(); +} +
/* TODO */ /* IccPowerOn with wrong voltage (> 0x04) */ @@ -881,6 +919,7 @@ execute( TC_truncated() ); execute( TC_truncated_response() ); execute( TC_wrong_procedure_byte() ); + execute( TC_unexpected_procedure_byte() ); }