diff options
Diffstat (limited to 'packet-gsm_sim.c')
-rw-r--r-- | packet-gsm_sim.c | 115 |
1 files changed, 106 insertions, 9 deletions
diff --git a/packet-gsm_sim.c b/packet-gsm_sim.c index e416ac7..392786a 100644 --- a/packet-gsm_sim.c +++ b/packet-gsm_sim.c @@ -61,6 +61,14 @@ static int hf_record_nr = -1; static int hf_auth_rand = -1; static int hf_auth_sres = -1; static int hf_auth_kc = -1; + +static int hf_auth_3g_status = -1; +static int hf_auth_autn = -1; +static int hf_auth_auts = -1; +static int hf_auth_res = -1; +static int hf_auth_ck = -1; +static int hf_auth_ik = -1; + static int hf_chan_op = -1; static int hf_chan_nr = -1; @@ -812,7 +820,7 @@ dissect_bertlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) #define DATA_OFFS 3 static int -dissect_gsm_apdu(guint8 ins, guint8 p1, guint8 p2, guint8 p3, +dissect_gsm_apdu(guint8 cla, guint8 ins, guint8 p1, guint8 p2, guint8 p3, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) { guint8 g8; @@ -894,14 +902,73 @@ dissect_gsm_apdu(guint8 ins, guint8 p1, guint8 p2, guint8 p3, offset += DATA_OFFS; /* FIXME: actual PIN/PUK code */ break; - case 0x88: /* RUN GSM ALGO */ + case 0x88: /* RUN GSM ALGO / AUTHENTICATE */ offset += DATA_OFFS; - proto_tree_add_item(tree, hf_auth_rand, tvb, offset+DATA_OFFS, 16, ENC_NA); - offset += 16; - proto_tree_add_item(tree, hf_auth_sres, tvb, offset, 4, ENC_NA); - offset += 4; - proto_tree_add_item(tree, hf_auth_kc, tvb, offset, 8, ENC_NA); - offset += 8; + if (cla == 0xA0) { + /* SIM */ + proto_tree_add_item(tree, hf_auth_rand, tvb, offset+DATA_OFFS, 16, ENC_NA); + offset += 16; + proto_tree_add_item(tree, hf_auth_sres, tvb, offset, 4, ENC_NA); + offset += 4; + proto_tree_add_item(tree, hf_auth_kc, tvb, offset, 8, ENC_NA); + offset += 8; + } else { + /* USIM AUTHENTICATE 31.102 Chapter 7.1.2 */ + guint8 l_rand, l_autn, l_res, l_ck, l_ik, l_kc; + switch (p2 & 7) { + case 0: /* GSM context */ + case 1: /* 3G context */ + l_rand = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_rand, tvb, offset, l_rand, ENC_NA); + offset += l_rand; + l_autn = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_autn, tvb, offset, l_autn, ENC_NA); + offset += l_autn; + break; + default: + /* FIXME */ + break; + } + switch (p2 & 7) { + case 0: /* GSM context */ + l_res = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_sres, tvb, offset, l_res, ENC_NA); + offset += l_res; + l_kc = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_kc, tvb, offset, l_kc, ENC_NA); + offset += l_kc; + break; + case 1: /* 3G context */ + proto_tree_add_item(tree, hf_auth_3g_status, tvb, offset, 1, ENC_NA); + switch (tvb_get_guint8(tvb, offset++)) { + case 0xDB: /* successful */ + l_res = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_res, tvb, offset, l_res, ENC_NA); + offset += l_res; + l_ck = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_ck, tvb, offset, l_ck, ENC_NA); + offset += l_ck; + l_ik = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_ik, tvb, offset, l_ik, ENC_NA); + offset += l_ik; + l_kc = tvb_Get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_kc, tvb, offset, l_kc, ENC_NA); + offset += l_kc; + break; + case 0xDC: /* failure */ + l_res = tvb_get_guint8(tvb, offset++); + proto_tree_add_item(tree, hf_auth_auts, tvb, offset, l_res, ENC_NA); + offset += l_res; + break; + } + break; + case 2: /* VGCS/VBS context */ + /* FIXME */ + case 3: /* GBA context */ + /* FIXME */ + break; + } + } break; case 0x10: /* TERMINAL PROFILE */ offset += DATA_OFFS; @@ -991,7 +1058,7 @@ dissect_apdu_tvb(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree val_to_str(cla, apdu_cla_vals, "%02x")); //if (cla == 0xA0) - rc = dissect_gsm_apdu(ins, p1, p2, p3, tvb, offset, pinfo, sim_tree); + rc = dissect_gsm_apdu(cla, ins, p1, p2, p3, tvb, offset, pinfo, sim_tree); if (rc == -1 && sim_tree) { /* default dissector */ @@ -1106,6 +1173,36 @@ proto_register_gsm_sim(void) FT_BYTES, BASE_NONE, NULL, 0, "GSM Authentication Kc result", HFILL } }, + { &hf_auth_3g_status, + { "3G Auth Status", "usim.auth.status", + FT_UINT8, BASE_HEX, NULL, 0, + "USIM 3G Auth Status", HFILL } + }, + { &hf_auth_autn, + { "AUTN", "usim.auth.autn", + FT_BYTES, BASE_NONE, NULL, 0, + "UMTS AKA AUTN parameter", HFILL } + }, + { &hf_auth_auts, + { "AUTS", "usim.auth.auts", + FT_BYTES, BASE_NONE, NULL, 0, + "UMTS AKA AUTS response", HFILL } + }, + { &hf_auth_res, + { "RES", "usim.auth.res", + FT_BYTES, BASE_NONE, NULL, 0, + "UMTS AKA RES response", HFILL } + }, + { &hf_auth_ck, + { "CK", "usim.auth.ck", + FT_BYTES, BASE_NONE, NULL, 0, + "UMTS AKA CK (ciphering key) response", HFILL } + }, + { &hf_auth_ik, + { "IK", "usim.auth.ik", + FT_BYTES, BASE_NONE, NULL, 0, + "UMTS AKA IK (integrity key) response", HFILL } + }, { &hf_chan_nr, { "Channel Number", "iso7816.chan_nr", FT_UINT8, BASE_DEC, NULL, 0, |