[PATCH] libosmocore[master]: add osmo_auth_c3(): separate from gsm_milenage()

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Dec 18 03:39:22 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5466

to look at the new patch set (#3).

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
---
M include/osmocom/crypt/auth.h
M src/gsm/auth_core.c
M src/gsm/libosmogsm.map
M src/gsm/milenage/milenage.c
4 files changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/66/5466/3

diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h
index 4dbc6a4..e544126 100644
--- a/include/osmocom/crypt/auth.h
+++ b/include/osmocom/crypt/auth.h
@@ -105,4 +105,6 @@
 const char *osmo_auth_alg_name(enum osmo_auth_algo alg);
 enum osmo_auth_algo osmo_auth_alg_parse(const char *name);
 
+void osmo_auth_c3(uint8_t kc[], const uint8_t ck[], const uint8_t ik[]);
+
 /* @} */
diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c
index 400708f..f171ed4 100644
--- a/src/gsm/auth_core.c
+++ b/src/gsm/auth_core.c
@@ -236,4 +236,17 @@
 	{ 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];
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 6e6638a..d915234 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -340,6 +340,7 @@
 osmo_auth_load;
 osmo_auth_register;
 osmo_auth_supported;
+osmo_auth_c3;
 osmo_sub_auth_type_names;
 
 osmo_rsl2sitype;
diff --git a/src/gsm/milenage/milenage.c b/src/gsm/milenage/milenage.c
index 7cf3312..2050d25 100644
--- a/src/gsm/milenage/milenage.c
+++ b/src/gsm/milenage/milenage.c
@@ -249,8 +249,7 @@
 	if (milenage_f2345(opc, k, _rand, res, ck, ik, NULL, NULL))
 		return -1;
 
-	for (i = 0; i < 8; i++)
-		kc[i] = ck[i] ^ ck[i + 8] ^ ik[i] ^ ik[i + 8];
+	osmo_auth_c3(kc, ck, ik);
 
 #ifdef GSM_MILENAGE_ALT_SRES
 	os_memcpy(sres, res, 4);

-- 
To view, visit https://gerrit.osmocom.org/5466
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I85a1d6ae95ad9e5ce9524ef7fc06414848afc2aa
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list