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

May 2023

  • 1 participants
  • 2583 discussions
[M] Change in osmo-hlr[master]: Introduce support for XOR-2G algorithm
by laforge 30 May '23

30 May '23
Attention is currently required from: laforge. Hello Jenkins Builder, fixeria, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hlr/+/33096 to look at the new patch set (#3). Change subject: Introduce support for XOR-2G algorithm ...................................................................... Introduce support for XOR-2G algorithm So far we supported a "xor" algorithm in osmo-hlr, without specifying whether it's the XOR-3G or the (different) XOR-2G algorithm. Furthermore, it was buggy in the sense that it permitted the XOR[-3G] for 2G authentication data in the database. This patch * renames existing "xor" to "xor-3g" * disallows "xor-3g" usage with 2G authentication data * introduces support for XOR-2G as "xor-2g" in the VTY Change-Id: I039a1f84fda54a908a82fe621e7fd078cb85e4c6 Depends: libosmocore.git I0ee0565382c1e4515d44ff9b1752685c0a66ae39 --- M TODO-RELEASE M include/osmocom/hlr/hlr_vty.h M src/db_hlr.c M src/hlr_vty_subscr.c M tests/auc/auc_test.c M tests/db/db_test.c M tests/db/db_test.err M tests/db_upgrade/create_subscribers.vty M tests/db_upgrade/db_upgrade_test.ok M tests/db_upgrade/hlr_db_v0.sql M tests/test_subscriber.ctrl M tests/test_subscriber.vty M tests/test_subscriber_errors.ctrl 13 files changed, 64 insertions(+), 36 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/96/33096/3 -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/33096 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I039a1f84fda54a908a82fe621e7fd078cb85e4c6 Gerrit-Change-Number: 33096 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in osmo-hlr[master]: db: extend database schema to support 256bit K and/or OP[c] values
by laforge 30 May '23

30 May '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/33098 ) Change subject: db: extend database schema to support 256bit K and/or OP[c] values ...................................................................... db: extend database schema to support 256bit K and/or OP[c] values Other UMTS AKA algorithms than MILENAGE (notably TUAK) support K sizes of up to 256bit, or mandate a OP/OPc size of 256 bit. Let's extend our database schema to accommodate such larger sizes. Change-Id: Ibbde68484c904507a15c35cbfdf88cd47d0c7039 --- M sql/hlr.sql M src/ctrl.c M src/db.c M src/hlr_vty_subscr.c M tests/db_upgrade/db_upgrade_test.ok M tests/test_subscriber.vty 6 files changed, 95 insertions(+), 29 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/98/33098/1 diff --git a/sql/hlr.sql b/sql/hlr.sql index e855a6c..4c87f43 100644 --- a/sql/hlr.sql +++ b/sql/hlr.sql @@ -71,9 +71,9 @@ CREATE TABLE auc_3g ( subscriber_id INTEGER PRIMARY KEY, -- subscriber.id algo_id_3g INTEGER NOT NULL, -- enum osmo_auth_algo value - k VARCHAR(32) NOT NULL, -- hex string: subscriber's secret key (128bit) - op VARCHAR(32), -- hex string: operator's secret key (128bit) - opc VARCHAR(32), -- hex string: derived from OP and K (128bit) + k VARCHAR(64) NOT NULL, -- hex string: subscriber's secret key (128/256bit) + op VARCHAR(64), -- hex string: operator's secret key (128/256bit) + opc VARCHAR(64), -- hex string: derived from OP and K (128/256bit) sqn INTEGER NOT NULL DEFAULT 0, -- sequence number of key usage -- nr of index bits at lower SQN end ind_bitlen INTEGER NOT NULL DEFAULT 5 @@ -91,4 +91,4 @@ -- Set HLR database schema version number -- Note: This constant is currently duplicated in src/db.c and must be kept in sync! -PRAGMA user_version = 6; +PRAGMA user_version = 7; diff --git a/src/ctrl.c b/src/ctrl.c index f0f2ee6..e04195d 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -39,7 +39,7 @@ #define SEL_BY_ID SEL_BY "id-" extern bool auth_algo_parse(const char *alg_str, enum osmo_auth_algo *algo, - int *minlen, int *maxlen); + int *minlen, int *maxlen, int *minlen_opc, int *maxlen_opc); #define hexdump_buf(buf) osmo_hexdump_nospc((void*)buf, sizeof(buf)) @@ -550,7 +550,7 @@ } if (strcmp(tok, "none") == 0) { aud2g.algo = OSMO_AUTH_ALG_NONE; - } else if (!auth_algo_parse(tok, &aud2g.algo, &minlen, &maxlen)) { + } else if (!auth_algo_parse(tok, &aud2g.algo, &minlen, &maxlen, NULL, NULL)) { cmd->reply = "Unknown auth algorithm."; return CTRL_CMD_ERROR; } @@ -630,8 +630,8 @@ struct hlr *hlr = data; const char *by_selector = cmd->node; char *tmp = NULL, *tok, *saveptr; - int minlen = 0; - int maxlen = 0; + int minlen = 0, minlen_opc = 0; + int maxlen = 0, maxlen_opc = 0; struct sub_auth_data_str aud3g = { .type = OSMO_AUTH_TYPE_UMTS, .u.umts = { @@ -657,7 +657,7 @@ } if (strcmp(tok, "none") == 0) { aud3g.algo = OSMO_AUTH_ALG_NONE; - } else if (!auth_algo_parse(tok, &aud3g.algo, &minlen, &maxlen)) { + } else if (!auth_algo_parse(tok, &aud3g.algo, &minlen, &maxlen, &minlen_opc, &maxlen_opc)) { cmd->reply = "Unknown auth algorithm."; return CTRL_CMD_ERROR; } @@ -699,7 +699,7 @@ } aud3g.u.umts.opc = tok; - if (!osmo_is_hexstr(aud3g.u.umts.opc, MILENAGE_KEY_LEN * 2, MILENAGE_KEY_LEN * 2, true)) { + if (!osmo_is_hexstr(aud3g.u.umts.opc, minlen_opc * 2, maxlen_opc * 2, true)) { cmd->reply = talloc_asprintf(cmd, "Invalid OP/OPC."); return CTRL_CMD_ERROR; } diff --git a/src/db.c b/src/db.c index 23dcbbc..b186775 100644 --- a/src/db.c +++ b/src/db.c @@ -1,4 +1,4 @@ -/* (C) 2015 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2015-2023 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -28,7 +28,7 @@ #include "db_bootstrap.h" /* This constant is currently duplicated in sql/hlr.sql and must be kept in sync! */ -#define CURRENT_SCHEMA_VERSION 6 +#define CURRENT_SCHEMA_VERSION 7 #define SEL_COLUMNS \ "id," \ @@ -513,6 +513,46 @@ return rc; } +static int db_upgrade_v7(struct db_context *dbc) +{ + int rc; + /* SQLite doesn't allow us to change the column type in-place, so we + * first rename the old table, create a new table and then copy + * the data over before deleting the old table */ +#define CREATE_AUC_3G_V7 \ +"CREATE TABLE auc_3g (\n" \ +" subscriber_id INTEGER PRIMARY KEY, -- subscriber.id\n" \ +" algo_id_3g INTEGER NOT NULL, -- enum osmo_auth_algo value\n" \ +" k VARCHAR(64) NOT NULL, -- hex string: subscriber's secret key (128/256bit)\n" \ +" op VARCHAR(64), -- hex string: operator's secret key (128/256bit)\n" \ +" opc VARCHAR(64), -- hex string: derived from OP and K (128/256bit)\n" \ +" sqn INTEGER NOT NULL DEFAULT 0, -- sequence number of key usage\n" \ +" -- nr of index bits at lower SQN end\n" \ +" ind_bitlen INTEGER NOT NULL DEFAULT 5\n" \ +");" + const char *statements[] = { + "BEGIN TRANSACTION", + /* rename old table */ + "ALTER TABLE auc_3g RENAME TO old_auc_3g", + /* create new table */ + CREATE_AUC_3G_V7, + /* copy over old data */ + "INSERT INTO auc_3g SELECT subscriber_id, algo_id_3g, k, op, opc,sqn, ind_bitlen FROM old_auc_3g", + /* delete old table */ + "DROP TABLE old_auc_3g", + /* update user_version */ + "PRAGMA user_version = 7", + "COMMIT", + }; + + rc = db_run_statements(dbc, statements, ARRAY_SIZE(statements)); + if (rc != SQLITE_DONE) { + LOGP(DDB, LOGL_ERROR, "Unable to update HLR database schema to version 6\n"); + return rc; + } + return rc; +} + typedef int (*db_upgrade_func_t)(struct db_context *dbc); static db_upgrade_func_t db_upgrade_path[] = { db_upgrade_v1, @@ -521,6 +561,7 @@ db_upgrade_v4, db_upgrade_v5, db_upgrade_v6, + db_upgrade_v7, }; static int db_get_user_version(struct db_context *dbc) diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c index 191a87d..708359a 100644 --- a/src/hlr_vty_subscr.c +++ b/src/hlr_vty_subscr.c @@ -473,8 +473,15 @@ "Use Milenage algorithm\n" bool auth_algo_parse(const char *alg_str, enum osmo_auth_algo *algo, - int *minlen, int *maxlen) + int *minlen, int *maxlen, int *minlen_opc, int *maxlen_opc) { + /* Default: no OP[c]. True for all 2G algorithms, and 3G-XOR. Overridden + * below for real 3G AKA algorithms. */ + if (minlen_opc) + *minlen_opc = 0; + if (maxlen_opc) + *maxlen_opc = 0; + if (!strcasecmp(alg_str, "none")) { *algo = OSMO_AUTH_ALG_NONE; *minlen = *maxlen = 0; @@ -497,6 +504,10 @@ } else if (!strcasecmp(alg_str, "milenage")) { *algo = OSMO_AUTH_ALG_MILENAGE; *minlen = *maxlen = MILENAGE_KEY_LEN; + if (minlen_opc) + *minlen_opc = MILENAGE_KEY_LEN; + if (maxlen_opc) + *maxlen_opc = MILENAGE_KEY_LEN; } else return false; return true; @@ -552,7 +563,7 @@ .u.gsm.ki = ki, }; - if (!auth_algo_parse(alg_type, &aud2g.algo, &minlen, &maxlen)) { + if (!auth_algo_parse(alg_type, &aud2g.algo, &minlen, &maxlen, NULL, NULL)) { vty_out(vty, "%% Unknown auth algorithm: '%s'%s", alg_type, VTY_NEWLINE); return CMD_WARNING; } @@ -611,13 +622,13 @@ SUBSCR_UPDATE_HELP "Set UMTS authentication data (3G, and 2G with UMTS AKA)\n" AUTH_ALG_TYPES_3G_HELP - "Set Encryption Key K\n" "K as 32 hexadecimal characters\n" - "Set OP key\n" "Set OPC key\n" "OP or OPC as 32 hexadecimal characters\n" + "Set Encryption Key K\n" "K as 32/64 hexadecimal characters\n" + "Set OP key\n" "Set OPC key\n" "OP or OPC as 32/64 hexadecimal characters\n" "Set IND bit length\n" "IND bit length value (default: 5)\n") { struct hlr_subscriber subscr; - int minlen = 0; - int maxlen = 0; + int minlen = 0, minlen_opc = 0; + int maxlen = 0, maxlen_opc = 0; int rc; const char *id_type = argv[0]; const char *id = argv[1]; @@ -636,7 +647,7 @@ }, }; - if (!auth_algo_parse(alg_type, &aud3g.algo, &minlen, &maxlen)) { + if (!auth_algo_parse(alg_type, &aud3g.algo, &minlen, &maxlen, &minlen_opc, &maxlen_opc)) { vty_out(vty, "%% Unknown auth algorithm: '%s'%s", alg_type, VTY_NEWLINE); return CMD_WARNING; } @@ -644,8 +655,7 @@ if (!is_hexkey_valid(vty, "K", aud3g.u.umts.k, minlen, maxlen)) return CMD_WARNING; - if (!is_hexkey_valid(vty, opc_is_op ? "OP" : "OPC", aud3g.u.umts.opc, - MILENAGE_KEY_LEN, MILENAGE_KEY_LEN)) + if (!is_hexkey_valid(vty, opc_is_op ? "OP" : "OPC", aud3g.u.umts.opc, minlen_opc, maxlen_opc)) return CMD_WARNING; if (get_subscr_by_argv(vty, id_type, id, &subscr)) @@ -689,8 +699,8 @@ }, }; - if (!auth_algo_parse("xor-3g", &aud3g.algo, &minlen, &maxlen)) { - vty_out(vty, "%% Unknown auth algorithm: '%s'%s", "xor-3g", VTY_NEWLINE); + if (!auth_algo_parse("xor-3g", &aud3g.algo, &minlen, &maxlen, NULL, NULL)) { + vty_out(vty, "%% Unknown auth algorithm: '%s'%s", "xor", VTY_NEWLINE); return CMD_WARNING; } diff --git a/tests/db_upgrade/db_upgrade_test.ok b/tests/db_upgrade/db_upgrade_test.ok index ce5b17c..c719498 100644 --- a/tests/db_upgrade/db_upgrade_test.ok +++ b/tests/db_upgrade/db_upgrade_test.ok @@ -86,6 +86,7 @@ DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 4 DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 5 DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 6 +DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 7 DMAIN Cmdline option --db-check: Database was opened successfully, quitting. Resulting db: @@ -106,9 +107,9 @@ name|type|notnull|dflt_value|pk algo_id_3g|INTEGER|1||0 ind_bitlen|INTEGER|1|5|0 -k|VARCHAR(32)|1||0 -op|VARCHAR(32)|0||0 -opc|VARCHAR(32)|0||0 +k|VARCHAR(64)|1||0 +op|VARCHAR(64)|0||0 +opc|VARCHAR(64)|0||0 sqn|INTEGER|1|0|0 subscriber_id|INTEGER|0||1 @@ -179,5 +180,5 @@ rc = 0 DMAIN hlr starting DDB using database: <PATH>test.db -DDB Database <PATH>test.db' has HLR DB schema version 6 +DDB Database <PATH>test.db' has HLR DB schema version 7 DMAIN Cmdline option --db-check: Database was opened successfully, quitting. diff --git a/tests/test_subscriber.vty b/tests/test_subscriber.vty index dbe9327..9036fb8 100644 --- a/tests/test_subscriber.vty +++ b/tests/test_subscriber.vty @@ -275,14 +275,14 @@ k Set Encryption Key K OsmoHLR# subscriber imsi 123456789023000 update aud3g milenage k ? - K K as 32 hexadecimal characters + K K as 32/64 hexadecimal characters OsmoHLR# subscriber imsi 123456789023000 update aud3g milenage k Deaf0ff1ceD0d0DabbedD1ced1ceF00d ? op Set OP key opc Set OPC key OsmoHLR# subscriber imsi 123456789023000 update aud3g milenage k Deaf0ff1ceD0d0DabbedD1ced1ceF00d opc ? - OP_C OP or OPC as 32 hexadecimal characters + OP_C OP or OPC as 32/64 hexadecimal characters OsmoHLR# subscriber imsi 123456789023000 update aud3g milenage k Deaf0ff1ceD0d0DabbedD1ced1ceF00d opc CededEffacedAceFacedBadFadedBeef ? [ind-bitlen] Set IND bit length -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/33098 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Ibbde68484c904507a15c35cbfdf88cd47d0c7039 Gerrit-Change-Number: 33098 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in osmo-hlr[master]: Port to new libosmogsm 'struct osmo_sub_auth_data2'
by laforge 30 May '23

30 May '23
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/33097 ) Change subject: Port to new libosmogsm 'struct osmo_sub_auth_data2' ...................................................................... Port to new libosmogsm 'struct osmo_sub_auth_data2' libosmogsm has recently introdcued a 'struct osmo_sub_auth_data2' as successor to 'struct osmo_sub_auth_data', together with updated osmo_auth_gen_vec2/osmo_auth_gen_vec_auts2 API. The rationale of this new API is to enable * support for AKA algorithms which use K and/or OP[c] values of 256bit (instead of the classic 128bit) * support for RES length sizes of 4 and 16 bytes (instead of the classic 8 bytes) This commit just jumps over to the new API without adding any related functionality to osmo-hlr. The latter is left for subsequent commits. Change-Id: I3207c7bfb73e9ff5471e5c26b66639549e4d48a2 Depends: libosmocore.git Ie775fedba4a3fa12314c0f7c8a369662ef6a40df --- M TODO-RELEASE M include/osmocom/hlr/auc.h M include/osmocom/hlr/db.h M src/auc.c M src/ctrl.c M src/db_auc.c M src/db_hlr.c M src/hlr.c M src/hlr_vty_subscr.c M tests/auc/auc_test.c M tests/auc/gen_ts_55_205_test_sets/func_template.c M tests/db/db_test.c M tests/db/db_test.err 13 files changed, 194 insertions(+), 137 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/97/33097/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index 62fe828..4c445eb 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,4 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line -libosmogsm UPDATE_DEP_VER update libosmogsm version dependency after I0ee0565382c1e4515d44ff9b1752685c0a66ae39 is released +libosmogsm UPDATE_DEP_VER update libosmogsm version dependency after Ie775fedba4a3fa12314c0f7c8a369662ef6a40df is released diff --git a/include/osmocom/hlr/auc.h b/include/osmocom/hlr/auc.h index f5b6765..1d86398 100644 --- a/include/osmocom/hlr/auc.h +++ b/include/osmocom/hlr/auc.h @@ -3,6 +3,6 @@ #include <osmocom/crypt/auth.h> int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec, - struct osmo_sub_auth_data *aud2g, - struct osmo_sub_auth_data *aud3g, + struct osmo_sub_auth_data2 *aud2g, + struct osmo_sub_auth_data2 *aud3g, const uint8_t *rand_auts, const uint8_t *auts); diff --git a/include/osmocom/hlr/db.h b/include/osmocom/hlr/db.h index c43aa4f..588a96d 100644 --- a/include/osmocom/hlr/db.h +++ b/include/osmocom/hlr/db.h @@ -70,8 +70,8 @@ /* obtain the authentication data for a given imsi */ int db_get_auth_data(struct db_context *dbc, const char *imsi, - struct osmo_sub_auth_data *aud2g, - struct osmo_sub_auth_data *aud3g, + struct osmo_sub_auth_data2 *aud2g, + struct osmo_sub_auth_data2 *aud3g, int64_t *subscr_id); int db_update_sqn(struct db_context *dbc, int64_t id, @@ -121,7 +121,7 @@ * See https://sqlite.org/lang_datefunc.html, function datetime(). */ #define DB_LAST_LU_SEEN_FMT "%Y-%m-%d %H:%M:%S" -/* Like struct osmo_sub_auth_data, but the keys are in hexdump representation. +/* Like struct osmo_sub_auth_data2, but the keys are in hexdump representation. * This is useful because SQLite requires them in hexdump format, and callers * like the VTY and CTRL interface also have them available as hexdump to begin * with. In the binary format, a VTY command would first need to hexparse, diff --git a/src/auc.c b/src/auc.c index 28c441f..3ec0893 100644 --- a/src/auc.c +++ b/src/auc.c @@ -1,4 +1,4 @@ -/* (C) 2015 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2015-2023 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -32,8 +32,8 @@ /* compute given number of vectors using either aud2g or aud2g or a combination * of both. Handles re-synchronization if rand_auts and auts are set */ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec, - struct osmo_sub_auth_data *aud2g, - struct osmo_sub_auth_data *aud3g, + struct osmo_sub_auth_data2 *aud2g, + struct osmo_sub_auth_data2 *aud3g, const uint8_t *rand_auts, const uint8_t *auts) { unsigned int i; @@ -93,10 +93,10 @@ : "2G only", auts? ", with AUTS resync" : ""); if (aud3g) { - DBGP("3G: k = %s\n", hexb(aud3g->u.umts.k)); + DBGP("3G: k = %s\n", hex(aud3g->u.umts.k, aud3g->u.umts.k_len)); DBGP("3G: %s = %s\n", aud3g->u.umts.opc_is_op? "OP" : "opc", - hexb(aud3g->u.umts.opc)); + hex(aud3g->u.umts.opc, aud3g->u.umts.opc_len)); DBGP("3G: for sqn ind %u, previous sqn was %" PRIu64 "\n", aud3g->u.umts.ind, aud3g->u.umts.sqn); } @@ -115,6 +115,9 @@ if (aud3g) { /* 3G or 3G + 2G case */ + /* backwards-compatibiliy: We assume all RES are 8 bytes long */ + vec[i].res_len = 8; + /* Do AUTS only for the first vector or we would use * the same SQN for each following key. */ if ((i == 0) && auts) { @@ -123,10 +126,10 @@ DBGP("vector [%u]: resync: rand_auts = %s\n", i, hex(rand_auts, 16)); - rc = osmo_auth_gen_vec_auts(vec+i, aud3g, auts, + rc = osmo_auth_gen_vec_auts2(vec+i, aud3g, auts, rand_auts, rand); } else { - rc = osmo_auth_gen_vec(vec+i, aud3g, rand); + rc = osmo_auth_gen_vec2(vec+i, aud3g, rand); } if (rc < 0) { LOGP(DAUC, LOGL_ERROR, "Error in 3G vector " @@ -154,7 +157,7 @@ DBGP("vector [%u]: calculating 2G separately\n", i); - rc = osmo_auth_gen_vec(&vtmp, aud2g, rand); + rc = osmo_auth_gen_vec2(&vtmp, aud2g, rand); if (rc < 0) { LOGP(DAUC, LOGL_ERROR, "Error in 2G vector" "generation: [%u]: rc = %d\n", i, rc); @@ -165,7 +168,7 @@ vec[i].auth_types |= OSMO_AUTH_TYPE_GSM; } else { /* 2G only case */ - rc = osmo_auth_gen_vec(vec+i, aud2g, rand); + rc = osmo_auth_gen_vec2(vec+i, aud2g, rand); if (rc < 0) { LOGP(DAUC, LOGL_ERROR, "Error in 2G vector " "generation: [%u]: rc = %d\n", i, rc); diff --git a/src/ctrl.c b/src/ctrl.c index 4e4afeb..f0f2ee6 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -1,6 +1,6 @@ /* OsmoHLR Control Interface implementation */ -/* (C) 2017 sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> +/* (C) 2017-2023 sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> * All Rights Reserved * * Author: Max Suraev <msuraev(a)sysmocom.de> @@ -166,7 +166,7 @@ ); } -static void print_subscr_info_aud2g(struct ctrl_cmd *cmd, struct osmo_sub_auth_data *aud) +static void print_subscr_info_aud2g(struct ctrl_cmd *cmd, struct osmo_sub_auth_data2 *aud) { if (aud->algo == OSMO_AUTH_ALG_NONE) return; @@ -178,7 +178,7 @@ hexdump_buf(aud->u.gsm.ki)); } -static void print_subscr_info_aud3g(struct ctrl_cmd *cmd, struct osmo_sub_auth_data *aud) +static void print_subscr_info_aud3g(struct ctrl_cmd *cmd, struct osmo_sub_auth_data2 *aud) { if (aud->algo == OSMO_AUTH_ALG_NONE) return; @@ -187,7 +187,7 @@ "\naud3g.k\t%s" , osmo_auth_alg_name(aud->algo), - hexdump_buf(aud->u.umts.k)); + osmo_hexdump_nospc(aud->u.umts.k, aud->u.umts.k_len)); /* hexdump uses a static string buffer, hence only one hexdump per * printf(). */ ctrl_cmd_reply_printf(cmd, @@ -196,7 +196,7 @@ "\naud3g.sqn\t%" PRIu64 , aud->u.umts.opc_is_op? "op" : "opc", - hexdump_buf(aud->u.umts.opc), + osmo_hexdump_nospc(aud->u.umts.opc, aud->u.umts.opc_len), aud->u.umts.ind_bitlen, aud->u.umts.sqn); } @@ -291,8 +291,8 @@ static int get_subscr_info_aud(struct ctrl_cmd *cmd, void *data) { const char *imsi; - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct hlr *hlr = data; const char *by_selector = cmd->node; int rc; @@ -327,8 +327,8 @@ static int get_subscr_info_all(struct ctrl_cmd *cmd, void *data) { struct hlr_subscriber subscr; - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct hlr *hlr = data; const char *by_selector = cmd->node; int rc; @@ -492,8 +492,8 @@ struct hlr_subscriber subscr; struct hlr *hlr = data; const char *by_selector = cmd->node; - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g_unused; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g_unused; int rc; if (!get_subscriber(hlr->dbc, by_selector, &subscr, cmd)) @@ -592,8 +592,8 @@ struct hlr_subscriber subscr; struct hlr *hlr = data; const char *by_selector = cmd->node; - struct osmo_sub_auth_data aud2g_unused; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g_unused; + struct osmo_sub_auth_data2 aud3g; int rc; if (!get_subscriber(hlr->dbc, by_selector, &subscr, cmd)) @@ -618,9 +618,9 @@ } cmd->reply = talloc_asprintf(cmd, "%s,%s,%s,%s,%u", osmo_auth_alg_name(aud3g.algo), - osmo_hexdump_nospc_c(cmd, aud3g.u.umts.k, sizeof(aud3g.u.umts.k)), + osmo_hexdump_nospc_c(cmd, aud3g.u.umts.k, aud3g.u.umts.k_len), aud3g.u.umts.opc_is_op ? "OP" : "OPC", - osmo_hexdump_nospc_c(cmd, aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc)), + osmo_hexdump_nospc_c(cmd, aud3g.u.umts.opc, aud3g.u.umts.opc_len), aud3g.u.umts.ind_bitlen); return CTRL_CMD_REPLY; } diff --git a/src/db_auc.c b/src/db_auc.c index 11f282b..c72c127 100644 --- a/src/db_auc.c +++ b/src/db_auc.c @@ -1,4 +1,4 @@ -/* (C) 2015 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2015-2023 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -74,9 +74,9 @@ } /* hexparse a specific column of a sqlite prepared statement into dst (with length check) - * returns 0 for success, -EIO on error */ -static int hexparse_stmt(uint8_t *dst, size_t dst_len, sqlite3_stmt *stmt, int col, const char *col_name, - const char *imsi) + * returns byte length in case of success, -EIO on error */ +static int hexparse_stmt(uint8_t *dst, size_t dst_len_min, size_t dst_len_max, sqlite3_stmt *stmt, + int col, const char *col_name, const char *imsi) { const uint8_t *text; size_t col_len; @@ -84,9 +84,15 @@ /* Bytes are stored as hex strings in database, hence divide length by two */ col_len = sqlite3_column_bytes(stmt, col) / 2; - if (col_len != dst_len) { - LOGAUC(imsi, LOGL_ERROR, "Error reading %s, expected length %lu but has length %lu\n", col_name, - dst_len, col_len); + if (col_len < dst_len_min) { + LOGAUC(imsi, LOGL_ERROR, "Error reading %s, expected min length %lu but has length %lu\n", col_name, + dst_len_min, col_len); + return -EIO; + } + + if (col_len > dst_len_max) { + LOGAUC(imsi, LOGL_ERROR, "Error reading %s, expected max length %lu but has length %lu\n", col_name, + dst_len_max, col_len); return -EIO; } @@ -96,10 +102,10 @@ return -EIO; } - if (osmo_hexparse((void *)text, dst, dst_len) != col_len) + if (osmo_hexparse((void *)text, dst, dst_len_max) != col_len) return -EINVAL; - return 0; + return col_len; } /* obtain the authentication data for a given imsi @@ -107,8 +113,8 @@ * -ENOENT if the IMSI is not known, -ENOKEY if the IMSI is known but has no auth data, * -EIO on db failure */ int db_get_auth_data(struct db_context *dbc, const char *imsi, - struct osmo_sub_auth_data *aud2g, - struct osmo_sub_auth_data *aud3g, + struct osmo_sub_auth_data2 *aud2g, + struct osmo_sub_auth_data2 *aud3g, int64_t *subscr_id) { sqlite3_stmt *stmt = dbc->stmt[DB_STMT_AUC_BY_IMSI]; @@ -142,7 +148,8 @@ /* obtain result values using sqlite3_column_*() */ if (sqlite3_column_type(stmt, 1) == SQLITE_INTEGER) { /* we do have some 2G authentication data */ - if (hexparse_stmt(aud2g->u.gsm.ki, sizeof(aud2g->u.gsm.ki), stmt, 2, "Ki", imsi)) + if (hexparse_stmt(aud2g->u.gsm.ki, sizeof(aud2g->u.gsm.ki), sizeof(aud2g->u.gsm.ki), + stmt, 2, "Ki", imsi) < 0) goto end_2g; aud2g->algo = sqlite3_column_int(stmt, 1); aud2g->type = OSMO_AUTH_TYPE_GSM; @@ -151,24 +158,30 @@ end_2g: if (sqlite3_column_type(stmt, 3) == SQLITE_INTEGER) { /* we do have some 3G authentication data */ - if (hexparse_stmt(aud3g->u.umts.k, sizeof(aud3g->u.umts.k), stmt, 4, "K", imsi)) { + rc = hexparse_stmt(aud3g->u.umts.k, 16, sizeof(aud3g->u.umts.k), stmt, 4, "K", imsi); + if (rc < 0) { ret = -EIO; goto out; } + aud3g->u.umts.k_len = rc; aud3g->algo = sqlite3_column_int(stmt, 3); /* UMTS Subscribers can have either OP or OPC */ if (sqlite3_column_text(stmt, 5)) { - if (hexparse_stmt(aud3g->u.umts.opc, sizeof(aud3g->u.umts.opc), stmt, 5, "OP", imsi)) { + rc = hexparse_stmt(aud3g->u.umts.opc, 16, sizeof(aud3g->u.umts.opc), stmt, 5, "OP", imsi); + if (rc < 0) { ret = -EIO; goto out; } + aud3g->u.umts.opc_len = rc; aud3g->u.umts.opc_is_op = 1; } else { - if (hexparse_stmt(aud3g->u.umts.opc, sizeof(aud3g->u.umts.opc), stmt, 6, "OPC", imsi)) { + rc = hexparse_stmt(aud3g->u.umts.opc, 16, sizeof(aud3g->u.umts.opc), stmt, 6, "OPC", imsi); + if (rc < 0) { ret = -EIO; goto out; } + aud3g->u.umts.opc_len = rc; aud3g->u.umts.opc_is_op = 0; } aud3g->u.umts.sqn = sqlite3_column_int64(stmt, 7); @@ -194,7 +207,7 @@ unsigned int num_vec, const uint8_t *rand_auts, const uint8_t *auts, bool separation_bit) { - struct osmo_sub_auth_data aud2g, aud3g; + struct osmo_sub_auth_data2 aud2g, aud3g; int64_t subscr_id; int ret = 0; int rc; diff --git a/src/db_hlr.c b/src/db_hlr.c index 8dfbb15..aa2e365 100644 --- a/src/db_hlr.c +++ b/src/db_hlr.c @@ -1,4 +1,4 @@ -/* (C) 2015 by Harald Welte <laforge(a)gnumonks.org> +/* (C) 2015-2023 by Harald Welte <laforge(a)gnumonks.org> * * All Rights Reserved * @@ -286,12 +286,12 @@ if (aud->algo == OSMO_AUTH_ALG_NONE) break; - if (!osmo_is_hexstr(aud->u.umts.k, 32, 32, true)) { + if (!osmo_is_hexstr(aud->u.umts.k, 32, 64, true)) { LOGP(DAUC, LOGL_ERROR, "Cannot update auth tokens:" " Invalid K: '%s'\n", aud->u.umts.k); return -EINVAL; } - if (!osmo_is_hexstr(aud->u.umts.opc, 32, 32, true)) { + if (!osmo_is_hexstr(aud->u.umts.opc, 32, 64, true)) { LOGP(DAUC, LOGL_ERROR, "Cannot update auth tokens:" " Invalid OP/OPC: '%s'\n", aud->u.umts.opc); return -EINVAL; diff --git a/src/hlr.c b/src/hlr.c index e3b54ac..457850e 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -724,7 +724,7 @@ } static const char vlr_copyright[] = - "Copyright (C) 2016, 2017 by Harald Welte, sysmocom s.f.m.c. GmbH\r\n" + "Copyright (C) 2016-2023 by Harald Welte, sysmocom s.f.m.c. GmbH\r\n" "License AGPLv3+: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n" "This is free software: you are free to change and redistribute it.\r\n" "There is NO WARRANTY, to the extent permitted by law.\r\n"; diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c index 60a25bf..191a87d 100644 --- a/src/hlr_vty_subscr.c +++ b/src/hlr_vty_subscr.c @@ -1,5 +1,5 @@ /* OsmoHLR subscriber management VTY implementation */ -/* (C) 2017 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> +/* (C) 2017-2023 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -77,8 +77,8 @@ static void subscr_dump_full_vty(struct vty *vty, struct hlr_subscriber *subscr) { int rc; - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; vty_out(vty, " ID: %"PRIu64"%s", subscr->id, VTY_NEWLINE); @@ -137,12 +137,12 @@ if (aud2g.type != OSMO_AUTH_TYPE_NONE && aud2g.type != OSMO_AUTH_TYPE_GSM) { vty_out(vty, "%% Error: 2G auth data is not of type 'GSM'%s", VTY_NEWLINE); - aud2g = (struct osmo_sub_auth_data){}; + aud2g = (struct osmo_sub_auth_data2){}; } if (aud3g.type != OSMO_AUTH_TYPE_NONE && aud3g.type != OSMO_AUTH_TYPE_UMTS) { vty_out(vty, "%% Error: 3G auth data is not of type 'UMTS'%s", VTY_NEWLINE); - aud3g = (struct osmo_sub_auth_data){}; + aud3g = (struct osmo_sub_auth_data2){}; } if (aud2g.algo != OSMO_AUTH_ALG_NONE && aud2g.type != OSMO_AUTH_TYPE_NONE) { @@ -154,9 +154,10 @@ if (aud3g.algo != OSMO_AUTH_ALG_NONE && aud3g.type != OSMO_AUTH_TYPE_NONE) { vty_out(vty, " 3G auth: %s%s", osmo_auth_alg_name(aud3g.algo), VTY_NEWLINE); - vty_out(vty, " K=%s%s", hexdump_buf(aud3g.u.umts.k), VTY_NEWLINE); + vty_out(vty, " K=%s%s", + osmo_hexdump_nospc(aud3g.u.umts.k, aud3g.u.umts.k_len), VTY_NEWLINE); vty_out(vty, " %s=%s%s", aud3g.u.umts.opc_is_op? "OP" : "OPC", - hexdump_buf(aud3g.u.umts.opc), VTY_NEWLINE); + osmo_hexdump_nospc(aud3g.u.umts.opc, aud3g.u.umts.opc_len), VTY_NEWLINE); vty_out(vty, " IND-bitlen=%u", aud3g.u.umts.ind_bitlen); if (aud3g.u.umts.sqn) vty_out(vty, " last-SQN=%"PRIu64, aud3g.u.umts.sqn); diff --git a/tests/auc/auc_test.c b/tests/auc/auc_test.c index f39a5ad..5906720 100644 --- a/tests/auc/auc_test.c +++ b/tests/auc/auc_test.c @@ -116,14 +116,14 @@ /* Subscriber with 2G-only (COMP128v1) authentication data */ static void test_gen_vectors_2g_only(void) { - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct osmo_auth_vector vec; int rc; comment_start(); - aud2g = (struct osmo_sub_auth_data){ + aud2g = (struct osmo_sub_auth_data2){ .type = OSMO_AUTH_TYPE_GSM, .algo = OSMO_AUTH_ALG_COMP128v1, }; @@ -131,7 +131,7 @@ osmo_hexparse("EB215756028D60E3275E613320AEC880", aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); - aud3g = (struct osmo_sub_auth_data){ 0 }; + aud3g = (struct osmo_sub_auth_data2){ 0 }; next_rand("39fa2f4e3d523d8619a73b4f65c3e14d", true); @@ -179,14 +179,14 @@ * reflects the default configuration of sysmoUSIM-SJS1 */ static void test_gen_vectors_2g_plus_3g(void) { - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct osmo_auth_vector vec; int rc; comment_start(); - aud2g = (struct osmo_sub_auth_data){ + aud2g = (struct osmo_sub_auth_data2){ .type = OSMO_AUTH_TYPE_GSM, .algo = OSMO_AUTH_ALG_COMP128v1, }; @@ -194,9 +194,11 @@ osmo_hexparse("EB215756028D60E3275E613320AEC880", aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki)); - aud3g = (struct osmo_sub_auth_data){ + aud3g = (struct osmo_sub_auth_data2){ .type = OSMO_AUTH_TYPE_UMTS, .algo = OSMO_AUTH_ALG_MILENAGE, + .u.umts.k_len = 16, + .u.umts.opc_len = 16, .u.umts.sqn = 31, }; @@ -292,8 +294,8 @@ * tuples are suitable for both 2G and 3G authentication */ static void test_gen_vectors_3g_only(void) { - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct osmo_auth_vector vec; struct osmo_auth_vector vecs[3]; uint8_t auts[14]; @@ -302,11 +304,13 @@ comment_start(); - aud2g = (struct osmo_sub_auth_data){ 0 }; + aud2g = (struct osmo_sub_auth_data2){ 0 }; - aud3g = (struct osmo_sub_auth_data){ + aud3g = (struct osmo_sub_auth_data2){ .type = OSMO_AUTH_TYPE_UMTS, .algo = OSMO_AUTH_ALG_MILENAGE, + .u.umts.k_len = 16, + .u.umts.opc_len = 16, .u.umts.sqn = 31, }; @@ -466,18 +470,20 @@ * 2G and 3G authentication */ static void test_gen_vectors_3g_xor(void) { - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct osmo_auth_vector vec; int rc; comment_start(); - aud2g = (struct osmo_sub_auth_data){ 0 }; + aud2g = (struct osmo_sub_auth_data2){ 0 }; - aud3g = (struct osmo_sub_auth_data){ + aud3g = (struct osmo_sub_auth_data2){ .type = OSMO_AUTH_TYPE_UMTS, .algo = OSMO_AUTH_ALG_XOR_3G, + .u.umts.k_len = 16, + .u.umts.opc_len = 16, .u.umts.sqn = 0, }; @@ -517,39 +523,43 @@ int rc; int i; - struct osmo_sub_auth_data aud2g = { + struct osmo_sub_auth_data2 aud2g = { .type = OSMO_AUTH_TYPE_GSM, .algo = OSMO_AUTH_ALG_COMP128v1, }; - struct osmo_sub_auth_data aud3g = { + struct osmo_sub_auth_data2 aud3g = { .type = OSMO_AUTH_TYPE_UMTS, .algo = OSMO_AUTH_ALG_MILENAGE, + .u.umts.k_len = 16, + .u.umts.opc_len = 16, }; - struct osmo_sub_auth_data aud2g_noalg = { + struct osmo_sub_auth_data2 aud2g_noalg = { .type = OSMO_AUTH_TYPE_GSM, .algo = OSMO_AUTH_ALG_NONE, }; - struct osmo_sub_auth_data aud3g_noalg = { + struct osmo_sub_auth_data2 aud3g_noalg = { .type = OSMO_AUTH_TYPE_UMTS, .algo = OSMO_AUTH_ALG_NONE, + .u.umts.k_len = 16, + .u.umts.opc_len = 16, }; - struct osmo_sub_auth_data aud_notype = { + struct osmo_sub_auth_data2 aud_notype = { .type = OSMO_AUTH_TYPE_NONE, .algo = OSMO_AUTH_ALG_MILENAGE, }; - struct osmo_sub_auth_data no_aud = { + struct osmo_sub_auth_data2 no_aud = { .type = OSMO_AUTH_TYPE_NONE, .algo = OSMO_AUTH_ALG_NONE, }; struct { - struct osmo_sub_auth_data *aud2g; - struct osmo_sub_auth_data *aud3g; + struct osmo_sub_auth_data2 *aud2g; + struct osmo_sub_auth_data2 *aud3g; uint8_t *rand_auts; uint8_t *auts; const char *label; diff --git a/tests/auc/gen_ts_55_205_test_sets/func_template.c b/tests/auc/gen_ts_55_205_test_sets/func_template.c index 0865432..f30986f 100644 --- a/tests/auc/gen_ts_55_205_test_sets/func_template.c +++ b/tests/auc/gen_ts_55_205_test_sets/func_template.c @@ -24,18 +24,20 @@ static void {func_name}(void) {{ - struct osmo_sub_auth_data aud2g; - struct osmo_sub_auth_data aud3g; + struct osmo_sub_auth_data2 aud2g; + struct osmo_sub_auth_data2 aud3g; struct osmo_auth_vector vec; int rc; comment_start(); - aud2g = (struct osmo_sub_auth_data){{ 0 }}; + aud2g = (struct osmo_sub_auth_data2){{ 0 }}; - aud3g = (struct osmo_sub_auth_data){{ + aud3g = (struct osmo_sub_auth_data2){{ .type = OSMO_AUTH_TYPE_UMTS, .algo = OSMO_AUTH_ALG_MILENAGE, + .u.umts.k_len = 16, + .u.umts.opc_len = 16, .u.umts.sqn = 31, }}; @@ -48,6 +50,7 @@ fake_rand, sizeof(fake_rand)); vec = (struct osmo_auth_vector){{ {{0}} }}; + vec.res_len = 8; VERBOSE_ASSERT(aud3g.u.umts.sqn, == 31, "%"PRIu64); rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL); VERBOSE_ASSERT(rc, == 1, "%d"); diff --git a/tests/db/db_test.c b/tests/db/db_test.c index 6727812..bdf1393 100644 --- a/tests/db/db_test.c +++ b/tests/db/db_test.c @@ -122,16 +122,16 @@ /* Not linking the real auc_compute_vectors(), just returning num_vec. * This gets called by db_get_auc(), but we're only interested in its rc. */ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec, - struct osmo_sub_auth_data *aud2g, - struct osmo_sub_auth_data *aud3g, + struct osmo_sub_auth_data2 *aud2g, + struct osmo_sub_auth_data2 *aud3g, const uint8_t *rand_auts, const uint8_t *auts) { return num_vec; } static struct db_context *dbc = NULL; static void *ctx = NULL; static struct hlr_subscriber g_subscr; -static struct osmo_sub_auth_data g_aud2g; -static struct osmo_sub_auth_data g_aud3g; +static struct osmo_sub_auth_data2 g_aud2g; +static struct osmo_sub_auth_data2 g_aud3g; static int g_rc; static int64_t g_id; @@ -180,18 +180,21 @@ #undef Pb } -void dump_aud(const char *label, struct osmo_sub_auth_data *aud) +void dump_aud(const char *label, struct osmo_sub_auth_data2 *aud) { if (aud->type == OSMO_AUTH_TYPE_NONE) { fprintf(stderr, "%s: none\n", label); return; } - fprintf(stderr, "%s: struct osmo_sub_auth_data {\n", label); + fprintf(stderr, "%s: struct osmo_sub_auth_data2 {\n", label); #define Pf(name, fmt) \ Pfo(name, fmt, aud) #define Phex(name) \ Pfv(name, "'%s'", osmo_hexdump_nospc(aud->name, sizeof(aud->name))) +#define Phexl(name, len) \ + Pfv(name, "'%s'", osmo_hexdump_nospc(aud->name, aud->len)) + Pfv(type, "%s", osmo_sub_auth_type_name(aud->type)); Pfv(algo, "%s", osmo_auth_alg_name(aud->algo)); @@ -200,9 +203,9 @@ Phex(u.gsm.ki); break; case OSMO_AUTH_TYPE_UMTS: - Phex(u.umts.opc); + Phexl(u.umts.opc, u.umts.opc_len); Pf(u.umts.opc_is_op, "%u"); - Phex(u.umts.k); + Phexl(u.umts.k, u.umts.k_len); Phex(u.umts.amf); if (aud->u.umts.sqn) { Pf(u.umts.sqn, "%"PRIu64); @@ -219,6 +222,7 @@ #undef Pf #undef Phex +#undef Phexl } void db_raw_sql(struct db_context *dbc, const char *sql) diff --git a/tests/db/db_test.err b/tests/db/db_test.err index 222d3a1..dee85e0 100644 --- a/tests/db/db_test.err +++ b/tests/db/db_test.err @@ -824,7 +824,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 DAUC IMSI='123456789000000': No 3G Auth Data -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v1, .u.gsm.ki = '0123456789abcdef0123456789abcdef', @@ -841,7 +841,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 DAUC IMSI='123456789000000': No 3G Auth Data -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v1, .u.gsm.ki = '0123456789abcdef0123456789abcdef', @@ -853,7 +853,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 DAUC IMSI='123456789000000': No 3G Auth Data -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v2, .u.gsm.ki = 'beadedbeeaced1ebbeddefacedfacade', @@ -865,7 +865,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 DAUC IMSI='123456789000000': No 3G Auth Data -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'deafbeddedbabeacceededfadeddecaf', @@ -877,7 +877,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 DAUC IMSI='123456789000000': No 3G Auth Data -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = XOR-2G, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', @@ -905,7 +905,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 DAUC IMSI='123456789000000': No 3G Auth Data -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = XOR-2G, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', @@ -932,7 +932,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -954,7 +954,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -970,7 +970,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'deaf0ff1ced0d0dabbedd1ced1cef00d', @@ -985,7 +985,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1001,7 +1001,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'cededeffacedacefacedbadfadedbeef', @@ -1033,7 +1033,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'cededeffacedacefacedbadfadedbeef', @@ -1069,12 +1069,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1097,12 +1097,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1117,12 +1117,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1137,12 +1137,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1157,12 +1157,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1177,12 +1177,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1197,12 +1197,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1217,12 +1217,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1237,12 +1237,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1257,12 +1257,12 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 -2G: struct osmo_sub_auth_data { +2G: struct osmo_sub_auth_data2 { .type = GSM, .algo = COMP128v3, .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', } -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1338,7 +1338,7 @@ sqlite3_step(stmt) --> SQLITE_DONE db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY -DAUC IMSI='123456789000000': Error reading Ki, expected length 16 but has length 15 +DAUC IMSI='123456789000000': Error reading Ki, expected min length 16 but has length 15 DAUC IMSI='123456789000000': No 3G Auth Data @@ -1359,7 +1359,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -5 DAUC IMSI='123456789000000': No 2G Auth Data -DAUC IMSI='123456789000000': Error reading K, expected length 16 but has length 15 +DAUC IMSI='123456789000000': Error reading K, expected min length 16 but has length 15 @@ -1374,7 +1374,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -5 DAUC IMSI='123456789000000': No 2G Auth Data -DAUC IMSI='123456789000000': Error reading OP, expected length 16 but has length 15 +DAUC IMSI='123456789000000': Error reading OP, expected min length 16 but has length 15 @@ -1389,7 +1389,7 @@ db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -5 DAUC IMSI='123456789000000': No 2G Auth Data -DAUC IMSI='123456789000000': Error reading OPC, expected length 16 but has length 15 +DAUC IMSI='123456789000000': Error reading OPC, expected min length 16 but has length 15 @@ -1458,7 +1458,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1477,7 +1477,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1495,7 +1495,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1513,7 +1513,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1534,7 +1534,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1550,7 +1550,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1568,7 +1568,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', @@ -1586,7 +1586,7 @@ DAUC IMSI='123456789000000': No 2G Auth Data 2G: none -3G: struct osmo_sub_auth_data { +3G: struct osmo_sub_auth_data2 { .type = UMTS, .algo = MILENAGE, .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/33097 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I3207c7bfb73e9ff5471e5c26b66639549e4d48a2 Gerrit-Change-Number: 33097 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newchange
1 0
0 0
[XL] Change in libosmocore[master]: libosmogsm: Add support for TUAK authentication algorithm
by laforge 30 May '23

30 May '23
Attention is currently required from: pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33094 ) Change subject: libosmogsm: Add support for TUAK authentication algorithm ...................................................................... Patch Set 5: (3 comments) File include/osmocom/crypt/auth.h: https://gerrit.osmocom.org/c/libosmocore/+/33094/comment/a49e2579_58a27d2e PS5, Line 36: OSMO_AUTH_ALG_TUAK, > update TODO-RELEASE (new symbols). not really a "symbol", but yes it would count as API addition to libversion,I guess. File src/gsm/auth_tuak.c: https://gerrit.osmocom.org/c/libosmocore/+/33094/comment/ca6b942b_9045aa68 PS5, Line 45: } else > if {} else {}. […] Done File tests/Makefile.am: https://gerrit.osmocom.org/c/libosmocore/+/33094/comment/e11941eb_c811f682 PS5, Line 401: auth/milenage_test.ok \ > this looks wrong? Done -- 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: 5 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 30 May 2023 19:39:17 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: libosmogsm: Support authentication with 256-bit K and/or OP/OPc
by laforge 30 May '23

