This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgHello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1538 to look at the new patch set (#5). Use define for key buffers This effectively doubles the Kc buffer which enable us to match the requirements for future A5/4 and GEA4 support (see 3GPP TS 55.216 V6.2.0 and 3GPP TS 55.226 V9.0.0 specs). Add corresponding spec. references and comments where appropriate. Note: the GSUP test output have to be adjusted because KC parser now accept both 64 and 128 bit Kc lengths as valid. Related: OS#1910 Change-Id: I8d347bbeadc14cbc7306ea6e9b73e4a1c8c8cb21 --- M TODO-RELEASE M include/osmocom/crypt/auth.h M src/gsm/auth_core.c M src/gsm/gsup.c M tests/auth/milenage_test.c M tests/gsup/gsup_test.err M utils/osmo-auc-gen.c 7 files changed, 20 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/1538/5 diff --git a/TODO-RELEASE b/TODO-RELEASE index 782ba19..d498850 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -10,3 +10,4 @@ core msgb_queue_free() add inline func to msgb.h coding gsm0503_rach_ext-encode() add func to gsm0503_coding.h codec ecu.c / ecu.h implement ECU for FR (Error Concealment Unit) +libosmogsm osmo_auth_vector expand kc[] field to accommodate for GEA4 and A5/4 key sizes \ No newline at end of file diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index e544126..d2a2ff8 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -42,7 +42,7 @@ union { struct { uint8_t opc[16]; /*!< operator invariant value */ - uint8_t k[16]; /*!< secret key of the subscriber */ + uint8_t k[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< secret key of the subscriber */ uint8_t amf[2]; uint64_t sqn; /*!< sequence number (in: prev sqn; out: used sqn) */ int opc_is_op; /*!< is the OPC field OPC (0) or OP (1) ? */ @@ -60,11 +60,11 @@ struct osmo_auth_vector { uint8_t rand[16]; /*!< random challenge */ uint8_t autn[16]; /*!< authentication nonce */ - uint8_t ck[16]; /*!< ciphering key */ - uint8_t ik[16]; /*!< integrity key */ + uint8_t ck[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< ciphering key */ + uint8_t ik[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< integrity key */ uint8_t res[16]; /*!< authentication result */ uint8_t res_len; /*!< length (in bytes) of res */ - uint8_t kc[8]; /*!< Kc for GSM encryption (A5) */ + uint8_t kc[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< Kc for GSM/GPRS encryption (A5 & GEA) */ uint8_t sres[4]; /*!< authentication result for GSM */ uint32_t auth_types; /*!< bitmask of OSMO_AUTH_TYPE_* */ }; diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index f171ed4..9e750a0 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -98,7 +98,7 @@ return 0; } -/* C5 function to derive UMTS IK from GSM Kc */ +/* 3GPP TS 33.102 §6.8.2.3 C5 function to derive UMTS IK from GSM Kc */ static inline void c5_function(uint8_t *ik, const uint8_t *kc) { unsigned int i; @@ -110,7 +110,7 @@ ik[i] = ik[i-12]; } -/* C4 function to derive UMTS CK from GSM Kc */ +/* 3GPP TS 33.102 §6.8.2.3 C4 function to derive UMTS CK from GSM Kc */ void osmo_c4(uint8_t *ck, const uint8_t *kc) { memcpy(ck, kc, 8); diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index eb829f7..31d423f 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -154,7 +154,7 @@ break; case OSMO_GSUP_KC_IE: - if (value_len != sizeof(auth_vector->kc)) + if (value_len != OSMO_A5_MAX_KEY_LEN_BYTES && value_len != OSMO_A5_MAX_KEY_LEN_BYTES/2) goto parse_error; memcpy(auth_vector->kc, value, value_len); @@ -450,8 +450,8 @@ msgb_tlv_put(msg, OSMO_GSUP_SRES_IE, sizeof(auth_vector->sres), auth_vector->sres); - msgb_tlv_put(msg, OSMO_GSUP_KC_IE, - sizeof(auth_vector->kc), auth_vector->kc); + /* FIXME: choose proper length for A5/4 and GEA4 support */ + msgb_tlv_put(msg, OSMO_GSUP_KC_IE, OSMO_A5_MAX_KEY_LEN_BYTES/2, auth_vector->kc); } if (auth_vector->auth_types & OSMO_AUTH_TYPE_UMTS) { diff --git a/tests/auth/milenage_test.c b/tests/auth/milenage_test.c index 2bd3cf2..8b058e5 100644 --- a/tests/auth/milenage_test.c +++ b/tests/auth/milenage_test.c @@ -23,7 +23,10 @@ if (vec->auth_types & OSMO_AUTH_TYPE_GSM) { printf("SRES:\t%s\n", osmo_hexdump(vec->sres, sizeof(vec->sres))); - printf("Kc:\t%s\n", osmo_hexdump(vec->kc, sizeof(vec->kc))); + /* According to 3GPP TS 55.205 Sec. 4 the GSM-MILENAGE output is limited to 64 bits. + According to 3GPP TS 33.102 Annex. B5 in UMTS security context Kc can be 128 bits. + Here we test the former, so make sure we only print interesting Kc bits. */ + printf("Kc:\t%s\n", osmo_hexdump(vec->kc, OSMO_A5_MAX_KEY_LEN_BYTES/2)); } } diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err index 05c64fe..1c59d9f 100644 --- a/tests/gsup/gsup_test.err +++ b/tests/gsup/gsup_test.err @@ -57,7 +57,7 @@ DLGSUP Stopping DLGSUP logging message 0: tested 2816 modifications, 510 parse failures message 1: tested 3584 modifications, 768 parse failures - message 2: tested 21248 modifications, 2571 parse failures + message 2: tested 21248 modifications, 2569 parse failures message 3: tested 2816 modifications, 510 parse failures message 4: tested 3584 modifications, 768 parse failures message 5: tested 20736 modifications, 4010 parse failures @@ -67,5 +67,5 @@ message 9: tested 2816 modifications, 510 parse failures message 10: tested 3584 modifications, 768 parse failures message 11: tested 3328 modifications, 767 parse failures - message 12: tested 54016 modifications, 4622 parse failures + message 12: tested 54016 modifications, 4613 parse failures message 13: tested 11520 modifications, 1026 parse failures diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index ec9bad8..8eaac53 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -45,7 +45,8 @@ printf("imsi,"); printf("%s,", osmo_hexdump_nospc(vec->rand, sizeof(vec->rand))); printf("%s,", osmo_hexdump_nospc(vec->sres, sizeof(vec->sres))); - printf("%s\n", osmo_hexdump_nospc(vec->kc, sizeof(vec->kc))); + /* FIXME: choose proper length for A5/4 and GEA4 support */ + printf("%s\n", osmo_hexdump_nospc(vec->kc, OSMO_A5_MAX_KEY_LEN_BYTES/2)); } static void dump_auth_vec(struct osmo_auth_vector *vec) @@ -61,7 +62,8 @@ if (vec->auth_types & OSMO_AUTH_TYPE_GSM) { printf("SRES:\t%s\n", osmo_hexdump_nospc(vec->sres, sizeof(vec->sres))); - printf("Kc:\t%s\n", osmo_hexdump_nospc(vec->kc, sizeof(vec->kc))); + /* FIXME: choose proper length for A5/4 and GEA4 support */ + printf("Kc:\t%s\n", osmo_hexdump_nospc(vec->kc, OSMO_A5_MAX_KEY_LEN_BYTES/2)); } } -- To view, visit https://gerrit.osmocom.org/1538 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I8d347bbeadc14cbc7306ea6e9b73e4a1c8c8cb21 Gerrit-PatchSet: 5 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder