From aa84b71f0fe014156e90dde2f0c44694368dc034 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 18 Dec 2017 03:12:01 +0100 Subject: add osmo_auth_c3() (separate from gsm_milenage()) To send a Ciphering Mode Command, we may need to derive a Kc from UMTS AKA tokens. gsm_milenage() derives Kc from 3G tokens, but also derives an SRES. For SRES, it requires an OPC, which may need to be derived from OP first. All we need is a Kc, so we could feed a zero OPC ... but to simplify the function call for cases where just a Kc is required, separate the c3 function out from gsm_milenage(), as osmo_auth_c3(). Obviously call osmo_auth_c3() from gsm_milenage() (meaning that osmo-hlr's 55.205 derived auc tests still cover exactly that implementation). Prepares: If04e405426c55a81341747a9b450a69188525d5c (osmo-msc) Related: OS#2745 Change-Id: I85a1d6ae95ad9e5ce9524ef7fc06414848afc2aa --- src/gsm/auth_core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gsm/auth_core.c') diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c index 400708f9..f171ed49 100644 --- a/src/gsm/auth_core.c +++ b/src/gsm/auth_core.c @@ -236,4 +236,17 @@ const struct value_string osmo_sub_auth_type_names[] = { { 0, NULL } }; +/* Derive GSM AKA ciphering key Kc from UMTS AKA CK and IK (auth function c3 from 3GPP TS 33.103 ยง + * 4.6.1). + * \param[out] kc GSM AKA Kc, 8 byte target buffer. + * \param[in] ck UMTS AKA CK, 16 byte input buffer. + * \param[in] ik UMTS AKA IK, 16 byte input buffer. + */ +void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[]) +{ + int i; + for (i = 0; i < 8; i++) + kc[i] = ck[i] ^ ck[i + 8] ^ ik[i] ^ ik[i + 8]; +} + /*! @} */ -- cgit v1.2.3