Disconnect hostapd from building in base
[dragonfly.git] / contrib / hostapd / src / eap_server / eap_sim_db.h
CommitLineData
ebfa2275
SZ
1/*
2 * hostapd / EAP-SIM database/authenticator gateway
4781064b 3 * Copyright (c) 2005-2008, 2012, Jouni Malinen <j@w1.fi>
ebfa2275 4 *
4781064b
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
ebfa2275
SZ
7 */
8
9#ifndef EAP_SIM_DB_H
10#define EAP_SIM_DB_H
11
a875087d 12#include "eap_common/eap_sim_common.h"
ebfa2275
SZ
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'
4781064b
JM
21#define EAP_AKA_PRIME_PERMANENT_PREFIX '6'
22#define EAP_AKA_PRIME_PSEUDONYM_PREFIX '7'
23#define EAP_AKA_PRIME_REAUTH_ID_PREFIX '8'
24
25enum eap_sim_db_method {
26 EAP_SIM_DB_SIM,
27 EAP_SIM_DB_AKA,
28 EAP_SIM_DB_AKA_PRIME
29};
30
31struct eap_sim_db_data;
ebfa2275 32
4781064b
JM
33struct eap_sim_db_data *
34eap_sim_db_init(const char *config,
35 void (*get_complete_cb)(void *ctx, void *session_ctx),
36 void *ctx);
ebfa2275
SZ
37
38void eap_sim_db_deinit(void *priv);
39
4781064b
JM
40int eap_sim_db_get_gsm_triplets(struct eap_sim_db_data *data,
41 const char *username, int max_chal,
ebfa2275
SZ
42 u8 *_rand, u8 *kc, u8 *sres,
43 void *cb_session_ctx);
44
45#define EAP_SIM_DB_FAILURE -1
46#define EAP_SIM_DB_PENDING -2
47
4781064b
JM
48char * eap_sim_db_get_next_pseudonym(struct eap_sim_db_data *data,
49 enum eap_sim_db_method method);
ebfa2275 50
4781064b
JM
51char * eap_sim_db_get_next_reauth_id(struct eap_sim_db_data *data,
52 enum eap_sim_db_method method);
ebfa2275 53
4781064b
JM
54int eap_sim_db_add_pseudonym(struct eap_sim_db_data *data,
55 const char *permanent, char *pseudonym);
ebfa2275 56
4781064b
JM
57int eap_sim_db_add_reauth(struct eap_sim_db_data *data, const char *permanent,
58 char *reauth_id, u16 counter, const u8 *mk);
59int eap_sim_db_add_reauth_prime(struct eap_sim_db_data *data,
60 const char *permanent,
61 char *reauth_id, u16 counter, const u8 *k_encr,
62 const u8 *k_aut, const u8 *k_re);
ebfa2275 63
4781064b
JM
64const char * eap_sim_db_get_permanent(struct eap_sim_db_data *data,
65 const char *pseudonym);
ebfa2275
SZ
66
67struct eap_sim_reauth {
68 struct eap_sim_reauth *next;
4781064b
JM
69 char *permanent; /* Permanent username */
70 char *reauth_id; /* Fast re-authentication username */
ebfa2275
SZ
71 u16 counter;
72 u8 mk[EAP_SIM_MK_LEN];
a875087d
JL
73 u8 k_encr[EAP_SIM_K_ENCR_LEN];
74 u8 k_aut[EAP_AKA_PRIME_K_AUT_LEN];
75 u8 k_re[EAP_AKA_PRIME_K_RE_LEN];
ebfa2275
SZ
76};
77
78struct eap_sim_reauth *
4781064b
JM
79eap_sim_db_get_reauth_entry(struct eap_sim_db_data *data,
80 const char *reauth_id);
ebfa2275 81
4781064b
JM
82void eap_sim_db_remove_reauth(struct eap_sim_db_data *data,
83 struct eap_sim_reauth *reauth);
ebfa2275 84
4781064b
JM
85int eap_sim_db_get_aka_auth(struct eap_sim_db_data *data, const char *username,
86 u8 *_rand, u8 *autn, u8 *ik, u8 *ck,
87 u8 *res, size_t *res_len, void *cb_session_ctx);
ebfa2275 88
4781064b
JM
89int eap_sim_db_resynchronize(struct eap_sim_db_data *data,
90 const char *username, const u8 *auts,
ebfa2275
SZ
91 const u8 *_rand);
92
4781064b 93char * sim_get_username(const u8 *identity, size_t identity_len);
ebfa2275
SZ
94
95#endif /* EAP_SIM_DB_H */