The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
milenage.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * @file src/lib/sim/milenage.h
4  * @brief 3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208)
5  *
6  * This file implements an example authentication algorithm defined for 3GPP
7  * AKA. This can be used to implement a simple HLR/AuC into hlr_auc_gw to allow
8  * EAP-AKA to be tested properly with real USIM cards.
9  *
10  * This implementations assumes that the r1..r5 and c1..c5 constants defined in
11  * TS 35.206 are used, i.e., r1=64, r2=0, r3=32, r4=64, r5=96, c1=00..00,
12  * c2=00..01, c3=00..02, c4=00..04, c5=00..08. The block cipher is assumed to
13  * be AES (Rijndael).
14  *
15  * This software may be distributed under the terms of the BSD license.
16  * See README for more details.
17  *
18  * @copyright 2017 The FreeRADIUS server project
19  * @copyright 2006-2007 (j@w1.fi)
20  */
21 #include <stddef.h>
22 
23 /*
24  * Inputs
25  */
26 #define MILENAGE_KI_SIZE 16 //!< Subscriber key.
27 #define MILENAGE_OP_SIZE 16 //!< Operator code (unique to the operator)
28 #define MILENAGE_OPC_SIZE 16 //!< Derived operator code (unique to the operator and subscriber).
29 #define MILENAGE_AMF_SIZE 2 //!< Authentication management field.
30 #define MILENAGE_SQN_SIZE 6 //!< Sequence number.
31 #define MILENAGE_RAND_SIZE 16 //!< Random challenge.
32 
33 /*
34  * UMTS Outputs
35  */
36 #define MILENAGE_AK_SIZE 6 //!< Anonymisation key.
37 #define MILENAGE_AUTN_SIZE 16 //!< Network authentication key.
38 #define MILENAGE_IK_SIZE 16 //!< Integrity key.
39 #define MILENAGE_CK_SIZE 16 //!< Ciphering key.
40 #define MILENAGE_RES_SIZE 8
41 #define MILENAGE_AUTS_SIZE 14
42 
43 /*
44  * GSM (COMP128-4) outputs
45  */
46 #define MILENAGE_SRES_SIZE 4
47 #define MILENAGE_KC_SIZE 8
48 
50  uint8_t const op[MILENAGE_OP_SIZE],
51  uint8_t const ki[MILENAGE_KI_SIZE]);
52 
58  uint8_t const opc[MILENAGE_OPC_SIZE],
59  uint8_t const amf[MILENAGE_AMF_SIZE],
60  uint8_t const ki[MILENAGE_KI_SIZE],
61  uint64_t sqn,
62  uint8_t const rand[MILENAGE_RAND_SIZE]);
63 
64 int milenage_auts(uint64_t *sqn,
65  uint8_t const opc[MILENAGE_OPC_SIZE],
66  uint8_t const ki[MILENAGE_KI_SIZE],
67  uint8_t const rand[MILENAGE_RAND_SIZE],
68  uint8_t const auts[MILENAGE_AUTS_SIZE]);
69 
72  uint8_t const ik[MILENAGE_IK_SIZE],
73  uint8_t const ck[MILENAGE_CK_SIZE],
74  uint8_t const res[MILENAGE_RES_SIZE]);
75 
77  uint8_t const opc[MILENAGE_OPC_SIZE],
78  uint8_t const ki[MILENAGE_KI_SIZE],
79  uint8_t const rand[MILENAGE_RAND_SIZE]);
80 
85  uint8_t const opc[MILENAGE_OPC_SIZE],
86  uint8_t const ki[MILENAGE_KI_SIZE],
87  uint64_t sqn,
88  uint8_t const rand[MILENAGE_RAND_SIZE],
89  uint8_t const autn[MILENAGE_AUTN_SIZE]);
unsigned char uint8_t
Definition: merged_model.c:30
#define MILENAGE_AK_SIZE
Anonymisation key.
Definition: milenage.h:36
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.
Definition: milenage.c:282
#define MILENAGE_AMF_SIZE
Authentication management field.
Definition: milenage.h:29
#define MILENAGE_KI_SIZE
Subscriber key.
Definition: milenage.h:26
#define MILENAGE_RAND_SIZE
Random challenge.
Definition: milenage.h:31
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.
Definition: milenage.c:417
#define MILENAGE_AUTN_SIZE
Network authentication key.
Definition: milenage.h:37
#define MILENAGE_SRES_SIZE
Definition: milenage.h:46
#define MILENAGE_CK_SIZE
Ciphering key.
Definition: milenage.h:39
#define MILENAGE_OP_SIZE
Operator code (unique to the operator)
Definition: milenage.h:27
#define MILENAGE_IK_SIZE
Integrity key.
Definition: milenage.h:38
#define MILENAGE_KC_SIZE
Definition: milenage.h:47
#define MILENAGE_AUTS_SIZE
Definition: milenage.h:41
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.
Definition: milenage.c:329
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.
Definition: milenage.c:358
#define MILENAGE_OPC_SIZE
Derived operator code (unique to the operator and subscriber).
Definition: milenage.h:28
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.
Definition: milenage.c:386
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.
Definition: milenage.c:243
#define MILENAGE_RES_SIZE
Definition: milenage.h:40