From ceae1237528f91f44e226225207ac70a2cf842ec Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 27 Jun 2016 18:12:49 +0200 Subject: Make C4 function globally available This function perform 64 -> 128 bit key expansion which useful for converting between UMTS CK and GSM Kc, A5/3 and A5/4, GEA3 and GEA4 keys. Change-Id: I5a6c6deef6027cd6af144c9062d4c9166be26904 Related: OS#1582 --- src/gsm/a5.c | 4 ++-- src/gsm/auth_core.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gsm/a5.c b/src/gsm/a5.c index f1fd697e..dbba0f20 100644 --- a/src/gsm/a5.c +++ b/src/gsm/a5.c @@ -40,6 +40,7 @@ #include #include +#include /* Somme OS (like Nuttx) don't have ENOTSUP */ #ifndef ENOTSUP @@ -95,8 +96,7 @@ void _a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct) { uint8_t ck[16]; - memcpy(ck, key, 8); - memcpy(ck + 8, key, 8); + osmo_c4(ck, key); /* internal function require 128 bit key so we expand by concatenating supplied 64 bit key */ _a5_4(ck, fn, dl, ul, fn_correct); } diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index f1ec2ed4..3aac0694 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -106,7 +106,7 @@ static inline void c5_function(uint8_t *ik, const uint8_t *kc) } /* C4 function to derive UMTS CK from GSM Kc */ -static inline void c4_function(uint8_t *ck, const uint8_t *kc) +void osmo_c4(uint8_t *ck, const uint8_t *kc) { memcpy(ck, kc, 8); memcpy(ck+8, kc, 8); @@ -125,7 +125,7 @@ int osmo_auth_3g_from_2g(struct osmo_auth_vector *vec) if ((vec->auth_types & OSMO_AUTH_TYPE_GSM) && !(vec->auth_types & OSMO_AUTH_TYPE_UMTS)) { c5_function(vec->ik, vec->kc); - c4_function(vec->ck, vec->kc); + osmo_c4(vec->ck, vec->kc); /* We cannot actually set OSMO_AUTH_TYPE_UMTS as we have no * AUTN and no RES, and thus can only perform GSM * authentication with this tuple. -- cgit v1.2.3