libosmogsm 1.13.1.1-afb4 Osmocom GSM library

Functions
milenage.c File Reference

3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208) More...

`#include "includes.h"`
`#include "common.h"`
`#include "aes_wrap.h"`
`#include "milenage.h"`
`#include <osmocom/crypt/auth.h>`

## Functions
int | milenage_f1 (const u8 *opc, const u8 *k, const u8 *_rand, const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s)
| milenage_f1 - Milenage f1 and f1* algorithms @opc: OPc = 128-bit value derived from OP and K @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @sqn: SQN = 48-bit sequence number @amf: AMF = 16-bit authentication management field @mac_a: Buffer for MAC-A = 64-bit network authentication code, or NULL @mac_s: Buffer for MAC-S = 64-bit resync authentication code, or NULL Returns: 0 on success, -1 on failure More...
int | milenage_f2345 (const u8 *opc, const u8 *k, const u8 *_rand, u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar)
| milenage_f2345 - Milenage f2, f3, f4, f5, f5* algorithms @opc: OPc = 128-bit value derived from OP and K @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @res: Buffer for RES = 64-bit signed response (f2), or NULL @ck: Buffer for CK = 128-bit confidentiality key (f3), or NULL @ik: Buffer for IK = 128-bit integrity key (f4), or NULL @ak: Buffer for AK = 48-bit anonymity key (f5), or NULL @akstar: Buffer for AK = 48-bit anonymity key (f5*), or NULL Returns: 0 on success, -1 on failure More...
void | milenage_generate (const u8 *opc, const u8 *amf, const u8 *k, const u8 *sqn, const u8 *_rand, u8 *autn, u8 *ik, u8 *ck, u8 *res, size_t *res_len)
| milenage_generate - Generate AKA AUTN,IK,CK,RES @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @amf: AMF = 16-bit authentication management field @k: K = 128-bit subscriber key @sqn: SQN = 48-bit sequence number @_rand: RAND = 128-bit random challenge @autn: Buffer for AUTN = 128-bit authentication token @ik: Buffer for IK = 128-bit integrity key (f4), or NULL @ck: Buffer for CK = 128-bit confidentiality key (f3), or NULL @res: Buffer for RES = 64-bit signed response (f2), or NULL @res_len: Max length for res; set to used length or 0 on failure More...
int | milenage_auts (const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts, u8 *sqn)
| milenage_auts - Milenage AUTS validation @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @auts: AUTS = 112-bit authentication token from client @sqn: Buffer for SQN = 48-bit sequence number Returns: 0 = success (sqn filled), -1 on failure More...
int | gsm_milenage (const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, u8 *kc)
| gsm_milenage - Generate GSM-Milenage (3GPP TS 55.205) authentication triplet @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @sres: Buffer for SRES = 32-bit SRES @kc: Buffer for Kc = 64-bit Kc Returns: 0 on success, -1 on failure More...
int | milenage_check (const u8 *opc, const u8 *k, const u8 *sqn, const u8 *_rand, const u8 *autn, u8 *ik, u8 *ck, u8 *res, size_t *res_len, u8 *auts)
| milenage_generate - Generate AKA AUTN,IK,CK,RES @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @k: K = 128-bit subscriber key @sqn: SQN = 48-bit sequence number @_rand: RAND = 128-bit random challenge @autn: AUTN = 128-bit authentication token @ik: Buffer for IK = 128-bit integrity key (f4), or NULL @ck: Buffer for CK = 128-bit confidentiality key (f3), or NULL @res: Buffer for RES = 64-bit signed response (f2), or NULL @res_len: Variable that will be set to RES length @auts: 112-bit buffer for AUTS Returns: 0 on success, -1 on failure, or -2 on synchronization failure More...
int | milenage_opc_gen (u8 *opc, const u8 *k, const u8 *op)

## Detailed Description

3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208)

## Function Documentation

## ◆ gsm_milenage()

int gsm_milenage | ( | const u8 * | opc,
|  | const u8 * | k,
|  | const u8 * | _rand,
|  | u8 * | sres,
|  | u8 * | kc
| ) |  |

gsm_milenage - Generate GSM-Milenage (3GPP TS 55.205) authentication triplet @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @sres: Buffer for SRES = 32-bit SRES @kc: Buffer for Kc = 64-bit Kc Returns: 0 on success, -1 on failure

References milenage_f2345(), osmo_auth_c2(), osmo_auth_c3(), res, and sres.

## ◆ milenage_auts()

int milenage_auts | ( | const u8 * | opc,
|  | const u8 * | k,
|  | const u8 * | _rand,
|  | const u8 * | auts,
|  | u8 * | sqn
| ) |  |

