lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

June 2023

  • 1 participants
  • 2480 discussions
[XL] Change in libosmocore[master]: libosmogsm: Add support for TUAK authentication algorithm
by laforge 02 Jun '23

02 Jun '23
Attention is currently required from: laforge. Hello Jenkins Builder, fixeria, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/33094 to look at the new patch set (#8). Change subject: libosmogsm: Add support for TUAK authentication algorithm ...................................................................... libosmogsm: Add support for TUAK authentication algorithm The TUAK algorithm is specified in 3GPP TS 35.231, 232 and 233 and intended as an alternative to MILENAGE. It's based around the cryptographic function of KeccakP1600, which is part of SHA-3. This patch adds support for TUAK to the libosmogsm authentication core API via 'struct osmo_auth_impl'. Unit tests covering the test cases from the 3GPP specification are added (and are all passing). Change-Id: Ib905b8d8bdf248e8299bf50666ee1bca8298433d --- A .checkpatch.conf M TODO-RELEASE M include/osmocom/crypt/auth.h M src/gsm/Makefile.am M src/gsm/auth_core.c A src/gsm/auth_tuak.c A src/gsm/tuak/KeccakP-1600-3gpp.c A src/gsm/tuak/KeccakP-1600-3gpp.h A src/gsm/tuak/tuak.c A src/gsm/tuak/tuak.h M tests/Makefile.am A tests/auth/tuak_test.c A tests/auth/tuak_test.ok 13 files changed, 1,205 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/33094/8 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33094 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ib905b8d8bdf248e8299bf50666ee1bca8298433d Gerrit-Change-Number: 33094 Gerrit-PatchSet: 8 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in libosmocore[master]: libosmogsm: Ensure MILENAGE + XOR-3G K length is 128 bit
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33089 ) ( 4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: libosmogsm: Ensure MILENAGE + XOR-3G K length is 128 bit ...................................................................... libosmogsm: Ensure MILENAGE + XOR-3G K length is 128 bit Since Change-Id Ie775fedba4a3fa12314c0f7c8a369662ef6a40df we are supporting K-lengths != 128 bit. However, our existing MILENAGE and XOR-3G algorithms only support that key length, so let's add some explicit checks for that. Change-Id: Iae8b93cf059abda087101cdd01bbcf92d355753b --- M src/gsm/auth_milenage.c M src/gsm/auth_xor.c 2 files changed, 33 insertions(+), 4 deletions(-) Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c index 84780c6..9e94293 100644 --- a/src/gsm/auth_milenage.c +++ b/src/gsm/auth_milenage.c @@ -19,6 +19,7 @@ * */ +#include <errno.h> #include <osmocom/crypt/auth.h> #include <osmocom/core/bits.h> #include "milenage/common.h" @@ -57,6 +58,11 @@ OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE); + if (aud->u.umts.k_len != 16) + return -EINVAL; + if (aud->u.umts.opc_len != 16) + return -EINVAL; + opc = gen_opc_if_needed(aud, gen_opc); if (!opc) return -1; @@ -154,6 +160,11 @@ OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE); + if (aud->u.umts.k_len != 16) + return -EINVAL; + if (aud->u.umts.opc_len != 16) + return -EINVAL; + opc = gen_opc_if_needed(aud, gen_opc); rc = milenage_auts(opc, aud->u.umts.k, rand_auts, auts, sqn_out); diff --git a/src/gsm/auth_xor.c b/src/gsm/auth_xor.c index c94b02f..a506a03 100644 --- a/src/gsm/auth_xor.c +++ b/src/gsm/auth_xor.c @@ -55,9 +55,11 @@ /* Step 1: xdout = (ki or k) ^ rand */ if (aud->type == OSMO_AUTH_TYPE_GSM) xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout)); - else if (aud->type == OSMO_AUTH_TYPE_UMTS) + else if (aud->type == OSMO_AUTH_TYPE_UMTS) { + if (aud->u.umts.k_len != 16) + return -EINVAL; xor(xdout, aud->u.umts.k, _rand, sizeof(xdout)); - else + } else return -ENOTSUP; /** @@ -141,9 +143,11 @@ /* Step 1: xdout = (ki or k) ^ rand */ if (aud->type == OSMO_AUTH_TYPE_GSM) xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout)); - else if (aud->type == OSMO_AUTH_TYPE_UMTS) + else if (aud->type == OSMO_AUTH_TYPE_UMTS) { + if (aud->u.umts.k_len != 16) + return -EINVAL; xor(xdout, aud->u.umts.k, _rand, sizeof(xdout)); - else + } else return -ENOTSUP; /* Step 2: ak = xdout[2-8] */ -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33089 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iae8b93cf059abda087101cdd01bbcf92d355753b Gerrit-Change-Number: 33089 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmocore[master]: libosmogsm: Add OSMO_ASSERT() to ensure correct algorithm
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33088 ) ( 4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: libosmogsm: Add OSMO_ASSERT() to ensure correct algorithm ...................................................................... libosmogsm: Add OSMO_ASSERT() to ensure correct algorithm Let's make sure that nobody ever ends up calling the algo_impl call-backs with data of a non-matching algorithm. This should never happen at all, as all normal users should go through the auth_core.c:osmo_auth_gen_vec* API, which dispatches based on algorithm. Change-Id: I22b504b6cffb4999b2f14772fffcb2f6f02c198c --- M src/gsm/auth_comp128v1.c M src/gsm/auth_comp128v23.c M src/gsm/auth_milenage.c M src/gsm/auth_xor.c M src/gsm/auth_xor_2g.c 5 files changed, 28 insertions(+), 0 deletions(-) Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/gsm/auth_comp128v1.c b/src/gsm/auth_comp128v1.c index a314dc2..ded3f8a 100644 --- a/src/gsm/auth_comp128v1.c +++ b/src/gsm/auth_comp128v1.c @@ -30,6 +30,7 @@ struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_COMP128v1); comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc); vec->auth_types = OSMO_AUTH_TYPE_GSM; diff --git a/src/gsm/auth_comp128v23.c b/src/gsm/auth_comp128v23.c index 697858a..f942bc0 100644 --- a/src/gsm/auth_comp128v23.c +++ b/src/gsm/auth_comp128v23.c @@ -32,6 +32,7 @@ struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_COMP128v2); comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc); vec->auth_types = OSMO_AUTH_TYPE_GSM; @@ -49,6 +50,7 @@ struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_COMP128v3); comp128v3(aud->u.gsm.ki, _rand, vec->sres, vec->kc); vec->auth_types = OSMO_AUTH_TYPE_GSM; diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c index 36fbb06..84780c6 100644 --- a/src/gsm/auth_milenage.c +++ b/src/gsm/auth_milenage.c @@ -55,6 +55,8 @@ uint64_t seq_1; int rc; + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE); + opc = gen_opc_if_needed(aud, gen_opc); if (!opc) return -1; @@ -150,6 +152,8 @@ const uint8_t *opc; int rc; + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE); + opc = gen_opc_if_needed(aud, gen_opc); rc = milenage_auts(opc, aud->u.umts.k, rand_auts, auts, sqn_out); diff --git a/src/gsm/auth_xor.c b/src/gsm/auth_xor.c index 3552568..c94b02f 100644 --- a/src/gsm/auth_xor.c +++ b/src/gsm/auth_xor.c @@ -50,6 +50,8 @@ uint8_t ak[6], xmac[8]; int i; + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_XOR_3G); + /* Step 1: xdout = (ki or k) ^ rand */ if (aud->type == OSMO_AUTH_TYPE_GSM) xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout)); @@ -134,6 +136,8 @@ uint8_t ak[6], xmac[8]; uint8_t sqnms[6]; + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_XOR_3G); + /* Step 1: xdout = (ki or k) ^ rand */ if (aud->type == OSMO_AUTH_TYPE_GSM) xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout)); diff --git a/src/gsm/auth_xor_2g.c b/src/gsm/auth_xor_2g.c index 1a96b4a..367c79d 100644 --- a/src/gsm/auth_xor_2g.c +++ b/src/gsm/auth_xor_2g.c @@ -48,6 +48,8 @@ { uint8_t res1[16]; + OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_XOR_2G); + if (aud->type != OSMO_AUTH_TYPE_GSM) return -ENOTSUP; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33088 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I22b504b6cffb4999b2f14772fffcb2f6f02c198c Gerrit-Change-Number: 33088 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: libosmogsm: Support authentication with 256-bit K and/or OP/OPc
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33087 ) Change subject: libosmogsm: Support authentication with 256-bit K and/or OP/OPc ...................................................................... libosmogsm: Support authentication with 256-bit K and/or OP/OPc 3GPP TS 33.102 Section 6.3.7 states that K can be 128 or 256 bits, while our 'struct osmo_sub_auth_data' had a fixed-size 128bit field. This means we cannot use our auth_core for algorithms with larger key sizes, such as TUAK. Let's introduce osmo_sub_auth_data2 for larger (and variable) sized K and OP[c]. K and OP[c] can even have different sizes in TUAK, where OP[c] is always 256bit, but K can be 128 or 256 bits. So we need separate length fields for K and OP[c]. I'm adding backwards-compatibility API wrappers, so old applications just continue to work as they always did. However, I'm not adding compatibility wrappers for the plug-in API that can be used to register additional authentication implementations at runtime. We don't know of any user of that API outside of libosmocore, so the function signatures of the 'struct osmo_auth_impl' are modified in an incompatible way. Change-Id: Ie775fedba4a3fa12314c0f7c8a369662ef6a40df --- M TODO-RELEASE M include/osmocom/crypt/auth.h M src/gsm/auth_comp128v1.c M src/gsm/auth_comp128v23.c M src/gsm/auth_core.c M src/gsm/auth_milenage.c M src/gsm/auth_xor.c M src/gsm/auth_xor_2g.c M src/gsm/libosmogsm.map 9 files changed, 189 insertions(+), 27 deletions(-) Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index ebda4c5..d082ee3 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -13,3 +13,5 @@ libosmocore ADD new API osmo_io_*() libosmocoding ADD new gsm0503_tch_hr_decode2() public API, previous API gsm0503_tch_hr_decode() marked as deprecated +libosmogsm ADD new osmo_sub_auth_data2 / osmo_auth_gen_vec2 / osmo_auth_gen_vec_auts2 +libosmogsm MODIFY osmo_auth_impl callback function signature change. No known external users diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index d872f64..2833ed3 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -40,6 +40,30 @@ #define OSMO_AUTH_ALG_XOR OSMO_AUTH_ALG_XOR_3G /*! permanent (secret) subscriber auth data */ +struct osmo_sub_auth_data2 { + enum osmo_sub_auth_type type; + enum osmo_auth_algo algo; + union { + struct { + /* See 3GPP TS 33.102 Section 9.3.7 Length of authentication parameters */ + uint8_t opc[32]; /*!< operator invariant value */ + uint8_t opc_len; /*!< OPc length (in bytes): 16 or 32 */ + uint8_t k[32]; /*!< secret key of the subscriber */ + uint8_t k_len; /*!< K length (in bytes): 16 or 32 */ + 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) ? */ + unsigned int ind_bitlen; /*!< nr of bits not in SEQ, only SQN */ + unsigned int ind; /*!< which IND slot to use an SQN from */ + uint64_t sqn_ms; /*!< sqn from AUTS (output value only) */ + } umts; + struct { + uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< secret key */ + } gsm; + } u; +}; + +/* deprecated older structure without support for 32-byte K/OP[c] */ struct osmo_sub_auth_data { enum osmo_sub_auth_type type; enum osmo_auth_algo algo; @@ -58,7 +82,7 @@ uint8_t ki[OSMO_A5_MAX_KEY_LEN_BYTES]; /*!< secret key */ } gsm; } u; -}; +} OSMO_DEPRECATED_OUTSIDE("Use osmo_sub_auth_data2 instead"); /* data structure describing a computed auth vector, generated by AuC */ struct osmo_auth_vector { @@ -67,7 +91,7 @@ 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 res_len; /*!< length (in bytes) of res: 8..16 bytes */ uint8_t kc[8]; /*!< Kc for GSM encryption (A5) */ uint8_t sres[4]; /*!< authentication result for GSM */ uint32_t auth_types; /*!< bitmask of OSMO_AUTH_TYPE_* */ @@ -82,22 +106,32 @@ /*! callback for generate authentication vectors */ int (*gen_vec)(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand); - /* callback for generationg auth vectors + re-sync */ + /*! callback for generating auth vectors + re-sync */ int (*gen_vec_auts)(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand); }; int osmo_auth_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, const uint8_t *_rand); + struct osmo_sub_auth_data *aud, const uint8_t *_rand) + OSMO_DEPRECATED_OUTSIDE("Use osmo_auth_gen_vec2 instead"); + +int osmo_auth_gen_vec2(struct osmo_auth_vector *vec, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand); int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *auts, const uint8_t *rand_auts, + const uint8_t *_rand) + OSMO_DEPRECATED_OUTSIDE("Use osmo_auth_gen_vec_auts2 instead"); + +int osmo_auth_gen_vec_auts2(struct osmo_auth_vector *vec, + struct osmo_sub_auth_data2 *aud, + const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand); int osmo_auth_register(struct osmo_auth_impl *impl); diff --git a/src/gsm/auth_comp128v1.c b/src/gsm/auth_comp128v1.c index ba3cf60..a314dc2 100644 --- a/src/gsm/auth_comp128v1.c +++ b/src/gsm/auth_comp128v1.c @@ -27,7 +27,7 @@ */ static int c128v1_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc); diff --git a/src/gsm/auth_comp128v23.c b/src/gsm/auth_comp128v23.c index 91fb259..697858a 100644 --- a/src/gsm/auth_comp128v23.c +++ b/src/gsm/auth_comp128v23.c @@ -29,7 +29,7 @@ */ static int c128v2_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc); @@ -46,7 +46,7 @@ }; static int c128v3_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { comp128v3(aud->u.gsm.ki, _rand, vec->sres, vec->kc); diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index ce6ba7d..421ecee 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -1,4 +1,4 @@ -/* (C) 2010-2012 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2010-2023 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -36,6 +36,35 @@ static LLIST_HEAD(osmo_auths); +/* generate auth_data2 from auth_data (for legacy API/ABI compatibility */ +static int auth_data2auth_data2(struct osmo_sub_auth_data2 *out, const struct osmo_sub_auth_data *in) +{ + out->type = in->type; + out->algo = in->algo; + switch (in->type) { + case OSMO_AUTH_TYPE_NONE: + return 0; + case OSMO_AUTH_TYPE_GSM: + memcpy(out->u.gsm.ki, in->u.gsm.ki, sizeof(out->u.gsm.ki)); + break; + case OSMO_AUTH_TYPE_UMTS: + memcpy(out->u.umts.opc, in->u.umts.opc, sizeof(in->u.umts.opc)); + out->u.umts.opc_len = sizeof(in->u.umts.opc); + memcpy(out->u.umts.k, in->u.umts.k, sizeof(in->u.umts.k)); + out->u.umts.k_len = sizeof(in->u.umts.k); + memcpy(out->u.umts.amf, in->u.umts.amf, sizeof(out->u.umts.amf)); + out->u.umts.sqn = in->u.umts.sqn; + out->u.umts.opc_is_op = in->u.umts.opc_is_op; + out->u.umts.ind_bitlen = in->u.umts.ind_bitlen; + out->u.umts.ind = in->u.umts.ind; + out->u.umts.sqn_ms = in->u.umts.sqn_ms; + break; + default: + return -EINVAL; + } + return 0; +} + static struct osmo_auth_impl *selected_auths[_OSMO_AUTH_ALG_NUM]; /*! Register an authentication algorithm implementation with the core @@ -149,9 +178,9 @@ * by the AUC via HLR and VLR to the MSC which will then be able to * invoke authentication with the MS */ -int osmo_auth_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, - const uint8_t *_rand) +int osmo_auth_gen_vec2(struct osmo_auth_vector *vec, + struct osmo_sub_auth_data2 *aud, + const uint8_t *_rand) { struct osmo_auth_impl *impl = selected_auths[aud->algo]; int rc; @@ -168,6 +197,71 @@ return 0; } +/*! Generate authentication vector + * \param[out] vec Generated authentication vector + * \param[in] aud Subscriber-specific key material + * \param[in] _rand Random challenge to be used + * \returns 0 on success, negative error on failure + * + * This function performs the core cryptographic function of the AUC, + * computing authentication triples/quintuples based on the permanent + * subscriber data and a random value. The result is what is forwarded + * by the AUC via HLR and VLR to the MSC which will then be able to + * invoke authentication with the MS + */ +int osmo_auth_gen_vec(struct osmo_auth_vector *vec, + struct osmo_sub_auth_data *aud, + const uint8_t *_rand) +{ + struct osmo_sub_auth_data2 aud2; + int rc; + + rc = auth_data2auth_data2(&aud2, aud); + if (rc < 0) + return rc; + + rc = osmo_auth_gen_vec2(vec, &aud2, _rand); + if (aud->type == OSMO_AUTH_TYPE_UMTS) + aud->u.umts.sqn = aud2.u.umts.sqn; + + return rc; +} + +/*! Generate authentication vector and re-sync sequence + * \param[out] vec Generated authentication vector + * \param[in] aud Subscriber-specific key material + * \param[in] auts AUTS value sent by the SIM/MS + * \param[in] rand_auts RAND value sent by the SIM/MS + * \param[in] _rand Random challenge to be used to generate vector + * \returns 0 on success, negative error on failure + * + * This function performs a special variant of the core cryptographic + * function of the AUC: computing authentication triples/quintuples + * based on the permanent subscriber data, a random value as well as the + * AUTS and RAND values returned by the SIM/MS. This special variant is + * needed if the sequence numbers between MS and AUC have for some + * reason become different. + */ +int osmo_auth_gen_vec_auts2(struct osmo_auth_vector *vec, + struct osmo_sub_auth_data2 *aud, + const uint8_t *auts, const uint8_t *rand_auts, + const uint8_t *_rand) +{ + struct osmo_auth_impl *impl = selected_auths[aud->algo]; + int rc; + + if (!impl || !impl->gen_vec_auts) + return -ENOENT; + + rc = impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); + if (rc < 0) + return rc; + + memcpy(vec->rand, _rand, sizeof(vec->rand)); + + return 0; +} + /*! Generate authentication vector and re-sync sequence * \param[out] vec Generated authentication vector * \param[in] aud Subscriber-specific key material @@ -188,19 +282,20 @@ const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand) { - struct osmo_auth_impl *impl = selected_auths[aud->algo]; + struct osmo_sub_auth_data2 aud2; int rc; - if (!impl || !impl->gen_vec_auts) - return -ENOENT; - - rc = impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand); + rc = auth_data2auth_data2(&aud2, aud); if (rc < 0) return rc; - memcpy(vec->rand, _rand, sizeof(vec->rand)); + rc = osmo_auth_gen_vec_auts2(vec, &aud2, auts, rand_auts, _rand); + if (aud->type == OSMO_AUTH_TYPE_UMTS) { + aud->u.umts.sqn = aud2.u.umts.sqn; + aud->u.umts.sqn_ms = aud2.u.umts.sqn_ms; + } - return 0; + return rc; } static const struct value_string auth_alg_vals[] = { diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c index 4a430b3..36fbb06 100644 --- a/src/gsm/auth_milenage.c +++ b/src/gsm/auth_milenage.c @@ -28,7 +28,7 @@ * @{ */ -static const uint8_t *gen_opc_if_needed(const struct osmo_sub_auth_data *aud, uint8_t *gen_opc) +static const uint8_t *gen_opc_if_needed(const struct osmo_sub_auth_data2 *aud, uint8_t *gen_opc) { int rc; @@ -43,7 +43,7 @@ } static int milenage_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { size_t res_len = sizeof(vec->res); @@ -141,7 +141,7 @@ } static int milenage_gen_vec_auts(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand) { diff --git a/src/gsm/auth_xor.c b/src/gsm/auth_xor.c index 81076bd..3552568 100644 --- a/src/gsm/auth_xor.c +++ b/src/gsm/auth_xor.c @@ -43,7 +43,7 @@ /* 3GPP TS 34.108, section 8.1.2.1 */ static int xor_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *_rand) { uint8_t xdout[16], cdout[8]; @@ -125,7 +125,7 @@ /* 3GPP TS 34.108, section 8.1.2.2 */ static int xor_gen_vec_auts(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, + struct osmo_sub_auth_data2 *aud, const uint8_t *auts, const uint8_t *rand_auts, const uint8_t *_rand) diff --git a/src/gsm/auth_xor_2g.c b/src/gsm/auth_xor_2g.c index 9efe5cc..1a96b4a 100644 --- a/src/gsm/auth_xor_2g.c +++ b/src/gsm/auth_xor_2g.c @@ -43,8 +43,8 @@ /* GSM XOR-2G algorithm as specified in Annex 4 (A.4.1.2) of 3GPP TS 51.010-1. */ static int xor2g_gen_vec(struct osmo_auth_vector *vec, - struct osmo_sub_auth_data *aud, - const uint8_t *_rand) + struct osmo_sub_auth_data2 *aud, + const uint8_t *_rand) { uint8_t res1[16]; diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 40f3e80..e03e014 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -578,7 +578,9 @@ osmo_auth_alg_name; osmo_auth_alg_parse; osmo_auth_gen_vec; +osmo_auth_gen_vec2; osmo_auth_gen_vec_auts; +osmo_auth_gen_vec_auts2; osmo_auth_3g_from_2g; osmo_auth_load; osmo_auth_register; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33087 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ie775fedba4a3fa12314c0f7c8a369662ef6a40df Gerrit-Change-Number: 33087 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: libosmogsm: Factor out the C2 derivation function
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33092 ) Change subject: libosmogsm: Factor out the C2 derivation function ...................................................................... libosmogsm: Factor out the C2 derivation function 3GPP specifies the C2 derivation function (generating GSM SRES from UMTS XRES) independent of the MILENAGE algorithm. So instead of open-coding it in milenage.c:gsm_milenage(), let's create a separate public function osmo_auth_c2() similar to the already-existing osmo_auth_c3() function. gsm_milenage() can then simply use that function. Change-Id: I0e7cd55f5578f891cb6cc1b0442920ba5beddae4 --- M TODO-RELEASE M include/osmocom/crypt/auth.h M src/gsm/auth_core.c M src/gsm/libosmogsm.map M src/gsm/milenage/milenage.c 5 files changed, 49 insertions(+), 7 deletions(-) Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index d082ee3..b239efa 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -15,3 +15,4 @@ gsm0503_tch_hr_decode() marked as deprecated libosmogsm ADD new osmo_sub_auth_data2 / osmo_auth_gen_vec2 / osmo_auth_gen_vec_auts2 libosmogsm MODIFY osmo_auth_impl callback function signature change. No known external users +libosmogsm ADD osmo_auth_c2 diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index dfec885..0e9b502 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -144,5 +144,6 @@ enum osmo_auth_algo osmo_auth_alg_parse(const char *name); void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[]); +void osmo_auth_c2(uint8_t sres[4], const uint8_t *res, size_t res_len, uint8_t sres_deriv_func); /* @} */ diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index 2b6f35a..ad5967d 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -363,4 +363,33 @@ kc[i] = ck[i] ^ ck[i + 8] ^ ik[i] ^ ik[i + 8]; } +/*! Derive GSM SRES from UMTS [X]RES (auth function c2 from 3GPP TS 33.103 Section 6.8.1.2 + * \param[out] sres GSM SRES value, 4 byte target buffer + * \param[in] res UMTS XRES, 4..16 bytes input buffer + * \param[in] res_len length of res parameter (in bytes) + * \param[in] sres_deriv_func SRES derivation function (1 or 2, see 3GPP TS 55.205 Section 4 + */ +void osmo_auth_c2(uint8_t sres[4], const uint8_t *res, size_t res_len, uint8_t sres_deriv_func) +{ + uint8_t xres[16]; + + OSMO_ASSERT(sres_deriv_func == 1 || sres_deriv_func == 2); + OSMO_ASSERT(res_len <= sizeof(xres)); + + memcpy(xres, res, res_len); + + /* zero-pad the end, if XRES is < 16 bytes */ + if (res_len < sizeof(xres)) + memset(xres+res_len, 0, sizeof(xres)-res_len); + + if (sres_deriv_func == 1) { + /* SRES derivation function #1 */ + for (unsigned int i = 0; i < 4; i++) + sres[i] = xres[i] ^ xres[4+i] ^ xres[8+i] ^ xres[12+i]; + } else { + /* SRES derivation function #2 */ + memcpy(sres, xres, 4); + } +} + /*! @} */ diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index e03e014..0e45dc1 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -585,6 +585,7 @@ osmo_auth_load; osmo_auth_register; osmo_auth_supported; +osmo_auth_c2; osmo_auth_c3; osmo_sub_auth_type_names; diff --git a/src/gsm/milenage/milenage.c b/src/gsm/milenage/milenage.c index 3c14ab9..ba9ab33 100644 --- a/src/gsm/milenage/milenage.c +++ b/src/gsm/milenage/milenage.c @@ -244,19 +244,13 @@ int gsm_milenage(const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, u8 *kc) { u8 res[8], ck[16], ik[16]; - int i; if (milenage_f2345(opc, k, _rand, res, ck, ik, NULL, NULL)) return -1; osmo_auth_c3(kc, ck, ik); + osmo_auth_c2(sres, res, sizeof(res), 1); -#ifdef GSM_MILENAGE_ALT_SRES - os_memcpy(sres, res, 4); -#else /* GSM_MILENAGE_ALT_SRES */ - for (i = 0; i < 4; i++) - sres[i] = res[i] ^ res[i + 4]; -#endif /* GSM_MILENAGE_ALT_SRES */ return 0; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33092 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I0e7cd55f5578f891cb6cc1b0442920ba5beddae4 Gerrit-Change-Number: 33092 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: osmo-auc-gen: Convert over to osmo_auth_gen_vec*2 API
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33090 ) ( 4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: osmo-auc-gen: Convert over to osmo_auth_gen_vec*2 API ...................................................................... osmo-auc-gen: Convert over to osmo_auth_gen_vec*2 API This allows the tool to support K/OPc lengths != 128 bit. Let's add more length checks of command-line arguments while we're adding those checks for K/OPc. Change-Id: Iffed02ec0fc9c9a996da6f218d67314e381cbb29 --- M utils/osmo-auc-gen.c 1 file changed, 47 insertions(+), 4 deletions(-) Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index e3e1b43..86abeda 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -1,7 +1,7 @@ /*! \file osmo-auc-gen.c * GSM/GPRS/3G authentication testing tool. */ /* - * (C) 2010-2021 by Harald Welte <laforge(a)gnumonks.org> + * (C) 2010-2023 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -80,7 +80,7 @@ } } -static struct osmo_sub_auth_data test_aud = { +static struct osmo_sub_auth_data2 test_aud = { .type = OSMO_AUTH_TYPE_NONE, .algo = OSMO_AUTH_ALG_NONE, }; @@ -174,10 +174,21 @@ case OSMO_AUTH_TYPE_GSM: rc = osmo_hexparse(optarg, test_aud.u.gsm.ki, sizeof(test_aud.u.gsm.ki)); + if (rc != sizeof(test_aud.u.gsm.ki)) { + fprintf(stderr, "Invalid Ki length %d\n", rc); + exit(2); + } break; case OSMO_AUTH_TYPE_UMTS: rc = osmo_hexparse(optarg, test_aud.u.umts.k, sizeof(test_aud.u.umts.k)); + /* 3GPP TS 33.102 6.3.7: "The authentication key (K) shall have a length of + * 128 bits or 256 bits." */ + if (rc != 16 && rc != 32) { + fprintf(stderr, "Invalid K length %d\n", rc); + exit(2); + } + test_aud.u.umts.k_len = rc; break; default: fprintf(stderr, "please specify 2g/3g first!\n"); @@ -190,6 +201,11 @@ } rc = osmo_hexparse(optarg, test_aud.u.umts.opc, sizeof(test_aud.u.umts.opc)); + if (rc != 16 && rc != 32) { + fprintf(stderr, "Invalid OPC length %d\n", rc); + exit(2); + } + test_aud.u.umts.opc_len = rc; test_aud.u.umts.opc_is_op = 0; break; case 'O': @@ -199,6 +215,11 @@ } rc = osmo_hexparse(optarg, test_aud.u.umts.opc, sizeof(test_aud.u.umts.opc)); + if (rc != 16 && rc != 32) { + fprintf(stderr, "Invalid OP length %d\n", rc); + exit(2); + } + test_aud.u.umts.opc_len = rc; test_aud.u.umts.opc_is_op = 1; break; case 'A': @@ -216,6 +237,10 @@ } rc = osmo_hexparse(optarg, test_aud.u.umts.amf, sizeof(test_aud.u.umts.amf)); + if (rc != 2) { + fprintf(stderr, "Invalid AMF length %d\n", rc); + exit(2); + } break; case 's': if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { @@ -242,6 +267,10 @@ break; case 'r': rc = osmo_hexparse(optarg, _rand, sizeof(_rand)); + if (rc != sizeof(_rand)) { + fprintf(stderr, "Invalid RAND length %d\n", rc); + exit(2); + } rand_is_set = 1; break; case 'I': @@ -316,9 +345,9 @@ } if (!auts_is_set) - rc = osmo_auth_gen_vec(vec, &test_aud, _rand); + rc = osmo_auth_gen_vec2(vec, &test_aud, _rand); else - rc = osmo_auth_gen_vec_auts(vec, &test_aud, _auts, _rand, _rand); + rc = osmo_auth_gen_vec_auts2(vec, &test_aud, _auts, _rand, _rand); if (rc < 0) { if (!auts_is_set) fprintf(stderr, "error generating auth vector\n"); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33090 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iffed02ec0fc9c9a996da6f218d67314e381cbb29 Gerrit-Change-Number: 33090 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmocore[master]: libosmogsm: Avoid executing MILENAGE crypto twice (for UMTS and GSM)
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33093 ) ( 4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: libosmogsm: Avoid executing MILENAGE crypto twice (for UMTS and GSM) ...................................................................... libosmogsm: Avoid executing MILENAGE crypto twice (for UMTS and GSM) So far, we were executing the cryptographic functions to generate MILENAGE authentication tuples *twice* for every call to milenage_gen_vec: Once for UMTS, and another time for GSM. Let's do this properly: Execute once for UMTS, an then call the computationally much simpler C2 and C3 functions to compute the SRES and Kc values from RES, and CK+IK, respectively. Change-Id: I20ecf6d32974c1ba196bf56deba5b2cd971eaffb --- M src/gsm/auth_milenage.c 1 file changed, 19 insertions(+), 4 deletions(-) Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c index a439b15..2bd05a6 100644 --- a/src/gsm/auth_milenage.c +++ b/src/gsm/auth_milenage.c @@ -54,7 +54,6 @@ uint8_t sqn[6]; uint64_t ind_mask; uint64_t seq_1; - int rc; OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE); @@ -138,9 +137,8 @@ sqn, _rand, vec->autn, vec->ik, vec->ck, vec->res, &res_len); - rc = gsm_milenage(opc, aud->u.umts.k, _rand, vec->sres, vec->kc); - if (rc < 0) - return rc; + osmo_auth_c3(vec->kc, vec->ck, vec->ik); + osmo_auth_c2(vec->sres, vec->res, vec->res_len, 1); vec->auth_types = OSMO_AUTH_TYPE_UMTS | OSMO_AUTH_TYPE_GSM; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33093 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I20ecf6d32974c1ba196bf56deba5b2cd971eaffb Gerrit-Change-Number: 33093 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: libosmogsm: Allow auth API caller to specify RES length
by laforge 02 Jun '23

02 Jun '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33091 ) Change subject: libosmogsm: Allow auth API caller to specify RES length ...................................................................... libosmogsm: Allow auth API caller to specify RES length There are 3G algorithms which support different lengths of RES values (4, 8, 16 byte). For MILENAGE, we never really had to bother, as the 4-byte RES is simply the first 4 bytes of the 8-byte RES. However, for TUAK, the expected RES length is an input parameter to the Keccak crypto functions, so the result of all parameters (including CK, IK, ...) will be completely different for RES length 4 than RES length 8. So let's permit the caller of the osmocom auth API to specify the requested RES length via the osmo_auth_vector.res_len parameter. For backwards compatibility of callers of the old osmo_auth_gen_vec/ osmo_auth_gen_vec_auts API: Always force the res_len to 8 in this case, which was the hard-coded length before this patch. Change-Id: Ic662843fbe8b5c58e4af39ea630ad5ac13fd6bef --- M include/osmocom/crypt/auth.h M src/gsm/auth_core.c M src/gsm/auth_milenage.c M tests/osmo-auc-gen/osmo-auc-gen_test.ok M utils/osmo-auc-gen.c 5 files changed, 87 insertions(+), 28 deletions(-) Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index 2833ed3..dfec885 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -91,7 +91,7 @@ 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: 8..16 bytes */ + uint8_t res_len; /*!< length (in bytes) of res: 4..16 bytes */ uint8_t kc[8]; /*!< Kc for GSM encryption (A5) */ 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 421ecee..2b6f35a 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -167,7 +167,7 @@ } /*! Generate authentication vector - * \param[out] vec Generated authentication vector + * \param[out] vec Generated authentication vector. See below! * \param[in] aud Subscriber-specific key material * \param[in] _rand Random challenge to be used * \returns 0 on success, negative error on failure @@ -176,7 +176,12 @@ * computing authentication triples/quintuples based on the permanent * subscriber data and a random value. The result is what is forwarded * by the AUC via HLR and VLR to the MSC which will then be able to - * invoke authentication with the MS + * invoke authentication with the MS. + * + * Contrary to the older osmo_auth_gen_vec(), the caller must specify + * the desired RES length in the vec->res_len field prior to calling + * this function. The requested length must match the capabilities of + * the chosen algorithm (e.g. 4/8 for MILENAGE). */ int osmo_auth_gen_vec2(struct osmo_auth_vector *vec, struct osmo_sub_auth_data2 *aud, @@ -216,6 +221,12 @@ struct osmo_sub_auth_data2 aud2; int rc; + if (aud->type == OSMO_AUTH_TYPE_UMTS) { + /* old API callers are not expected to initialize this struct field, + * and always expect an 8-byte RES value */ + vec->res_len = 8; + } + rc = auth_data2auth_data2(&aud2, aud); if (rc < 0) return rc; @@ -228,7 +239,7 @@ } /*! Generate authentication vector and re-sync sequence - * \param[out] vec Generated authentication vector + * \param[out] vec Generated authentication vector. See below! * \param[in] aud Subscriber-specific key material * \param[in] auts AUTS value sent by the SIM/MS * \param[in] rand_auts RAND value sent by the SIM/MS @@ -241,6 +252,11 @@ * AUTS and RAND values returned by the SIM/MS. This special variant is * needed if the sequence numbers between MS and AUC have for some * reason become different. + * + * Contrary to the older osmo_auth_gen_vec_auts(), the caller must specify + * the desired RES length in the vec->res_len field prior to calling + * this function. The requested length must match the capabilities of + * the chosen algorithm (e.g. 4/8 for MILENAGE). */ int osmo_auth_gen_vec_auts2(struct osmo_auth_vector *vec, struct osmo_sub_auth_data2 *aud, @@ -285,6 +301,12 @@ struct osmo_sub_auth_data2 aud2; int rc; + if (aud->type == OSMO_AUTH_TYPE_UMTS) { + /* old API callers are not expected to initialize this struct field, + * and always expect an 8-byte RES value */ + vec->res_len = 8; + } + rc = auth_data2auth_data2(&aud2, aud); if (rc < 0) return rc; diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c index 9e94293..a439b15 100644 --- a/src/gsm/auth_milenage.c +++ b/src/gsm/auth_milenage.c @@ -62,6 +62,8 @@ return -EINVAL; if (aud->u.umts.opc_len != 16) return -EINVAL; + if (vec->res_len != 4 && vec->res_len != 8) + return -EINVAL; opc = gen_opc_if_needed(aud, gen_opc); if (!opc) @@ -135,7 +137,7 @@ milenage_generate(opc, aud->u.umts.amf, aud->u.umts.k, sqn, _rand, vec->autn, vec->ik, vec->ck, vec->res, &res_len); - vec->res_len = res_len; + rc = gsm_milenage(opc, aud->u.umts.k, _rand, vec->sres, vec->kc); if (rc < 0) return rc; diff --git a/tests/osmo-auc-gen/osmo-auc-gen_test.ok b/tests/osmo-auc-gen/osmo-auc-gen_test.ok index 3c41f41..2da0b02 100644 --- a/tests/osmo-auc-gen/osmo-auc-gen_test.ok +++ b/tests/osmo-auc-gen/osmo-auc-gen_test.ok @@ -1,7 +1,7 @@ > osmo-auc-gen -3 -a milenage -r 6a61050765caa32c90371370e5d6dc2d -k 1dc4f974325cce611e54f516dc1fec56 -o 2a48162ff3edca4adf0b7b5e527d6c16 -s 0 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 6a61050765caa32c90371370e5d6dc2d @@ -18,7 +18,7 @@ > osmo-auc-gen -3 -a milenage -r 6a61050765caa32c90371370e5d6dc2d -k 1dc4f974325cce611e54f516dc1fec56 -o 2a48162ff3edca4adf0b7b5e527d6c16 -s 1 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 6a61050765caa32c90371370e5d6dc2d @@ -35,7 +35,7 @@ > osmo-auc-gen -3 -a milenage -r 6a61050765caa32c90371370e5d6dc2d -k 1dc4f974325cce611e54f516dc1fec56 -o 2a48162ff3edca4adf0b7b5e527d6c16 -s 23 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 6a61050765caa32c90371370e5d6dc2d @@ -52,7 +52,7 @@ > osmo-auc-gen -3 -a milenage -r 1dc4f974325cce611e54f516dc1fec56 -k 2a48162ff3edca4adf0b7b5e527d6c16 -o 6a61050765caa32c90371370e5d6dc2d -s 42 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 1dc4f974325cce611e54f516dc1fec56 @@ -69,7 +69,7 @@ > osmo-auc-gen -3 -a milenage -r 2a48162ff3edca4adf0b7b5e527d6c16 -k 6a61050765caa32c90371370e5d6dc2d -o 1dc4f974325cce611e54f516dc1fec56 -s 99 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 2a48162ff3edca4adf0b7b5e527d6c16 @@ -86,7 +86,7 @@ > osmo-auc-gen -3 -a milenage -r 6a61050765caa32c90371370e5d6dc2d -k 2a48162ff3edca4adf0b7b5e527d6c16 -o 1dc4f974325cce611e54f516dc1fec56 -s 281474976710655 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 6a61050765caa32c90371370e5d6dc2d @@ -103,7 +103,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -121,7 +121,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 5 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -139,7 +139,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 23 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -157,7 +157,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 31 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -175,7 +175,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 0 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -193,7 +193,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 1 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -211,7 +211,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 1 --ind 1 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -229,7 +229,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 8 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -247,7 +247,7 @@ > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 8 --ind 1 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY RAND: 39fa2f4e3d523d8619a73b4f65c3e14d @@ -266,27 +266,27 @@ expecting error: > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind -1 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY expecting error: > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 32 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY expecting error: > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 42 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY expecting error: > osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind-len 0 --ind 1 -osmo-auc-gen (C) 2011-2012 by Harald Welte +osmo-auc-gen (C) 2011-2023 by Harald Welte This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c index 86abeda..50419a4 100644 --- a/utils/osmo-auc-gen.c +++ b/utils/osmo-auc-gen.c @@ -98,6 +98,7 @@ "-s --sqn\tSpecify SQN (only for 3G)\n" "-i --ind\tSpecify IND slot for new SQN after AUTS (only for 3G)\n" "-l --ind-len\tSpecify IND bit length (default=5) (only for 3G)\n" + "-L --res-len\tSpecify RES byte length (default=8) (only for 3G)\n" "-A --auts\tSpecify AUTS (only for 3G)\n" "-r --rand\tSpecify random value\n" "-I --ipsec\tOutput in triplets.dat format for strongswan\n"); @@ -123,10 +124,12 @@ int fmt_triplets_dat = 0; uint64_t ind_mask = 0; - printf("osmo-auc-gen (C) 2011-2012 by Harald Welte\n"); + printf("osmo-auc-gen (C) 2011-2023 by Harald Welte\n"); printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n"); memset(_auts, 0, sizeof(_auts)); + memset(vec, 0, sizeof(*vec)); + vec->res_len = 8; /* default */ while (1) { int c; @@ -141,6 +144,7 @@ { "sqn", 1, 0, 's' }, { "ind", 1, 0, 'i' }, { "ind-len", 1, 0, 'l' }, + { "res-len", 1, 0, 'L' }, { "rand", 1, 0, 'r' }, { "auts", 1, 0, 'A' }, { "help", 0, 0, 'h' }, @@ -149,7 +153,7 @@ rc = 0; - c = getopt_long(argc, argv, "23a:k:o:f:s:i:l:r:hO:A:I", long_options, + c = getopt_long(argc, argv, "23a:k:o:f:s:i:l:L:r:hO:A:I", long_options, &option_index); if (c == -1) @@ -265,6 +269,14 @@ } test_aud.u.umts.ind_bitlen = atoi(optarg); break; + case 'L': + rc = atoi(optarg); + if (rc != 4 && rc != 8 && rc != 16) { + fprintf(stderr, "Invalid RES length %u\n", rc); + exit(2); + } + vec->res_len = rc; + break; case 'r': rc = osmo_hexparse(optarg, _rand, sizeof(_rand)); if (rc != sizeof(_rand)) { @@ -313,8 +325,6 @@ exit(2); } - memset(vec, 0, sizeof(*vec)); - if (test_aud.type == OSMO_AUTH_TYPE_UMTS) { uint64_t seq_1 = 1LL << test_aud.u.umts.ind_bitlen; ind_mask = seq_1 - 1; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33091 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ic662843fbe8b5c58e4af39ea630ad5ac13fd6bef Gerrit-Change-Number: 33091 Gerrit-PatchSet: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmocore[master]: ASCI: Add Notification/NCH message to gsm_04_08.h
by laforge 02 Jun '23

02 Jun '23
Attention is currently required from: jolly. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33137 ) Change subject: ASCI: Add Notification/NCH message to gsm_04_08.h ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33137 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iff1555a2914ce0a1ead6ab883498adb2c33b135e Gerrit-Change-Number: 33137 Gerrit-PatchSet: 1 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Comment-Date: Fri, 02 Jun 2023 08:29:39 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: Add support for receiving Bter UI frames at lapdm.c
by laforge 02 Jun '23

02 Jun '23
Attention is currently required from: jolly, dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32934 ) Change subject: Add support for receiving Bter UI frames at lapdm.c ...................................................................... Patch Set 9: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32934 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If04115884743455c7bf2b2bc5f7e49e74b6ffb60 Gerrit-Change-Number: 32934 Gerrit-PatchSet: 9 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 02 Jun 2023 08:29:20 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • ...
  • 248
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.