The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions
milenage.h File Reference

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

#include <stddef.h>
+ Include dependency graph for milenage.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MILENAGE_AK_SIZE   6
 Anonymisation key. More...
 
#define MILENAGE_AMF_SIZE   2
 Authentication management field. More...
 
#define MILENAGE_AUTN_SIZE   16
 Network authentication key. More...
 
#define MILENAGE_AUTS_SIZE   14
 
#define MILENAGE_CK_SIZE   16
 Ciphering key. More...
 
#define MILENAGE_IK_SIZE   16
 Integrity key. More...
 
#define MILENAGE_KC_SIZE   8
 
#define MILENAGE_KI_SIZE   16
 Subscriber key. More...
 
#define MILENAGE_OP_SIZE   16
 Operator code (unique to the operator) More...
 
#define MILENAGE_OPC_SIZE   16
 Derived operator code (unique to the operator and subscriber). More...
 
#define MILENAGE_RAND_SIZE   16
 Random challenge. More...
 
#define MILENAGE_RES_SIZE   8
 
#define MILENAGE_SQN_SIZE   6
 Sequence number. More...
 
#define MILENAGE_SRES_SIZE   4
 

Functions

int milenage_auts (uint64_t *sqn, uint8_t const opc[MILENAGE_OPC_SIZE], uint8_t const ki[MILENAGE_KI_SIZE], uint8_t const rand[MILENAGE_RAND_SIZE], uint8_t const auts[MILENAGE_AUTS_SIZE])
 Milenage AUTS validation. More...
 
int milenage_check (uint8_t ik[MILENAGE_IK_SIZE], uint8_t ck[MILENAGE_CK_SIZE], uint8_t res[MILENAGE_RES_SIZE], uint8_t auts[MILENAGE_AUTS_SIZE], uint8_t const opc[MILENAGE_OPC_SIZE], uint8_t const ki[MILENAGE_KI_SIZE], uint64_t sqn, uint8_t const rand[MILENAGE_RAND_SIZE], uint8_t const autn[MILENAGE_AUTN_SIZE])
 Milenage check. More...
 
void milenage_gsm_from_umts (uint8_t sres[MILENAGE_SRES_SIZE], uint8_t kc[MILENAGE_KC_SIZE], uint8_t const ik[MILENAGE_IK_SIZE], uint8_t const ck[MILENAGE_CK_SIZE], uint8_t const res[MILENAGE_RES_SIZE])
 Generate GSM-Milenage (3GPP TS 55.205) authentication triplet from a quintuplet. More...
 
int milenage_gsm_generate (uint8_t sres[MILENAGE_SRES_SIZE], uint8_t kc[MILENAGE_KC_SIZE], uint8_t const opc[MILENAGE_OPC_SIZE], uint8_t const ki[MILENAGE_KI_SIZE], uint8_t const rand[MILENAGE_RAND_SIZE])
 Generate GSM-Milenage (3GPP TS 55.205) authentication triplet. More...
 
int milenage_opc_generate (uint8_t opc[MILENAGE_OPC_SIZE], uint8_t const op[MILENAGE_OP_SIZE], uint8_t const ki[MILENAGE_KI_SIZE])
 Derive OPc from OP and Ki. More...
 
int milenage_umts_generate (uint8_t autn[MILENAGE_AUTN_SIZE], uint8_t ik[MILENAGE_IK_SIZE], uint8_t ck[MILENAGE_CK_SIZE], uint8_t ak[MILENAGE_AK_SIZE], uint8_t res[MILENAGE_RES_SIZE], uint8_t const opc[MILENAGE_OPC_SIZE], uint8_t const amf[MILENAGE_AMF_SIZE], uint8_t const ki[MILENAGE_KI_SIZE], uint64_t sqn, uint8_t const rand[MILENAGE_RAND_SIZE])
 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).

This software may be distributed under the terms of the BSD license. See README for more details.

Definition in file milenage.h.

Macro Definition Documentation

◆ MILENAGE_AK_SIZE

#define MILENAGE_AK_SIZE   6

Anonymisation key.

Definition at line 36 of file milenage.h.

◆ MILENAGE_AMF_SIZE

#define MILENAGE_AMF_SIZE   2

Authentication management field.

Definition at line 29 of file milenage.h.

◆ MILENAGE_AUTN_SIZE

#define MILENAGE_AUTN_SIZE   16

Network authentication key.

Definition at line 37 of file milenage.h.

◆ MILENAGE_AUTS_SIZE

#define MILENAGE_AUTS_SIZE   14

Definition at line 41 of file milenage.h.

◆ MILENAGE_CK_SIZE

#define MILENAGE_CK_SIZE   16

Ciphering key.

Definition at line 39 of file milenage.h.

◆ MILENAGE_IK_SIZE

#define MILENAGE_IK_SIZE   16

Integrity key.

Definition at line 38 of file milenage.h.

◆ MILENAGE_KC_SIZE

#define MILENAGE_KC_SIZE   8

Definition at line 47 of file milenage.h.

◆ MILENAGE_KI_SIZE

#define MILENAGE_KI_SIZE   16

Subscriber key.

Definition at line 26 of file milenage.h.

◆ MILENAGE_OP_SIZE

#define MILENAGE_OP_SIZE   16

Operator code (unique to the operator)

Definition at line 27 of file milenage.h.

◆ MILENAGE_OPC_SIZE

#define MILENAGE_OPC_SIZE   16

Derived operator code (unique to the operator and subscriber).

Definition at line 28 of file milenage.h.

◆ MILENAGE_RAND_SIZE

#define MILENAGE_RAND_SIZE   16

Random challenge.

Definition at line 31 of file milenage.h.

◆ MILENAGE_RES_SIZE

