libosmosim: class_tables: Fix GlobalPlatform CLA=8x INS=CA/CB GET DATA

in their infinite wisdom, GlobalPlatform made GET DATA a command that can be either APDU
case 2 or case 4.  As the specify Le must be 0x00, we can conclude that P3 == 0x00 must be
Le, while P3 != 0x00 must be Lc and hence case 4 */

Change-Id: Ic8a17921f5a42d227791f1de39f90b4967c2e1b6
Related: SYS#6865
This commit is contained in:
Harald Welte 2024-06-05 19:43:43 +02:00
parent 020b3248a8
commit fb52e1dcbb
3 changed files with 19 additions and 2 deletions

View File

@ -178,6 +178,7 @@ static int gp_cla_ins_helper(const struct osim_cla_ins_case *cic,
{
uint8_t ins = hdr[1];
uint8_t p1 = hdr[2];
uint8_t p3 = hdr[4];
switch (ins) {
case 0xE2: /* STORE DATA */
@ -197,6 +198,16 @@ static int gp_cla_ins_helper(const struct osim_cla_ins_case *cic,
else
return 2; /* ETSI TS 102 221 V16.2.0 11.1.2 */
break;
case 0xCA:
case 0xCB:
/* in their infinite wisdom, GlobalPlatform made GET DATA a command that can be either APDU
* case 2 or case 4. As the specify Le must be 0x00, we can conclude that P3 == 0x00 must be
* Le, while P3 != 0x00 must be Lc and hence case 4 */
if (p3 == 0x00)
return 2;
else
return 4;
break;
}
return 0;
}
@ -225,8 +236,8 @@ static const uint8_t uicc_ins_tbl_80[256] = {
static const uint8_t gp_ins_tbl_8ce[256] = {
[0xE4] = 4, /* DELETE */
[0xE2] = 0x80, /* STORE DATA */
[0xCA] = 4, /* GET DATA */
[0xCB] = 4, /* GET DATA */
[0xCA] = 0x80, /* GET DATA */
[0xCB] = 0x80, /* GET DATA */
[0xF2] = 0x80, /* GET STATUS */
[0xE6] = 4, /* INSTALL */
[0xE8] = 4, /* LOAD */

View File

@ -29,6 +29,8 @@ const uint8_t uicc_read[] = { 0x00, 0xB0, 0x00, 0x00, 0x10 };
const uint8_t uicc_upd[] = { 0x00, 0xD6, 0x00, 0x00, 0x02, 0x01, 0x02 };
const uint8_t uicc_get_status[] = { 0x80, 0xf2, 0x00, 0x02, 0x10 };
const uint8_t euicc_m2m_get_status[] = { 0x81, 0xf2, 0x40, 0x02, 0x02, 0x4f, 0x00 };
const uint8_t gp_get_data2[] = { 0x81, 0xCA, 0x00, 0x5A, 0x00 };
const uint8_t gp_get_data4[] = { 0x81, 0xCA, 0x00, 0x5A, 0x12 };
#define APDU_CASE_ASSERT(x, y) \
do { \
@ -49,6 +51,8 @@ static void test_cla_ins_tbl(void)
APDU_CASE_ASSERT(uicc_upd, 3);
APDU_CASE_ASSERT(uicc_get_status, 2);
APDU_CASE_ASSERT(euicc_m2m_get_status, 4);
APDU_CASE_ASSERT(gp_get_data2, 2);
APDU_CASE_ASSERT(gp_get_data4, 4);
}
int main(int argc, char **argv)

View File

@ -6,3 +6,5 @@ Testing uicc_read
Testing uicc_upd
Testing uicc_get_status
Testing euicc_m2m_get_status
Testing gp_get_data2
Testing gp_get_data4