laforge has uploaded this change for review.
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
---
M src/sim/class_tables.c
M tests/sim/sim_test.c
M tests/sim/sim_test.ok
3 files changed, 33 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/66/37066/1
diff --git a/src/sim/class_tables.c b/src/sim/class_tables.c
index 29ef2d7..3d50521 100644
--- a/src/sim/class_tables.c
+++ b/src/sim/class_tables.c
@@ -178,6 +178,7 @@
{
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 @@
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 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 */
diff --git a/tests/sim/sim_test.c b/tests/sim/sim_test.c
index 9a52af4..ab5d2be 100644
--- a/tests/sim/sim_test.c
+++ b/tests/sim/sim_test.c
@@ -29,6 +29,8 @@
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 @@
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)
diff --git a/tests/sim/sim_test.ok b/tests/sim/sim_test.ok
index cac59ba..3abfb71 100644
--- a/tests/sim/sim_test.ok
+++ b/tests/sim/sim_test.ok
@@ -6,3 +6,5 @@
Testing uicc_upd
Testing uicc_get_status
Testing euicc_m2m_get_status
+Testing gp_get_data2
+Testing gp_get_data4
To view, visit change 37066. To unsubscribe, or for help writing mail filters, visit settings.