summaryrefslogtreecommitdiffstats
path: root/src/gsm/auth_milenage.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-03-21 09:03:16 +0100
committerHarald Welte <laforge@gnumonks.org>2012-03-21 09:04:14 +0100
commita72e47b8a09d6a870b093cfa3b5716b6817c33b8 (patch)
treebf5f747ac33e5ef579ed6530abdd06f03708d851 /src/gsm/auth_milenage.c
parent5fb795e972340b104467d37d5281b622507e9ff8 (diff)
auth_milenage/osmo-auc-gen: compute OPC in case only OP is known
Diffstat (limited to 'src/gsm/auth_milenage.c')
-rw-r--r--src/gsm/auth_milenage.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c
index 2a9ba334..5b2787dd 100644
--- a/src/gsm/auth_milenage.c
+++ b/src/gsm/auth_milenage.c
@@ -83,10 +83,21 @@ static int milenage_gen_vec_auts(struct osmo_auth_vector *vec,
const uint8_t *_rand)
{
uint8_t sqn_out[6];
+ uint8_t gen_opc[16];
+ uint8_t *opc;
int rc;
- rc = milenage_auts(aud->u.umts.opc, aud->u.umts.k,
- rand_auts, auts, sqn_out);
+ /* Check if we only know OP and compute OPC if required */
+ if (aud->type == OSMO_AUTH_TYPE_UMTS && aud->u.umts.opc_is_op) {
+ rc = milenage_opc_gen(gen_opc, aud->u.umts.k,
+ aud->u.umts.opc);
+ if (rc < 0)
+ return rc;
+ opc = gen_opc;
+ } else
+ opc = aud->u.umts.opc;
+
+ rc = milenage_auts(opc, aud->u.umts.k, rand_auts, auts, sqn_out);
if (rc < 0)
return rc;