#define MILENAGE_RES_SIZE   8

Definition at line 40 of file milenage.h.

◆ MILENAGE_SQN_SIZE

#define MILENAGE_SQN_SIZE   6

Sequence number.

Definition at line 30 of file milenage.h.

◆ MILENAGE_SRES_SIZE

#define MILENAGE_SRES_SIZE   4

Definition at line 46 of file milenage.h.

Function Documentation

◆ milenage_auts()

int milenage_auts ( uint64_t *  sqn,
uint8_t const  opc[MILENAGE_OPC_SIZE],
uint8_t const  ki[MILENAGE_KI_SIZE],
uint8_t const  rand[MILENAGE_RAND_SIZE],
uint8_t const  auts[MILENAGE_AUTS_SIZE] 
)

Milenage AUTS validation.

Parameters
[out]sqnSQN = 48-bit sequence number (host byte order).
[in]opc128-bit operator variant algorithm configuration field (encr.).
[in]ki128-bit subscriber key.
[in]rand128-bit random challenge.
[in]auts112-bit authentication token from client.
Returns
  • 0 on success with sqn filled.
  • -1 on failure.

Definition at line 329 of file milenage.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ milenage_check()

int milenage_check ( uint8_t  ik[MILENAGE_IK_SIZE],
uint8_t  ck[MILENAGE_CK_SIZE],
uint8_t  res[MILENAGE_RES_SIZE],
uint8_t  auts[MILENAGE_AUTS_SIZE],
uint8_t const  opc[MILENAGE_OPC_SIZE],
uint8_t const  ki[MILENAGE_KI_SIZE],
uint64_t  sqn,
uint8_t const  rand[MILENAGE_RAND_SIZE],
uint8_t const  autn[MILENAGE_AUTN_SIZE] 
)

Milenage check.

Parameters
[out]ikBuffer for IK = 128-bit integrity key (f4), or NULL.
[out]ckBuffer for CK = 128-bit confidentiality key (f3), or NULL.
[out]resBuffer for RES = 64-bit signed response (f2), or NULL.
[in]auts112-bit buffer for AUTS.
[in]opc128-bit operator variant algorithm configuration field (encr.).
[in]ki128-bit subscriber key.
[in]sqn48-bit sequence number.
[in]rand128-bit random challenge.
[in]autn128-bit authentication token.
Returns
  • 0 on success.
  • -1 on failure.
  • -2 on synchronization failure

Definition at line 417 of file milenage.c.

+ Here is the call graph for this function:

◆ milenage_gsm_from_umts()

void milenage_gsm_from_umts ( uint8_t  sres[MILENAGE_SRES_SIZE],
uint8_t  kc[MILENAGE_KC_SIZE],
uint8_t const  ik[MILENAGE_IK_SIZE],
uint8_t const  ck[MILENAGE_CK_SIZE],
uint8_t const  res[MILENAGE_RES_SIZE] 
)

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

Parameters
[out]sresBuffer for SRES = 32-bit SRES.
[out]kc64-bit Kc.
[in]ik128-bit integrity.
[in]ckConfidentiality key.
[in]res64-bit signed response.

Definition at line 358 of file milenage.c.

+ Here is the caller graph for this function:

◆ milenage_gsm_generate()

int milenage_gsm_generate ( uint8_t  sres[MILENAGE_SRES_SIZE],
uint8_t  kc[MILENAGE_KC_SIZE],
uint8_t const  opc[MILENAGE_OPC_SIZE],
uint8_t const  ki[MILENAGE_KI_SIZE],
uint8_t const  rand[MILENAGE_RAND_SIZE] 
)

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

Parameters
[out]sresBuffer for SRES = 32-bit SRES.
[out]kc64-bit Kc.
[in]opc128-bit operator variant algorithm configuration field (encr.).
[in]ki128-bit subscriber key.
[in]rand128-bit random challenge.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 386 of file milenage.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ milenage_opc_generate()

int milenage_opc_generate ( uint8_t  opc[MILENAGE_OPC_SIZE],
uint8_t const  op[MILENAGE_OP_SIZE],
uint8_t const  ki[MILENAGE_KI_SIZE] 
)

Derive OPc from OP and Ki.

Parameters
[out]opcThe derived Operator Code used as an input to other Milenage functions.
[in]opOperator Code.
[in]kiSubscriber key.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 243 of file milenage.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ milenage_umts_generate()

int milenage_umts_generate ( uint8_t  autn[MILENAGE_AUTN_SIZE],
uint8_t  ik[MILENAGE_IK_SIZE],
uint8_t  ck[MILENAGE_CK_SIZE],
uint8_t  ak[MILENAGE_AK_SIZE],
uint8_t  res[MILENAGE_RES_SIZE],
uint8_t const  opc[MILENAGE_OPC_SIZE],
uint8_t const  amf[MILENAGE_AMF_SIZE],
uint8_t const  ki[MILENAGE_KI_SIZE],
uint64_t  sqn,
uint8_t const  rand[MILENAGE_RAND_SIZE] 
)

Generate AKA AUTN, IK, CK, RES.

Parameters
[out]autnBuffer for AUTN = 128-bit authentication token.
[out]ikBuffer for IK = 128-bit integrity key (f4), or NULL.
[out]ckBuffer for CK = 128-bit confidentiality key (f3), or NULL.
[out]akBuffer for AK = 48-bit anonymity key (f5), or NULL
[out]resBuffer for RES = 64-bit signed response (f2), or NULL.
[in]opc128-bit operator variant algorithm configuration field (encr.).
[in]amf16-bit authentication management field.
[in]ki128-bit subscriber key.
[in]sqn48-bit sequence number (host byte order).
[in]rand128-bit random challenge.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 282 of file milenage.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: