• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hostapd / EAP-SIM database/authenticator gateway
3  * Copyright (c) 2005-2007, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef EAP_SIM_DB_H
10 #define EAP_SIM_DB_H
11 
12 #include "eap_common/eap_sim_common.h"
13 
14 /* Identity prefixes */
15 #define EAP_SIM_PERMANENT_PREFIX '1'
16 #define EAP_SIM_PSEUDONYM_PREFIX '3'
17 #define EAP_SIM_REAUTH_ID_PREFIX '5'
18 #define EAP_AKA_PERMANENT_PREFIX '0'
19 #define EAP_AKA_PSEUDONYM_PREFIX '2'
20 #define EAP_AKA_REAUTH_ID_PREFIX '4'
21 
22 void * eap_sim_db_init(const char *config,
23 		       void (*get_complete_cb)(void *ctx, void *session_ctx),
24 		       void *ctx);
25 
26 void eap_sim_db_deinit(void *priv);
27 
28 int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
29 				size_t identity_len, int max_chal,
30 				u8 *_rand, u8 *kc, u8 *sres,
31 				void *cb_session_ctx);
32 
33 #define EAP_SIM_DB_FAILURE -1
34 #define EAP_SIM_DB_PENDING -2
35 
36 int eap_sim_db_identity_known(void *priv, const u8 *identity,
37 			      size_t identity_len);
38 
39 char * eap_sim_db_get_next_pseudonym(void *priv, int aka);
40 
41 char * eap_sim_db_get_next_reauth_id(void *priv, int aka);
42 
43 int eap_sim_db_add_pseudonym(void *priv, const u8 *identity,
44 			     size_t identity_len, char *pseudonym);
45 
46 int eap_sim_db_add_reauth(void *priv, const u8 *identity,
47 			  size_t identity_len, char *reauth_id, u16 counter,
48 			  const u8 *mk);
49 int eap_sim_db_add_reauth_prime(void *priv, const u8 *identity,
50 				size_t identity_len, char *reauth_id,
51 				u16 counter, const u8 *k_encr, const u8 *k_aut,
52 				const u8 *k_re);
53 
54 const u8 * eap_sim_db_get_permanent(void *priv, const u8 *identity,
55 				    size_t identity_len, size_t *len);
56 
57 struct eap_sim_reauth {
58 	struct eap_sim_reauth *next;
59 	u8 *identity;
60 	size_t identity_len;
61 	char *reauth_id;
62 	u16 counter;
63 	int aka_prime;
64 	u8 mk[EAP_SIM_MK_LEN];
65 	u8 k_encr[EAP_SIM_K_ENCR_LEN];
66 	u8 k_aut[EAP_AKA_PRIME_K_AUT_LEN];
67 	u8 k_re[EAP_AKA_PRIME_K_RE_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 #endif /* EAP_SIM_DB_H */
86