summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/crypt/auth.h2
-rw-r--r--src/gsm/auth_core.c13
-rw-r--r--src/gsm/libosmogsm.map1
-rw-r--r--src/gsm/milenage/milenage.c5
4 files changed, 18 insertions, 3 deletions
diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h
index 4dbc6a4d..e544126b 100644
--- a/include/osmocom/crypt/auth.h
+++ b/include/osmocom/crypt/auth.h
@@ -105,4 +105,6 @@ void osmo_c4(uint8_t *ck, const uint8_t *kc);
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 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];
+}
+
/*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 6e6638a9..d915234c 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -340,6 +340,7 @@ osmo_auth_3g_from_2g;
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 7cf33122..3c14ab96 100644
--- a/src/gsm/milenage/milenage.c
+++ b/src/gsm/milenage/milenage.c
@@ -29,7 +29,7 @@
#include "common.h"
#include "aes_wrap.h"
#include "milenage.h"
-
+#include <osmocom/crypt/auth.h>
/**
* milenage_f1 - Milenage f1 and f1* algorithms
@@ -249,8 +249,7 @@ int gsm_milenage(const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, u8 *kc)
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);