diff options
author | Harald Welte <laforge@gnumonks.org> | 2012-03-21 08:19:47 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-03-21 08:19:47 +0100 |
commit | 042afe7fe73929f40b32545bbdd97f10f260af60 (patch) | |
tree | 11cb9c8245a1c296c3b20f47269e1f01bfb12b04 /src/gsm | |
parent | fb6a2e274fe05865021f4b695239e73490e34437 (diff) |
milenage: Add function to compute OPC from OP and K
Diffstat (limited to 'src/gsm')
-rw-r--r-- | src/gsm/milenage/milenage.c | 15 | ||||
-rw-r--r-- | src/gsm/milenage/milenage.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/gsm/milenage/milenage.c b/src/gsm/milenage/milenage.c index cc4e95c5..b43f986a 100644 --- a/src/gsm/milenage/milenage.c +++ b/src/gsm/milenage/milenage.c @@ -327,3 +327,18 @@ int milenage_check(const u8 *opc, const u8 *k, const u8 *sqn, const u8 *_rand, return 0; } + +int milenage_opc_gen(u8 *opc, const u8 *k, const u8 *op) +{ + int i; + + /* Encrypt OP using K */ + if (aes_128_encrypt_block(k, op, opc)) + return -1; + + /* XOR the resulting Ek(OP) with OP */ + for (i = 0; i < 16; i++) + opc[i] = opc[i] ^ op[i]; + + return 0; +} diff --git a/src/gsm/milenage/milenage.h b/src/gsm/milenage/milenage.h index d5054d6d..a91e946a 100644 --- a/src/gsm/milenage/milenage.h +++ b/src/gsm/milenage/milenage.h @@ -30,4 +30,6 @@ int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand, int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand, u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar); +int milenage_opc_gen(u8 *opc, const u8 *k, const u8 *op); + #endif /* MILENAGE_H */ |