milenage_auts - Milenage AUTS validation @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @auts: AUTS = 112-bit authentication token from client @sqn: Buffer for SQN = 48-bit sequence number Returns: 0 = success (sqn filled), -1 on failure

References milenage_f1(), and milenage_f2345().

Referenced by milenage_gen_vec_auts().

## ◆ milenage_check()

int milenage_check | ( | const u8 * | opc,
|  | const u8 * | k,
|  | const u8 * | sqn,
|  | const u8 * | _rand,
|  | const u8 * | autn,
|  | u8 * | ik,
|  | u8 * | ck,
|  | u8 * | res,
|  | size_t * | res_len,
|  | u8 * | auts
| ) |  |

milenage_generate - Generate AKA AUTN,IK,CK,RES @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @k: K = 128-bit subscriber key @sqn: SQN = 48-bit sequence number @_rand: RAND = 128-bit random challenge @autn: AUTN = 128-bit authentication token @ik: Buffer for IK = 128-bit integrity key (f4), or NULL @ck: Buffer for CK = 128-bit confidentiality key (f3), or NULL @res: Buffer for RES = 64-bit signed response (f2), or NULL @res_len: Variable that will be set to RES length @auts: 112-bit buffer for AUTS Returns: 0 on success, -1 on failure, or -2 on synchronization failure

References milenage_f1(), milenage_f2345(), MSG_DEBUG, os_memcmp, res, wpa_hexdump, wpa_hexdump_key, and wpa_printf.

## ◆ milenage_f1()

int milenage_f1 | ( | const u8 * | opc,
|  | const u8 * | k,
|  | const u8 * | _rand,
|  | const u8 * | sqn,
|  | const u8 * | amf,
|  | u8 * | mac_a,
|  | u8 * | mac_s
| ) |  |

milenage_f1 - Milenage f1 and f1* algorithms @opc: OPc = 128-bit value derived from OP and K @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @sqn: SQN = 48-bit sequence number @amf: AMF = 16-bit authentication management field @mac_a: Buffer for MAC-A = 64-bit network authentication code, or NULL @mac_s: Buffer for MAC-S = 64-bit resync authentication code, or NULL Returns: 0 on success, -1 on failure

References aes_128_encrypt_block(), and os_memcpy.

Referenced by milenage_auts(), milenage_check(), and milenage_generate().

## ◆ milenage_f2345()

int milenage_f2345 | ( | const u8 * | opc,
|  | const u8 * | k,
|  | const u8 * | _rand,
|  | u8 * | res,
|  | u8 * | ck,
|  | u8 * | ik,
|  | u8 * | ak,
|  | u8 * | akstar
| ) |  |

milenage_f2345 - Milenage f2, f3, f4, f5, f5* algorithms @opc: OPc = 128-bit value derived from OP and K @k: K = 128-bit subscriber key @_rand: RAND = 128-bit random challenge @res: Buffer for RES = 64-bit signed response (f2), or NULL @ck: Buffer for CK = 128-bit confidentiality key (f3), or NULL @ik: Buffer for IK = 128-bit integrity key (f4), or NULL @ak: Buffer for AK = 48-bit anonymity key (f5), or NULL @akstar: Buffer for AK = 48-bit anonymity key (f5*), or NULL Returns: 0 on success, -1 on failure

References aes_128_encrypt_block(), os_memcpy, and res.

Referenced by gsm_milenage(), milenage_auts(), milenage_check(), and milenage_generate().

## ◆ milenage_generate()

void milenage_generate | ( | const u8 * | opc,
|  | const u8 * | amf,
|  | const u8 * | k,
|  | const u8 * | sqn,
|  | const u8 * | _rand,
|  | u8 * | autn,
|  | u8 * | ik,
|  | u8 * | ck,
|  | u8 * | res,
|  | size_t * | res_len
| ) |  |

milenage_generate - Generate AKA AUTN,IK,CK,RES @opc: OPc = 128-bit operator variant algorithm configuration field (encr.) @amf: AMF = 16-bit authentication management field @k: K = 128-bit subscriber key @sqn: SQN = 48-bit sequence number @_rand: RAND = 128-bit random challenge @autn: Buffer for AUTN = 128-bit authentication token @ik: Buffer for IK = 128-bit integrity key (f4), or NULL @ck: Buffer for CK = 128-bit confidentiality key (f3), or NULL @res: Buffer for RES = 64-bit signed response (f2), or NULL @res_len: Max length for res; set to used length or 0 on failure

References milenage_f1(), milenage_f2345(), os_memcpy, and res.

Referenced by milenage_gen_vec().

## ◆ milenage_opc_gen()

int milenage_opc_gen | ( | u8 * | opc,
|  | const u8 * | k,
|  | const u8 * | op
| ) |  |

References aes_128_encrypt_block().

Referenced by gen_opc_if_needed().