laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42791?usp=email )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: CCID: Truncated APDU test ......................................................................
CCID: Truncated APDU test
A SELECT APDU must have a header + two bytes of data (what to select). The test truncates this APDU in all variants, ranging from 6 bytes down to 0 bytes. The reader may respond with an error caused by invald request or with and error caused by timeout of the SIM.
Change-Id: I3df2ad9871bccdd03f618a6a457671adb1624590 --- M ccid/CCID_Tests.ttcn 1 file changed, 41 insertions(+), 1 deletion(-)
Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified
diff --git a/ccid/CCID_Tests.ttcn b/ccid/CCID_Tests.ttcn index f5dae50..107d00d 100644 --- a/ccid/CCID_Tests.ttcn +++ b/ccid/CCID_Tests.ttcn @@ -43,6 +43,7 @@ const octetstring c_SIM_SELECT_EF_ICCID := '00A4000C022FE2'O; const octetstring c_SIM_READ_BINARY := '00B000000A'O; const octetstring c_UICC_GET_RESPONSE_BASE := 'a0c00000'O; +const octetstring c_UICC_TRUNCATED := '00a40004'O;
/* Table 7 of ISO7816-3 */ type enumerated ISO7816_Fi { @@ -564,9 +565,47 @@ f_start_and_wait(); }
+/* truncated transfer */ +private function f_TC_truncated() runs on Slot_CT +{ + var integer i; + var octetstring req; + var CCID_PDU pdu; + const record of octetstring c_status := { '6700'O, '6700'O, '6700'O, '6d00'O, '6881'O }; + + f_ccid_power_on(); + for (i := 4; i >= 0; i := i-1) { + log("Testing trunkted transfer block with ", i, " octet(s)."); + req := substr(c_UICC_TRUNCATED, 0, i); + pdu := f_ccid_xfr_pdu(req, ?); + if (pdu.hdr_in.bStatus.bmCommandStatus == CCID_CMD_STATUS_FAILED) { + log("Command failed as expected."); + continue; + } + if (pdu.u.DataBlock.abData == c_status[4 - i]) { + log("Got expected status result. (status ", c_status[4 - i], ")"); + continue; + } + setverdict(fail, "Unexpected SW1/SW2. (expected ", c_status[4 - i], ", got ", + pdu.u.DataBlock.abData, ")"); + mtc.stop; + } +} +testcase TC_truncated() runs on Test_CT +{ + var integer i; + + f_init(); + + for (i := 0; i < mp_use_slot_count; i := i+1) { + f_start_handler(refers(f_TC_truncated), i); + } + + f_start_and_wait(); +} +
/* TODO */ -/* truncated message */ /* IccPowerOn with wrong voltage (> 0x04) */ /* XfrBlock on empty slot */ /* GetParameters on empty slot */ @@ -606,6 +645,7 @@ } execute( TC_unsupp_mechanical() ); execute( TC_unsupp_secure() ); + execute( TC_truncated() ); }