[MERGED] libosmocore[master]: osmo_auth*: fix ordering of function args

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Feb 6 14:09:31 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: osmo_auth*: fix ordering of function args
......................................................................


osmo_auth*: fix ordering of function args

milenage_gen_vec() has parameter ordering of (..., auts, rand_auts, rand).

osmo_auth_gen_vec_auts() has (..., rand_auts, auts, rand), but actually feeds
args in the same order, so that its rand_auts becomes auts, and its auts
becomes rand_auts.

Interestingly enough, API user osmo-gen-vec.c also adheres to this misordering
and in turn passes auts for osmo_auth_gen_vec_auts()'s rand_auts and vice
versa, so that it matches milenage_gen_vec().

So both the implementation (milenage_*) and the API user use the same ordering,
just osmo_auth_gen_vec_auts() and osmo_auth_impl{ .gen_vec_auts() } in-between
have the argument names swapped.

Any current user of this API would need to adhere to this swapping or will not
get successful AUTS resolution to a SQN. So the least impact fix is to rename
the args without any actual functional change.

So swap the names rand_auts and auts for osmo_auth_gen_vec_auts() and
osmo_auth_impl{ .gen_vec_auts() }. (Also adjust API doc ordering)

Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4
---
M include/osmocom/crypt/auth.h
M src/gsm/auth_core.c
2 files changed, 5 insertions(+), 5 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h
index 37b8a8a..7c6072b 100644
--- a/include/osmocom/crypt/auth.h
+++ b/include/osmocom/crypt/auth.h
@@ -74,7 +74,7 @@
 	/* \brief callback for generationg auth vectors + re-sync */
 	int (*gen_vec_auts)(struct osmo_auth_vector *vec,
 			    struct osmo_sub_auth_data *aud,
-			    const uint8_t *rand_auts, const uint8_t *auts,
+			    const uint8_t *auts, const uint8_t *rand_auts,
 			    const uint8_t *_rand);
 };
 
@@ -83,7 +83,7 @@
 
 int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec,
 			   struct osmo_sub_auth_data *aud,
-			   const uint8_t *rand_auts, const uint8_t *auts,
+			   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_core.c b/src/gsm/auth_core.c
index 3aac069..3b1a5c6 100644
--- a/src/gsm/auth_core.c
+++ b/src/gsm/auth_core.c
@@ -170,8 +170,8 @@
 /*! \brief Generate authentication vector and re-sync sequence
  *  \param[out] vec Generated authentication vector
  *  \param[in] aud Subscriber-specific key material
- *  \param[in] rand_auts RAND value sent by the SIM/MS
  *  \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
  *
@@ -184,7 +184,7 @@
  */
 int osmo_auth_gen_vec_auts(struct osmo_auth_vector *vec,
 			   struct osmo_sub_auth_data *aud,
-			   const uint8_t *rand_auts, const uint8_t *auts,
+			   const uint8_t *auts, const uint8_t *rand_auts,
 			   const uint8_t *_rand)
 {
 	struct osmo_auth_impl *impl = selected_auths[aud->algo];
@@ -192,7 +192,7 @@
 	if (!impl || !impl->gen_vec_auts)
 		return -ENOENT;
 
-	return impl->gen_vec_auts(vec, aud, rand_auts, auts, _rand);
+	return impl->gen_vec_auts(vec, aud, auts, rand_auts, _rand);
 }
 
 static const struct value_string auth_alg_vals[] = {

-- 
To view, visit https://gerrit.osmocom.org/1737
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list