libosmogsm: Avoid executing MILENAGE crypto twice (for UMTS and GSM)
So far, we were executing the cryptographic functions to generate
MILENAGE authentication tuples *twice* for every call to
milenage_gen_vec: Once for UMTS, and another time for GSM.
Let's do this properly: Execute once for UMTS, an then call the
computationally much simpler C2 and C3 functions to compute the
SRES and Kc values from RES, and CK+IK, respectively.
Change-Id: I20ecf6d32974c1ba196bf56deba5b2cd971eaffb
diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c
index a439b15..2bd05a6 100644
--- a/src/gsm/auth_milenage.c
+++ b/src/gsm/auth_milenage.c
@@ -54,7 +54,6 @@
uint8_t sqn[6];
uint64_t ind_mask;
uint64_t seq_1;
- int rc;
OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE);
@@ -138,9 +137,8 @@
sqn, _rand,
vec->autn, vec->ik, vec->ck, vec->res, &res_len);
- rc = gsm_milenage(opc, aud->u.umts.k, _rand, vec->sres, vec->kc);
- if (rc < 0)
- return rc;
+ osmo_auth_c3(vec->kc, vec->ck, vec->ik);
+ osmo_auth_c2(vec->sres, vec->res, vec->res_len, 1);
vec->auth_types = OSMO_AUTH_TYPE_UMTS | OSMO_AUTH_TYPE_GSM;