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