5 #ifndef EAP_SIM_COMMON_H
6 #define EAP_SIM_COMMON_H
8 #define EAP_SIM_NONCE_S_LEN 16
9 #define EAP_SIM_NONCE_MT_LEN 16
10 #define EAP_SIM_MAC_LEN 16
11 #define EAP_SIM_MK_LEN 20
12 #define EAP_SIM_K_AUT_LEN 16
13 #define EAP_SIM_K_ENCR_LEN 16
14 #define EAP_SIM_KEYING_DATA_LEN 64
15 #define EAP_SIM_IV_LEN 16
16 #define EAP_SIM_KC_LEN 8
17 #define EAP_SIM_SRES_LEN 4
19 #define GSM_RAND_LEN 16
21 #define EAP_SIM_VERSION 1
24 #define EAP_SIM_SUBTYPE_START 10
25 #define EAP_SIM_SUBTYPE_CHALLENGE 11
26 #define EAP_SIM_SUBTYPE_NOTIFICATION 12
27 #define EAP_SIM_SUBTYPE_REAUTHENTICATION 13
28 #define EAP_SIM_SUBTYPE_CLIENT_ERROR 14
31 #define EAP_SIM_UNABLE_TO_PROCESS_PACKET 0
32 #define EAP_SIM_UNSUPPORTED_VERSION 1
33 #define EAP_SIM_INSUFFICIENT_NUM_OF_CHAL 2
34 #define EAP_SIM_RAND_NOT_FRESH 3
36 #define EAP_SIM_MAX_FAST_REAUTHS 1000
38 #define EAP_SIM_MAX_CHAL 3
42 #define EAP_AKA_SUBTYPE_CHALLENGE 1
43 #define EAP_AKA_SUBTYPE_AUTHENTICATION_REJECT 2
44 #define EAP_AKA_SUBTYPE_SYNCHRONIZATION_FAILURE 4
45 #define EAP_AKA_SUBTYPE_IDENTITY 5
46 #define EAP_AKA_SUBTYPE_NOTIFICATION 12
47 #define EAP_AKA_SUBTYPE_REAUTHENTICATION 13
48 #define EAP_AKA_SUBTYPE_CLIENT_ERROR 14
51 #define EAP_AKA_UNABLE_TO_PROCESS_PACKET 0
53 #define EAP_AKA_RAND_LEN 16
54 #define EAP_AKA_AUTN_LEN 16
55 #define EAP_AKA_AUTS_LEN 14
56 #define EAP_AKA_RES_MAX_LEN 16
57 #define EAP_AKA_IK_LEN 16
58 #define EAP_AKA_CK_LEN 16
59 #define EAP_AKA_MAX_FAST_REAUTHS 1000
60 #define EAP_AKA_MIN_RES_LEN 4
61 #define EAP_AKA_MAX_RES_LEN 16
62 #define EAP_AKA_CHECKCODE_LEN 20
64 #define EAP_AKA_PRIME_K_AUT_LEN 32
65 #define EAP_AKA_PRIME_CHECKCODE_LEN 32
66 #define EAP_AKA_PRIME_K_RE_LEN 32
70 void eap_sim_derive_mk(
const u8 *identity,
size_t identity_len,
71 const u8 *nonce_mt, u16 selected_version,
72 const u8 *ver_list,
size_t ver_list_len,
73 int num_chal,
const u8 *kc, u8 *mk);
74 void eap_aka_derive_mk(
const u8 *identity,
size_t identity_len,
75 const u8 *ik,
const u8 *ck, u8 *mk);
76 int eap_sim_derive_keys(
const u8 *mk, u8 *k_encr, u8 *k_aut, u8 *msk,
78 int eap_sim_derive_keys_reauth(u16 _counter,
79 const u8 *identity,
size_t identity_len,
80 const u8 *nonce_s,
const u8 *mk, u8 *msk,
82 int eap_sim_verify_mac(
const u8 *k_aut,
const struct wpabuf *req,
83 const u8 *mac,
const u8 *extra,
size_t extra_len);
84 void eap_sim_add_mac(
const u8 *k_aut,
const u8 *msg,
size_t msg_len, u8 *mac,
85 const u8 *extra,
size_t extra_len);
87 #if defined(EAP_AKA_PRIME) || defined(EAP_SERVER_AKA_PRIME)
88 void eap_aka_prime_derive_keys(
const u8 *identity,
size_t identity_len,
89 const u8 *ik,
const u8 *ck, u8 *k_encr,
90 u8 *k_aut, u8 *k_re, u8 *msk, u8 *emsk);
91 int eap_aka_prime_derive_keys_reauth(
const u8 *k_re, u16 counter,
92 const u8 *identity,
size_t identity_len,
93 const u8 *nonce_s, u8 *msk, u8 *emsk);
94 int eap_sim_verify_mac_sha256(
const u8 *k_aut,
const struct wpabuf *req,
95 const u8 *mac,
const u8 *extra,
97 void eap_sim_add_mac_sha256(
const u8 *k_aut,
const u8 *msg,
size_t msg_len,
98 u8 *mac,
const u8 *extra,
size_t extra_len);
100 void eap_aka_prime_derive_ck_ik_prime(u8 *ck, u8 *ik,
const u8 *sqn_ak,
101 const u8 *network_name,
102 size_t network_name_len);
104 static inline void eap_aka_prime_derive_keys(
const u8 *identity,
106 const u8 *ik,
const u8 *ck,
107 u8 *k_encr, u8 *k_aut, u8 *k_re,
112 static inline int eap_aka_prime_derive_keys_reauth(
const u8 *k_re, u16 counter,
115 const u8 *nonce_s, u8 *msk,
121 static inline int eap_sim_verify_mac_sha256(
const u8 *k_aut,
123 const u8 *mac,
const u8 *extra,
132 #define EAP_SIM_AT_RAND 1
133 #define EAP_SIM_AT_AUTN 2
134 #define EAP_SIM_AT_RES 3
135 #define EAP_SIM_AT_AUTS 4
136 #define EAP_SIM_AT_PADDING 6
137 #define EAP_SIM_AT_NONCE_MT 7
138 #define EAP_SIM_AT_PERMANENT_ID_REQ 10
139 #define EAP_SIM_AT_MAC 11
140 #define EAP_SIM_AT_NOTIFICATION 12
141 #define EAP_SIM_AT_ANY_ID_REQ 13
142 #define EAP_SIM_AT_IDENTITY 14
143 #define EAP_SIM_AT_VERSION_LIST 15
144 #define EAP_SIM_AT_SELECTED_VERSION 16
145 #define EAP_SIM_AT_FULLAUTH_ID_REQ 17
146 #define EAP_SIM_AT_COUNTER 19
147 #define EAP_SIM_AT_COUNTER_TOO_SMALL 20
148 #define EAP_SIM_AT_NONCE_S 21
149 #define EAP_SIM_AT_CLIENT_ERROR_CODE 22
150 #define EAP_SIM_AT_KDF_INPUT 23
151 #define EAP_SIM_AT_KDF 24
152 #define EAP_SIM_AT_IV 129
153 #define EAP_SIM_AT_ENCR_DATA 130
154 #define EAP_SIM_AT_NEXT_PSEUDONYM 132
155 #define EAP_SIM_AT_NEXT_REAUTH_ID 133
156 #define EAP_SIM_AT_CHECKCODE 134
157 #define EAP_SIM_AT_RESULT_IND 135
158 #define EAP_SIM_AT_BIDDING 136
161 #define EAP_SIM_GENERAL_FAILURE_AFTER_AUTH 0
162 #define EAP_SIM_TEMPORARILY_DENIED 1026
163 #define EAP_SIM_NOT_SUBSCRIBED 1031
164 #define EAP_SIM_GENERAL_FAILURE_BEFORE_AUTH 16384
165 #define EAP_SIM_SUCCESS 32768
168 #define EAP_AKA_PRIME_KDF 1
171 #define EAP_AKA_BIDDING_FLAG_D 0x8000
174 enum eap_sim_id_req {
175 NO_ID_REQ, ANY_ID, FULLAUTH_ID, PERMANENT_ID
180 const u8 *rand, *autn, *mac, *iv, *encr_data, *version_list, *nonce_s;
181 const u8 *next_pseudonym, *next_reauth_id;
182 const u8 *nonce_mt, *identity, *res, *auts;
186 size_t num_chal, version_list_len, encr_data_len;
187 size_t next_pseudonym_len, next_reauth_id_len, identity_len, res_len;
189 size_t checkcode_len;
190 size_t kdf_input_len;
191 enum eap_sim_id_req id_req;
192 int notification, counter, selected_version, client_error_code;
193 int counter_too_small;
195 #define EAP_AKA_PRIME_KDF_MAX 10
196 u16 kdf[EAP_AKA_PRIME_KDF_MAX];
200 int eap_sim_parse_attr(
const u8 *start,
const u8 *end,
202 u8 * eap_sim_parse_encr(
const u8 *k_encr,
const u8 *encr_data,
203 size_t encr_data_len,
const u8 *iv,
209 struct eap_sim_msg * eap_sim_msg_init(
int code,
int id,
int type,
int subtype);
212 const u8 *extra,
size_t extra_len);
214 u8 * eap_sim_msg_add_full(
struct eap_sim_msg *msg, u8 attr,
215 const u8 *data,
size_t len);
216 u8 * eap_sim_msg_add(
struct eap_sim_msg *msg, u8 attr,
217 u16 value,
const u8 *data,
size_t len);
218 u8 * eap_sim_msg_add_mac(
struct eap_sim_msg *msg, u8 attr);
219 int eap_sim_msg_add_encr_start(
struct eap_sim_msg *msg, u8 attr_iv,
221 int eap_sim_msg_add_encr_end(
struct eap_sim_msg *msg, u8 *k_encr,
224 void eap_sim_report_notification(
void *msg_ctx,
int notification,
int aka);
Definition: eap_sim_common.c:968
Definition: eap_sim_common.h:179