1 /* 2 * hostapd / EAP-SIM database/authenticator gateway 3 * Copyright (c) 2005-2007, Jouni Malinen <j (at) 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 #include "eap_common/eap_sim_common.h" 19 20 /* Identity prefixes */ 21 #define EAP_SIM_PERMANENT_PREFIX '1' 22 #define EAP_SIM_PSEUDONYM_PREFIX '3' 23 #define EAP_SIM_REAUTH_ID_PREFIX '5' 24 #define EAP_AKA_PERMANENT_PREFIX '0' 25 #define EAP_AKA_PSEUDONYM_PREFIX '2' 26 #define EAP_AKA_REAUTH_ID_PREFIX '4' 27 28 void * eap_sim_db_init(const char *config, 29 void (*get_complete_cb)(void *ctx, void *session_ctx), 30 void *ctx); 31 32 void eap_sim_db_deinit(void *priv); 33 34 int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity, 35 size_t identity_len, int max_chal, 36 u8 *_rand, u8 *kc, u8 *sres, 37 void *cb_session_ctx); 38 39 #define EAP_SIM_DB_FAILURE -1 40 #define EAP_SIM_DB_PENDING -2 41 42 int eap_sim_db_identity_known(void *priv, const u8 *identity, 43 size_t identity_len); 44 45 char * eap_sim_db_get_next_pseudonym(void *priv, int aka); 46 47 char * eap_sim_db_get_next_reauth_id(void *priv, int aka); 48 49 int eap_sim_db_add_pseudonym(void *priv, const u8 *identity, 50 size_t identity_len, char *pseudonym); 51 52 int eap_sim_db_add_reauth(void *priv, const u8 *identity, 53 size_t identity_len, char *reauth_id, u16 counter, 54 const u8 *mk); 55 int eap_sim_db_add_reauth_prime(void *priv, const u8 *identity, 56 size_t identity_len, char *reauth_id, 57 u16 counter, const u8 *k_encr, const u8 *k_aut, 58 const u8 *k_re); 59 60 const u8 * eap_sim_db_get_permanent(void *priv, const u8 *identity, 61 size_t identity_len, size_t *len); 62 63 struct eap_sim_reauth { 64 struct eap_sim_reauth *next; 65 u8 *identity; 66 size_t identity_len; 67 char *reauth_id; 68 u16 counter; 69 int aka_prime; 70 u8 mk[EAP_SIM_MK_LEN]; 71 u8 k_encr[EAP_SIM_K_ENCR_LEN]; 72 u8 k_aut[EAP_AKA_PRIME_K_AUT_LEN]; 73 u8 k_re[EAP_AKA_PRIME_K_RE_LEN]; 74 }; 75 76 struct eap_sim_reauth * 77 eap_sim_db_get_reauth_entry(void *priv, const u8 *identity, 78 size_t identity_len); 79 80 void eap_sim_db_remove_reauth(void *priv, struct eap_sim_reauth *reauth); 81 82 int eap_sim_db_get_aka_auth(void *priv, const u8 *identity, 83 size_t identity_len, u8 *_rand, u8 *autn, u8 *ik, 84 u8 *ck, u8 *res, size_t *res_len, 85 void *cb_session_ctx); 86 87 int eap_sim_db_resynchronize(void *priv, const u8 *identity, 88 size_t identity_len, const u8 *auts, 89 const u8 *_rand); 90 91 #endif /* EAP_SIM_DB_H */ 92