[PATCH] Use generic libosmocom auth API.

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/OpenBSC@lists.osmocom.org/.

Max max.suraev at fairwaves.ru
Tue Nov 19 12:42:44 UTC 2013


---
 openbsc/src/libmsc/auth.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index 10d8edf..ed25495 100644
--- a/openbsc/src/libmsc/auth.c
+++ b/openbsc/src/libmsc/auth.c
@@ -24,8 +24,7 @@
 #include <openbsc/debug.h>
 #include <openbsc/auth.h>
 #include <openbsc/gsm_data.h>
-
-#include <osmocom/gsm/comp128.h>
+#include <osmocom/crypt/auth.h>
 
 #include <stdlib.h>
 
@@ -53,6 +52,13 @@ _use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
 static int
 _use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
 {
+        static struct osmo_sub_auth_data auth = {
+	    .type = OSMO_AUTH_TYPE_GSM,
+	    .algo = OSMO_AUTH_ALG_COMP128v1
+	};
+	struct osmo_auth_vector _vec;
+	struct osmo_auth_vector *vec = &_vec;
+
 	if (ainfo->a3a8_ki_len != A38_COMP128_KEY_LEN) {
 		LOGP(DMM, LOGL_ERROR, "Invalid COMP128v1 key (len=%d) %s\n",
 			ainfo->a3a8_ki_len,
@@ -60,9 +66,13 @@ _use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
 		return -1;
 	}
 
-	comp128(ainfo->a3a8_ki, atuple->rand, atuple->sres, atuple->kc);
+	memcpy(auth.u.gsm.ki, ainfo->a3a8_ki, sizeof(auth.u.gsm.ki));
 
-	return 0;
+	int r = osmo_auth_gen_vec(vec, &auth, atuple->rand);
+	memcpy(atuple->sres, vec->sres, 4);
+	memcpy(atuple->kc, vec->kc, 8);
+
+	return r;
 }
 
 /* Return values 
-- 
1.8.3.2


--------------060000020105010100080006--




More information about the OpenBSC mailing list