2008-02-28 02:34:43 +01:00
|
|
|
/*
|
|
|
|
* hostapd / EAP-SIM database/authenticator gateway
|
2012-05-02 19:45:01 +02:00
|
|
|
* Copyright (c) 2005-2008, 2012, Jouni Malinen <j@w1.fi>
|
2008-02-28 02:34:43 +01:00
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EAP_SIM_DB_H
|
|
|
|
#define EAP_SIM_DB_H
|
|
|
|
|
|
|
|
#include "eap_common/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'
|
2012-05-02 19:45:01 +02:00
|
|
|
#define EAP_AKA_PRIME_PERMANENT_PREFIX '6'
|
|
|
|
#define EAP_AKA_PRIME_PSEUDONYM_PREFIX '7'
|
|
|
|
#define EAP_AKA_PRIME_REAUTH_ID_PREFIX '8'
|
|
|
|
|
|
|
|
enum eap_sim_db_method {
|
|
|
|
EAP_SIM_DB_SIM,
|
|
|
|
EAP_SIM_DB_AKA,
|
|
|
|
EAP_SIM_DB_AKA_PRIME
|
|
|
|
};
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
struct eap_sim_db_data;
|
|
|
|
|
|
|
|
struct eap_sim_db_data *
|
2015-06-10 13:15:24 +02:00
|
|
|
eap_sim_db_init(const char *config, unsigned int db_timeout,
|
2012-09-01 20:48:48 +02:00
|
|
|
void (*get_complete_cb)(void *ctx, void *session_ctx),
|
|
|
|
void *ctx);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
void eap_sim_db_deinit(void *priv);
|
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
int eap_sim_db_get_gsm_triplets(struct eap_sim_db_data *data,
|
|
|
|
const char *username, int max_chal,
|
2008-02-28 02:34:43 +01:00
|
|
|
u8 *_rand, u8 *kc, u8 *sres,
|
|
|
|
void *cb_session_ctx);
|
|
|
|
|
|
|
|
#define EAP_SIM_DB_FAILURE -1
|
|
|
|
#define EAP_SIM_DB_PENDING -2
|
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
char * eap_sim_db_get_next_pseudonym(struct eap_sim_db_data *data,
|
2012-05-02 19:45:01 +02:00
|
|
|
enum eap_sim_db_method method);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
char * eap_sim_db_get_next_reauth_id(struct eap_sim_db_data *data,
|
2012-05-02 19:45:01 +02:00
|
|
|
enum eap_sim_db_method method);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
int eap_sim_db_add_pseudonym(struct eap_sim_db_data *data,
|
|
|
|
const char *permanent, char *pseudonym);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
int eap_sim_db_add_reauth(struct eap_sim_db_data *data, const char *permanent,
|
|
|
|
char *reauth_id, u16 counter, const u8 *mk);
|
|
|
|
int eap_sim_db_add_reauth_prime(struct eap_sim_db_data *data,
|
|
|
|
const char *permanent,
|
2012-09-01 20:10:19 +02:00
|
|
|
char *reauth_id, u16 counter, const u8 *k_encr,
|
|
|
|
const u8 *k_aut, const u8 *k_re);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
const char * eap_sim_db_get_permanent(struct eap_sim_db_data *data,
|
|
|
|
const char *pseudonym);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
struct eap_sim_reauth {
|
|
|
|
struct eap_sim_reauth *next;
|
2012-09-01 20:10:19 +02:00
|
|
|
char *permanent; /* Permanent username */
|
|
|
|
char *reauth_id; /* Fast re-authentication username */
|
2008-02-28 02:34:43 +01:00
|
|
|
u16 counter;
|
|
|
|
u8 mk[EAP_SIM_MK_LEN];
|
2008-12-03 18:22:20 +01:00
|
|
|
u8 k_encr[EAP_SIM_K_ENCR_LEN];
|
|
|
|
u8 k_aut[EAP_AKA_PRIME_K_AUT_LEN];
|
|
|
|
u8 k_re[EAP_AKA_PRIME_K_RE_LEN];
|
2008-02-28 02:34:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct eap_sim_reauth *
|
2012-09-01 20:48:48 +02:00
|
|
|
eap_sim_db_get_reauth_entry(struct eap_sim_db_data *data,
|
|
|
|
const char *reauth_id);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
void eap_sim_db_remove_reauth(struct eap_sim_db_data *data,
|
|
|
|
struct eap_sim_reauth *reauth);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
int eap_sim_db_get_aka_auth(struct eap_sim_db_data *data, const char *username,
|
|
|
|
u8 *_rand, u8 *autn, u8 *ik, u8 *ck,
|
|
|
|
u8 *res, size_t *res_len, void *cb_session_ctx);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2012-09-01 20:48:48 +02:00
|
|
|
int eap_sim_db_resynchronize(struct eap_sim_db_data *data,
|
|
|
|
const char *username, const u8 *auts,
|
2008-02-28 02:34:43 +01:00
|
|
|
const u8 *_rand);
|
|
|
|
|
2012-09-01 18:10:33 +02:00
|
|
|
char * sim_get_username(const u8 *identity, size_t identity_len);
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
#endif /* EAP_SIM_DB_H */
|