30 May '23
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/33087 to look at the new patch set (#4). 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, 185 insertions(+), 29 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/33087/4 -- 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: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in libosmocore[master]: libosmogsm: Factor out the C2 derivation function
by laforge 30 May '23

30 May '23
Attention is currently required from: laforge. Hello Jenkins Builder, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/33092 to look at the new patch set (#4). 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, 48 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/33092/4 -- 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: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[XL] Change in libosmocore[master]: libosmogsm: Add support for TUAK authentication algorithm
by laforge 30 May '23

30 May '23
Attention is currently required from: laforge. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/33094 to look at the new patch set (#6). 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,189 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/33094/6 -- 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: 6 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in osmocom-bb[master]: trxcon/l1sched: rework burst buffer shifting for TCH/[FH]
by fixeria 30 May '23

30 May '23
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32921 ) Change subject: trxcon/l1sched: rework burst buffer shifting for TCH/[FH] ...................................................................... trxcon/l1sched: rework burst buffer shifting for TCH/[FH] This is how the buffer shifting is implemented in osmo-bts-trx. Keep trxcon's l1sched implementation as close to osmo-bts-trx as possible in order to simplify the integration of CSD support. Change-Id: Idb6e415f37f41b8ab92a3864962dac0a40c2fbaa Related: OS#4396 --- M src/host/trxcon/src/sched_lchan_tchf.c M src/host/trxcon/src/sched_lchan_tchh.c 2 files changed, 45 insertions(+), 40 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/host/trxcon/src/sched_lchan_tchf.c b/src/host/trxcon/src/sched_lchan_tchf.c index 691ad5a..a4aa80c 100644 --- a/src/host/trxcon/src/sched_lchan_tchf.c +++ b/src/host/trxcon/src/sched_lchan_tchf.c @@ -75,9 +75,16 @@ LOGP_LCHAND(lchan, LOGL_DEBUG, "Traffic received: fn=%u bid=%u\n", bi->fn, bi->bid); - /* Align to the first burst of a block */ - if (*mask == 0x00 && bi->bid != 0) - return 0; + if (bi->bid == 0) { + /* Shift the burst buffer by 4 bursts leftwards */ + memcpy(&bursts_p[0], &bursts_p[464], 464); + memset(&bursts_p[464], 0, 464); + *mask = *mask << 4; + } else { + /* Align to the first burst of a block */ + if (*mask == 0x00) + return 0; + } /* Update mask */ *mask |= (1 << bi->bid); @@ -108,9 +115,6 @@ } - /* Keep the mask updated */ - *mask = *mask << 4; - switch (lchan->tch_mode) { case GSM48_CMODE_SIGN: case GSM48_CMODE_SPEECH_V1: /* FR */ @@ -157,9 +161,6 @@ return -EINVAL; } - /* Shift buffer by 4 bursts for interleaving */ - memcpy(bursts_p, bursts_p + 464, 464); - /* Check decoding result */ if (rc < 4) { LOGP_LCHAND(lchan, LOGL_ERROR, @@ -227,8 +228,10 @@ if (br->bid > 0) goto send_burst; - /* Shift buffer by 4 bursts back for interleaving */ - memcpy(bursts_p, bursts_p + 464, 464); + /* Shift the burst buffer by 4 bursts leftwards for interleaving */ + memcpy(&bursts_p[0], &bursts_p[464], 464); + memset(&bursts_p[464], 0, 464); + *mask = *mask << 4; /* populate the buffer with bursts */ switch (lchan->tch_mode) { @@ -332,12 +335,9 @@ LOGP_LCHAND(lchan, LOGL_DEBUG, "Scheduled fn=%u burst=%u\n", br->fn, br->bid); /* If we have sent the last (4/4) burst */ - if (*mask == 0x0f) { + if ((*mask & 0x0f) == 0x0f) { /* Confirm data / traffic sending (pass ownership of the prim) */ l1sched_lchan_emit_data_cnf(lchan, br->fn); - - /* Reset mask */ - *mask = 0x00; } return 0; diff --git a/src/host/trxcon/src/sched_lchan_tchh.c b/src/host/trxcon/src/sched_lchan_tchh.c index bff9b1b..30d623b 100644 --- a/src/host/trxcon/src/sched_lchan_tchh.c +++ b/src/host/trxcon/src/sched_lchan_tchh.c @@ -252,6 +252,14 @@ LOGP_LCHAND(lchan, LOGL_DEBUG, "Traffic received: fn=%u bid=%u\n", bi->fn, bi->bid); + if (bi->bid == 0) { + /* Shift the burst buffer by 2 bursts leftwards */ + memcpy(&bursts_p[0], &bursts_p[232], 232); + memcpy(&bursts_p[232], &bursts_p[464], 232); + memset(&bursts_p[464], 0, 232); + *mask = *mask << 2; + } + if (*mask == 0x00) { /* Align to the first burst */ if (bi->bid > 0) @@ -286,17 +294,17 @@ if (lchan->tch_mode == GSM48_CMODE_SIGN) { /* FACCH/H is interleaved over 6 bursts */ if ((*mask & 0x3f) != 0x3f) - goto bfi_shift; + goto bfi; } else { /* Traffic is interleaved over 4 bursts */ if ((*mask & 0x0f) != 0x0f) - goto bfi_shift; + goto bfi; } /* Skip decoding attempt in case of FACCH/H */ if (lchan->dl_ongoing_facch) { lchan->dl_ongoing_facch = false; - goto bfi_shift; /* 2/2 BFI */ + goto bfi; /* 2/2 BFI */ } switch (lchan->tch_mode) { @@ -340,13 +348,6 @@ return -EINVAL; } - /* Shift buffer by 4 bursts for interleaving */ - memcpy(bursts_p, bursts_p + 232, 232); - memcpy(bursts_p + 232, bursts_p + 464, 232); - - /* Shift burst mask */ - *mask = *mask << 2; - /* Check decoding result */ if (rc < 4) { /* Calculate AVG of the measurements (assuming 4 bursts) */ @@ -384,14 +385,6 @@ return l1sched_lchan_emit_data_ind(lchan, &tch_data[0], tch_data_len, n_errors, n_bits_total, true); -bfi_shift: - /* Shift buffer */ - memcpy(bursts_p, bursts_p + 232, 232); - memcpy(bursts_p + 232, bursts_p + 464, 232); - - /* Shift burst mask */ - *mask = *mask << 2; - bfi: /* Didn't try to decode, fake measurements */ if (n_errors < 0) { @@ -441,17 +434,15 @@ return 0; } - /* Shift buffer by 2 bursts back for interleaving */ - memcpy(bursts_p, bursts_p + 232, 232); - - /* Also shift TX burst mask */ + /* Shift the burst buffer by 2 bursts leftwards for interleaving */ + memcpy(&bursts_p[0], &bursts_p[232], 232); + memcpy(&bursts_p[232], &bursts_p[464], 232); + memset(&bursts_p[464], 0, 232); *mask = *mask << 2; /* If FACCH/H blocks are still pending */ - if (lchan->ul_facch_blocks > 2) { - memcpy(bursts_p + 232, bursts_p + 464, 232); + if (lchan->ul_facch_blocks > 2) goto send_burst; - } if (msgb_l2len(lchan->prim) == GSM_MACBLOCK_LEN) lchan->ul_facch_blocks = 6; -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32921 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Idb6e415f37f41b8ab92a3864962dac0a40c2fbaa Gerrit-Change-Number: 32921 Gerrit-PatchSet: 6 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> 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 30 May '23

30 May '23
Attention is currently required from: pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33091 ) Change subject: libosmogsm: Allow auth API caller to specify RES length ...................................................................... Patch Set 3: (2 comments) File src/gsm/auth_core.c: https://gerrit.osmocom.org/c/libosmocore/+/33091/comment/00830b5e_235ffc40 PS3, Line 224: if (aud->type == OSMO_AUTH_TYPE_UMTS) { > I think this should go inside auth_data2auth_data2(), since v2 users are expected to set it always. note this is modifying the *vec*, not the *aud*. So I cannot do it in auth_data2auth_data2 where I only have access to the aud, but not to the vec. https://gerrit.osmocom.org/c/libosmocore/+/33091/comment/45459518_cd5484a5 PS3, Line 301: if (aud->type == OSMO_AUTH_TYPE_UMTS) { > Add to auth_data2auth_data2, you can drop it from here. see above, doesn't work. -- 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: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 30 May 2023 19:29:59 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: libosmogsm: Support authentication with 256-bit K and/or OP/OPc
by laforge 30 May '23

30 May '23
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmocore/+/33087 to look at the new patch set (#3). 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, 185 insertions(+), 29 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/87/33087/3 -- 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: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • ...
  • 259
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.