Rename the new cvsup bootstrap kit so make nrelease knows a new one
[dfdiff.git] / contrib / hostapd-0.4.9 / eap_sim_common.h
blob6715c369c0b6517602616b0258e6ffef4ae044dd
1 /*
2 * WPA Supplicant / EAP-SIM/AKA shared routines
3 * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #ifndef EAP_SIM_COMMON_H
16 #define EAP_SIM_COMMON_H
18 #define EAP_SIM_NONCE_S_LEN 16
19 #define EAP_SIM_NONCE_MT_LEN 16
20 #define EAP_SIM_MAC_LEN 16
21 #define EAP_SIM_MK_LEN 20
22 #define EAP_SIM_K_AUT_LEN 16
23 #define EAP_SIM_K_ENCR_LEN 16
24 #define EAP_SIM_KEYING_DATA_LEN 64
25 #define EAP_SIM_IV_LEN 16
27 #define GSM_RAND_LEN 16
29 #define AKA_RAND_LEN 16
30 #define AKA_AUTN_LEN 16
32 void eap_sim_derive_keys(const u8 *mk, u8 *k_encr, u8 *k_aut, u8 *msk);
33 void eap_sim_derive_keys_reauth(u16 _counter,
34 const u8 *identity, size_t identity_len,
35 const u8 *nonce_s, const u8 *mk, u8 *msk);
36 int eap_sim_verify_mac(const u8 *k_aut, const u8 *req, size_t req_len,
37 const u8 *mac, const u8 *extra, size_t extra_len);
38 void eap_sim_add_mac(const u8 *k_aut, u8 *msg, size_t msg_len, u8 *mac,
39 const u8 *extra, size_t extra_len);
42 /* EAP-SIM/AKA Attributes (0..127 non-skippable) */
43 #define EAP_SIM_AT_RAND 1
44 #define EAP_SIM_AT_AUTN 2 /* only AKA */
45 #define EAP_SIM_AT_RES 3 /* only AKA, only send */
46 #define EAP_SIM_AT_AUTS 4 /* only AKA, only send */
47 #define EAP_SIM_AT_PADDING 6 /* only encrypted */
48 #define EAP_SIM_AT_NONCE_MT 7 /* only SIM, only send */
49 #define EAP_SIM_AT_PERMANENT_ID_REQ 10
50 #define EAP_SIM_AT_MAC 11
51 #define EAP_SIM_AT_NOTIFICATION 12
52 #define EAP_SIM_AT_ANY_ID_REQ 13
53 #define EAP_SIM_AT_IDENTITY 14 /* only send */
54 #define EAP_SIM_AT_VERSION_LIST 15 /* only SIM */
55 #define EAP_SIM_AT_SELECTED_VERSION 16 /* only SIM */
56 #define EAP_SIM_AT_FULLAUTH_ID_REQ 17
57 #define EAP_SIM_AT_COUNTER 19 /* only encrypted */
58 #define EAP_SIM_AT_COUNTER_TOO_SMALL 20 /* only encrypted */
59 #define EAP_SIM_AT_NONCE_S 21 /* only encrypted */
60 #define EAP_SIM_AT_CLIENT_ERROR_CODE 22 /* only send */
61 #define EAP_SIM_AT_IV 129
62 #define EAP_SIM_AT_ENCR_DATA 130
63 #define EAP_SIM_AT_NEXT_PSEUDONYM 132 /* only encrypted */
64 #define EAP_SIM_AT_NEXT_REAUTH_ID 133 /* only encrypted */
65 #define EAP_SIM_AT_CHECKCODE 134 /* only AKA */
66 #define EAP_SIM_AT_RESULT_IND 135
68 /* AT_NOTIFICATION notification code values */
69 #define EAP_SIM_GENERAL_FAILURE_AFTER_AUTH 0
70 #define EAP_SIM_TEMPORARILY_DENIED 1026
71 #define EAP_SIM_NOT_SUBSCRIBED 1031
72 #define EAP_SIM_GENERAL_FAILURE_BEFORE_AUTH 16384
73 #define EAP_SIM_SUCCESS 32768
76 enum eap_sim_id_req {
77 NO_ID_REQ, ANY_ID, FULLAUTH_ID, PERMANENT_ID
81 struct eap_sim_attrs {
82 const u8 *rand, *autn, *mac, *iv, *encr_data, *version_list, *nonce_s;
83 const u8 *next_pseudonym, *next_reauth_id;
84 const u8 *nonce_mt, *identity;
85 size_t num_chal, version_list_len, encr_data_len;
86 size_t next_pseudonym_len, next_reauth_id_len, identity_len;
87 enum eap_sim_id_req id_req;
88 int notification, counter, selected_version, client_error_code;
91 int eap_sim_parse_attr(const u8 *start, const u8 *end,
92 struct eap_sim_attrs *attr, int aka, int encr);
93 u8 * eap_sim_parse_encr(const u8 *k_encr, const u8 *encr_data,
94 size_t encr_data_len, const u8 *iv,
95 struct eap_sim_attrs *attr, int aka);
98 struct eap_sim_msg;
100 struct eap_sim_msg * eap_sim_msg_init(int code, int id, int type, int subtype);
101 u8 * eap_sim_msg_finish(struct eap_sim_msg *msg, size_t *len, const u8 *k_aut,
102 const u8 *extra, size_t extra_len);
103 void eap_sim_msg_free(struct eap_sim_msg *msg);
104 u8 * eap_sim_msg_add_full(struct eap_sim_msg *msg, u8 attr,
105 const u8 *data, size_t len);
106 u8 * eap_sim_msg_add(struct eap_sim_msg *msg, u8 attr,
107 u16 value, const u8 *data, size_t len);
108 u8 * eap_sim_msg_add_mac(struct eap_sim_msg *msg, u8 attr);
109 int eap_sim_msg_add_encr_start(struct eap_sim_msg *msg, u8 attr_iv,
110 u8 attr_encr);
111 int eap_sim_msg_add_encr_end(struct eap_sim_msg *msg, u8 *k_encr,
112 int attr_pad);
114 void eap_sim_report_notification(void *msg_ctx, int notification, int aka);
116 #endif /* EAP_SIM_COMMON_H */