wpa_supplicant: update vendor branch to 0.6.10
[dragonfly.git] / contrib / hostapd / eap_sim_db.h
1 /*
2  * hostapd / EAP-SIM database/authenticator gateway
3  * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
4  *
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.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef EAP_SIM_DB_H
16 #define EAP_SIM_DB_H
17
18 #ifdef EAP_SIM
19
20 #include "eap_sim_common.h"
21
22 /* Identity prefixes */
23 #define EAP_SIM_PERMANENT_PREFIX '1'
24 #define EAP_SIM_PSEUDONYM_PREFIX '3'
25 #define EAP_SIM_REAUTH_ID_PREFIX '5'
26 #define EAP_AKA_PERMANENT_PREFIX '0'
27 #define EAP_AKA_PSEUDONYM_PREFIX '2'
28 #define EAP_AKA_REAUTH_ID_PREFIX '4'
29
30 void * eap_sim_db_init(const char *config,
31                        void (*get_complete_cb)(void *ctx, void *session_ctx),
32                        void *ctx);
33
34 void eap_sim_db_deinit(void *priv);
35
36 int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
37                                 size_t identity_len, int max_chal,
38                                 u8 *_rand, u8 *kc, u8 *sres,
39                                 void *cb_session_ctx);
40
41 #define EAP_SIM_DB_FAILURE -1
42 #define EAP_SIM_DB_PENDING -2
43
44 int eap_sim_db_identity_known(void *priv, const u8 *identity,
45                               size_t identity_len);
46
47 char * eap_sim_db_get_next_pseudonym(void *priv, int aka);
48
49 char * eap_sim_db_get_next_reauth_id(void *priv, int aka);
50
51 int eap_sim_db_add_pseudonym(void *priv, const u8 *identity,
52                              size_t identity_len, char *pseudonym);
53
54 int eap_sim_db_add_reauth(void *priv, const u8 *identity,
55                           size_t identity_len, char *reauth_id, u16 counter,
56                           const u8 *mk);
57
58 const u8 * eap_sim_db_get_permanent(void *priv, const u8 *identity,
59                                     size_t identity_len, size_t *len);
60
61 struct eap_sim_reauth {
62         struct eap_sim_reauth *next;
63         u8 *identity;
64         size_t identity_len;
65         char *reauth_id;
66         u16 counter;
67         u8 mk[EAP_SIM_MK_LEN];
68 };
69
70 struct eap_sim_reauth *
71 eap_sim_db_get_reauth_entry(void *priv, const u8 *identity,
72                             size_t identity_len);
73
74 void eap_sim_db_remove_reauth(void *priv, struct eap_sim_reauth *reauth);
75
76 int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
77                             size_t identity_len, u8 *_rand, u8 *autn, u8 *ik,
78                             u8 *ck, u8 *res, size_t *res_len,
79                             void *cb_session_ctx);
80
81 int eap_sim_db_resynchronize(void *priv, const u8 *identity,
82                              size_t identity_len, const u8 *auts,
83                              const u8 *_rand);
84
85 #else /* EAP_SIM */
86 static inline void *
87 eap_sim_db_init(const char *config,
88                 void (*get_complete_cb)(void *ctx, void *session_ctx),
89                 void *ctx)
90 {
91         return (void *) 1;
92 }
93
94 static inline void eap_sim_db_deinit(void *priv)
95 {
96 }
97 #endif /* EAP_SIM */
98
99 #endif /* EAP_SIM_DB_H */