Hi. Attached is a small patch which replaces direct call to comp128 from libosmocore to auth api call. This will help to remove comp128 from libosmocore public api and to use other auth functions in openbsc in future.
-- best regards, Max, http://fairwaves.ru
>From b669fba4e67d4d0055272f1fdc53065a560ff3bd Mon Sep 17 00:00:00 2001 From: Max <[email protected]> Date: Tue, 19 Nov 2013 13:16:26 +0100 Subject: [PATCH] Use generic osmocom auth api instead of direct call to comp128. --- openbsc/src/libmsc/auth.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 10d8edf..33d4a3a 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> @@ -60,9 +59,17 @@ _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); - - return 0; + static struct osmo_sub_auth_data auth = { + .type = OSMO_AUTH_TYPE_GSM, + .algo = OSMO_AUTH_ALG_COMP128v1 + }; + memcpy(auth.u.gsm.ki, ainfo->a3a8_ki, sizeof(auth.u.gsm.ki)); + struct osmo_auth_vector _vec; + struct osmo_auth_vector *vec = &_vec; + 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
