summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2022-06-22 19:04:35 +0200
committerFrediano Ziglio <freddy77@gmail.com>2023-06-08 20:36:40 +0100
commita1d0ff62b62f61167dcbf9192383254c3ae858e5 (patch)
tree3444baea2bf180a4eecb6803760c2eb2aefe5a0c
parent1d6a07e4bf27fcca1afc152201601374d8630452 (diff)
Test few more remaining branches
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
-rw-r--r--tests/common.c37
-rw-r--r--tests/libcacard.c40
2 files changed, 68 insertions, 9 deletions
diff --git a/tests/common.c b/tests/common.c
index f1613c1..23d39ee 100644
--- a/tests/common.c
+++ b/tests/common.c
@@ -980,7 +980,21 @@ void test_msft_applet(void)
* in select_aid()
*/
+ /* ask the applet for unknown data */
+ getdata[2] = 0xff;
+ getdata[3] = 0xff;
+ dwRecvLength = APDUBufSize;
+ status = vreader_xfr_bytes(reader,
+ getdata, sizeof(getdata),
+ pbRecvBuffer, &dwRecvLength);
+ g_assert_cmpint(status, ==, VREADER_OK);
+ g_assert_cmpint(dwRecvLength, ==, 2);
+ g_assert_cmpint(pbRecvBuffer[dwRecvLength-2], ==, 0x6a);
+ g_assert_cmpint(pbRecvBuffer[dwRecvLength-1], ==, 0x88);
+
/* ask the applet for our data */
+ getdata[2] = 0x7f;
+ getdata[3] = 0x68;
dwRecvLength = APDUBufSize;
status = vreader_xfr_bytes(reader,
getdata, sizeof(getdata),
@@ -1070,6 +1084,29 @@ void test_gp_applet(void)
}
g_assert_cmpint(equal_bytes, <, 6);
+ /* 0x0066 tag should return card registration data */
+ dwRecvLength = APDUBufSize;
+ getdata[2] = 0x00;
+ getdata[3] = 0x66;
+ status = vreader_xfr_bytes(reader,
+ getdata, sizeof(getdata),
+ pbRecvBuffer, &dwRecvLength);
+ g_assert_cmpint(status, ==, VREADER_OK);
+ g_assert_cmpint(dwRecvLength, ==, 53);
+ g_assert_cmpint(pbRecvBuffer[dwRecvLength-2], ==, VCARD7816_SW1_SUCCESS);
+ g_assert_cmpint(pbRecvBuffer[dwRecvLength-1], ==, 0x00);
+
+ /* anything else should fail */
+ dwRecvLength = APDUBufSize;
+ getdata[2] = 0xff;
+ getdata[3] = 0xff;
+ status = vreader_xfr_bytes(reader,
+ getdata, sizeof(getdata),
+ pbRecvBuffer, &dwRecvLength);
+ g_assert_cmpint(status, ==, VREADER_OK);
+ g_assert_cmpint(dwRecvLength, ==, 2);
+ g_assert_cmpint(pbRecvBuffer[dwRecvLength-2], ==, 0x6a);
+ g_assert_cmpint(pbRecvBuffer[dwRecvLength-1], ==, 0x88);
vreader_free(reader); /* get by id ref */
}
diff --git a/tests/libcacard.c b/tests/libcacard.c
index a475443..f29999b 100644
--- a/tests/libcacard.c
+++ b/tests/libcacard.c
@@ -838,6 +838,19 @@ static void test_invalid_select(void)
g_assert_cmpint(pbRecvBuffer[0], ==, VCARD7816_SW1_COMMAND_ERROR);
g_assert_cmpint(pbRecvBuffer[1], ==, 0x84);
+ /* The generic code handles only P1 = 0x04 */
+ select_gp(reader);
+
+ selfile[2] = 0xff;
+ dwRecvLength = APDUBufSize;
+ status = vreader_xfr_bytes(reader,
+ selfile, sizeof(selfile),
+ pbRecvBuffer, &dwRecvLength);
+ g_assert_cmpint(status, ==, VREADER_OK);
+ g_assert_cmpint(dwRecvLength, ==, 2);
+ g_assert_cmpint(pbRecvBuffer[0], ==, 0x6a);
+ g_assert_cmpint(pbRecvBuffer[1], ==, 0x81);
+
/* TODO check the iso7816 code handling the remaining SELECT APDUs */
vreader_free(reader); /* get by id ref */
@@ -858,15 +871,15 @@ static void test_invalid_instruction(void)
/* Card Capability Container */
select_applet(reader, TEST_CCC);
- /* 0xFF is invalid instruction everywhere, but fails in apdu_ins_to_string() */
- /*dwRecvLength = APDUBufSize;
+ /* 0xFF is invalid instruction everywhere */
+ dwRecvLength = APDUBufSize;
status = vreader_xfr_bytes(reader,
apdu, sizeof(apdu),
pbRecvBuffer, &dwRecvLength);
g_assert_cmpint(status, ==, VREADER_OK);
g_assert_cmpint(dwRecvLength, ==, 2);
g_assert_cmpint(pbRecvBuffer[0], ==, VCARD7816_SW1_INS_ERROR);
- g_assert_cmpint(pbRecvBuffer[1], ==, 0x00);*/
+ g_assert_cmpint(pbRecvBuffer[1], ==, 0x00);
/* CCC Applet does not know GET ACR instruction */
apdu[1] = 0x4c;
@@ -881,12 +894,11 @@ static void test_invalid_instruction(void)
/* TODO check the iso7816 code handling the remaining SELECT APDUs */
+ /* GP applet sends most of the instructions to the generic ISO handling */
+ select_gp(reader);
- /* PKI Applet */
- select_applet(reader, TEST_PKI);
-
- /* Update Buffer is not supported */
- apdu[1] = 0x58;
+ /* Secure messaging instructions not supported */
+ apdu[1] = 0x70;
dwRecvLength = APDUBufSize;
status = vreader_xfr_bytes(reader,
apdu, sizeof(apdu),
@@ -894,8 +906,18 @@ static void test_invalid_instruction(void)
g_assert_cmpint(status, ==, VREADER_OK);
g_assert_cmpint(dwRecvLength, ==, 2);
g_assert_cmpint(pbRecvBuffer[0], ==, VCARD7816_SW1_COMMAND_ERROR);
- g_assert_cmpint(pbRecvBuffer[1], ==, 0x85);
+ g_assert_cmpint(pbRecvBuffer[1], ==, 0x00);
+ /* 0xFF is invalid instruction also in the global APDU processing */
+ apdu[1] = 0xff;
+ dwRecvLength = APDUBufSize;
+ status = vreader_xfr_bytes(reader,
+ apdu, sizeof(apdu),
+ pbRecvBuffer, &dwRecvLength);
+ g_assert_cmpint(status, ==, VREADER_OK);
+ g_assert_cmpint(dwRecvLength, ==, 2);
+ g_assert_cmpint(pbRecvBuffer[0], ==, 0x69);
+ g_assert_cmpint(pbRecvBuffer[1], ==, 0x00);
vreader_free(reader); /* get by id ref */
}