diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-06-11 00:19:42 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-06-14 20:43:53 +0200 |
commit | e824d9c2a117cdfa83fa9614810321cc976048a2 (patch) | |
tree | 41a0bf5b8f4937599ac99b77232947cd4f0af120 /openbsc/src/auth.c | |
parent | c593cf100abeae7c795ccb568be68384081b9824 (diff) |
auth: Add support for XOR test A3A8 algo (and vty commands)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'openbsc/src/auth.c')
-rw-r--r-- | openbsc/src/auth.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/openbsc/src/auth.c b/openbsc/src/auth.c index 5a54da020..f57b668ef 100644 --- a/openbsc/src/auth.c +++ b/openbsc/src/auth.c @@ -31,6 +31,26 @@ static int +_use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) +{ + int i, l = ainfo->a3a8_ki_len; + + if ((l > A38_XOR_MAX_KEY_LEN) || (l < A38_XOR_MIN_KEY_LEN)) { + DEBUGP(DMM, "Invalid XOR key (len=%d) %s", + ainfo->a3a8_ki_len, + hexdump(ainfo->a3a8_ki, ainfo->a3a8_ki_len)); + return -1; + } + + for (i=0; i<4; i++) + atuple->sres[i] = atuple->rand[i] ^ ainfo->a3a8_ki[i]; + for (i=8; i<12; i++) + atuple->kc[i-4] = atuple->rand[i] ^ ainfo->a3a8_ki[i]; + + return 0; +} + +static int _use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple) { if (ainfo->a3a8_ki_len != A38_COMP128_KEY_LEN) { @@ -85,6 +105,11 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, case AUTH_ALGO_NONE: return 0; + case AUTH_ALGO_XOR: + if (_use_xor(&ainfo, atuple)) + return 0; + break; + case AUTH_ALGO_COMP128v1: if (_use_comp128_v1(&ainfo, atuple)) return 0; |