aboutsummaryrefslogtreecommitdiffstats
path: root/src/auc.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-05-30 17:27:32 +0200
committerHarald Welte <laforge@osmocom.org>2023-06-14 14:53:04 +0200
commita854b487620f2916c891da2d01245cb8b2624907 (patch)
tree096b04515d3ca6fd82275c19c4820b021d2472b8 /src/auc.c
parent91150802f83aabbb701aced555bd02f5c8c9f8ee (diff)
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
Diffstat (limited to 'src/auc.c')
-rw-r--r--src/auc.c21
1 files changed, 12 insertions, 9 deletions
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@gnumonks.org>
+/* (C) 2015-2023 by Harald Welte <laforge@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 @@ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec,
: "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 @@ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec,
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 @@ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec,
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 @@ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec,
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 @@ int auc_compute_vectors(struct osmo_auth_vector *vec, unsigned int num_vec,
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);