wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
milenage.c File Reference

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

#include "includes.h"
#include "common.h"
#include "crypto/aes_wrap.h"
#include "milenage.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 and f1* algorithms. More...
 
int milenage_f2345 (const u8 *opc, const u8 *k, const u8 *_rand, u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar)
 Milenage f2, f3, f4, f5, f5* algorithms. 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)
 Generate AKA AUTN,IK,CK,RES. More...
 
int milenage_auts (const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts, u8 *sqn)
 Milenage AUTS validation. More...
 
int gsm_milenage (const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, u8 *kc)
 Generate GSM-Milenage (3GPP TS 55.205) authentication triplet. 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)
 Generate AKA AUTN,IK,CK,RES. More...
 

Detailed Description

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

This file implements an example authentication algorithm defined for 3GPP AKA. This can be used to implement a simple HLR/AuC into hlr_auc_gw to allow EAP-AKA to be tested properly with real USIM cards.

This implementations assumes that the r1..r5 and c1..c5 constants defined in TS 35.206 are used, i.e., r1=64, r2=0, r3=32, r4=64, r5=96, c1=00..00, c2=00..01, c3=00..02, c4=00..04, c5=00..08. The block cipher is assumed to be AES (Rijndael).

Function Documentation

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

Generate GSM-Milenage (3GPP TS 55.205) authentication triplet.

Parameters
opcOPc = 128-bit operator variant algorithm configuration field (encr.)
kK = 128-bit subscriber key
_randRAND = 128-bit random challenge
sresBuffer for SRES = 32-bit SRES
kcBuffer for Kc = 64-bit Kc
Returns
0 on success, -1 on failure
int milenage_auts ( const u8 *  opc,
const u8 *  k,
const u8 *  _rand,
const u8 *  auts,
u8 *  sqn 
)

Milenage AUTS validation.

Parameters
opcOPc = 128-bit operator variant algorithm configuration field (encr.)
kK = 128-bit subscriber key
_randRAND = 128-bit random challenge
autsAUTS = 112-bit authentication token from client
sqnBuffer for SQN = 48-bit sequence number
Returns
0 = success (sqn filled), -1 on failure
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 
)

Generate AKA AUTN,IK,CK,RES.

Parameters
opcOPc = 128-bit operator variant algorithm configuration field (encr.)
kK = 128-bit subscriber key
sqnSQN = 48-bit sequence number
_randRAND = 128-bit random challenge
autnAUTN = 128-bit authentication token
ikBuffer for IK = 128-bit integrity key (f4), or NULL
ckBuffer for CK = 128-bit confidentiality key (f3), or NULL
resBuffer for RES = 64-bit signed response (f2), or NULL
res_lenVariable that will be set to RES length
auts112-bit buffer for AUTS
Returns
0 on success, -1 on failure, or -2 on synchronization failure
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 and f1* algorithms.

Parameters
opcOPc = 128-bit value derived from OP and K
kK = 128-bit subscriber key
_randRAND = 128-bit random challenge
sqnSQN = 48-bit sequence number
amfAMF = 16-bit authentication management field
mac_aBuffer for MAC-A = 64-bit network authentication code, or NULL
mac_sBuffer for MAC-S = 64-bit resync authentication code, or NULL
Returns
0 on success, -1 on failure
int milenage_f2345 ( const u8 *  opc,
const u8 *  k,
const u8 *  _rand,
u8 *  res,
u8 *  ck,
u8 *  ik,
u8 *  ak,
u8 *  akstar 
)

Milenage f2, f3, f4, f5, f5* algorithms.

Parameters
opcOPc = 128-bit value derived from OP and K
kK = 128-bit subscriber key
_randRAND = 128-bit random challenge
resBuffer for RES = 64-bit signed response (f2), or NULL
ckBuffer for CK = 128-bit confidentiality key (f3), or NULL
ikBuffer for IK = 128-bit integrity key (f4), or NULL
akBuffer for AK = 48-bit anonymity key (f5), or NULL
akstarBuffer for AK = 48-bit anonymity key (f5*), or NULL
Returns
0 on success, -1 on failure
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 
)

Generate AKA AUTN,IK,CK,RES.

Parameters
opcOPc = 128-bit operator variant algorithm configuration field (encr.)
amfAMF = 16-bit authentication management field
kK = 128-bit subscriber key
sqnSQN = 48-bit sequence number
_randRAND = 128-bit random challenge
autnBuffer for AUTN = 128-bit authentication token
ikBuffer for IK = 128-bit integrity key (f4), or NULL
ckBuffer for CK = 128-bit confidentiality key (f3), or NULL
resBuffer for RES = 64-bit signed response (f2), or NULL
res_lenMax length for res; set to used length or 0 on failure