Home | History | Annotate | Download | only in eap_server
      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 #ifdef EAP_SIM
     19 
     20 #include "eap_common/eap_sim_common.h"
     21 
     22 /* Identity prefixes */
     23 #define EAP_SIM_PERMANENT_PREFIX '1'
     24 #define EAP_SIM_PSEUDONYM_PREFIX '3'
     25 #define EAP_SIM_REAUTH_ID_PREFIX '5'
     26 #define EAP_AKA_PERMANENT_PREFIX '0'
     27 #define EAP_AKA_PSEUDONYM_PREFIX '2'
     28 #define EAP_AKA_REAUTH_ID_PREFIX '4'
     29 
     30 void * eap_sim_db_init(const char *config,
     31 		       void (*get_complete_cb)(void *ctx, void *session_ctx),
     32 		       void *ctx);
     33 
     34 void eap_sim_db_deinit(void *priv);
     35 
     36 int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
     37 				size_t identity_len, int max_chal,
     38 				u8 *_rand, u8 *kc, u8 *sres,
     39 				void *cb_session_ctx);
     40 
     41 #define EAP_SIM_DB_FAILURE -1
     42 #define EAP_SIM_DB_PENDING -2
     43 
     44 int eap_sim_db_identity_known(void *priv, const u8 *identity,
     45 			      size_t identity_len);
     46 
     47 char * eap_sim_db_get_next_pseudonym(void *priv, int aka);
     48 
     49 char * eap_sim_db_get_next_reauth_id(void *priv, int aka);
     50 
     51 int eap_sim_db_add_pseudonym(void *priv, const u8 *identity,
     52 			     size_t identity_len, char *pseudonym);
     53 
     54 int eap_sim_db_add_reauth(void *priv, const u8 *identity,
     55 			  size_t identity_len, char *reauth_id, u16 counter,
     56 			  const u8 *mk);
     57 int eap_sim_db_add_reauth_prime(void *priv, const u8 *identity,
     58 				size_t identity_len, char *reauth_id,
     59 				u16 counter, const u8 *k_encr, const u8 *k_aut,
     60 				const u8 *k_re);
     61 
     62 const u8 * eap_sim_db_get_permanent(void *priv, const u8 *identity,
     63 				    size_t identity_len, size_t *len);
     64 
     65 struct eap_sim_reauth {
     66 	struct eap_sim_reauth *next;
     67 	u8 *identity;
     68 	size_t identity_len;
     69 	char *reauth_id;
     70 	u16 counter;
     71 	int aka_prime;
     72 	u8 mk[EAP_SIM_MK_LEN];
     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];
     76 };
     77 
     78 struct eap_sim_reauth *
     79 eap_sim_db_get_reauth_entry(void *priv, const u8 *identity,
     80 			    size_t identity_len);
     81 
     82 void eap_sim_db_remove_reauth(void *priv, struct eap_sim_reauth *reauth);
     83 
     84 int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
     85 			    size_t identity_len, u8 *_rand, u8 *autn, u8 *ik,
     86 			    u8 *ck, u8 *res, size_t *res_len,
     87 			    void *cb_session_ctx);
     88 
     89 int eap_sim_db_resynchronize(void *priv, const u8 *identity,
     90 			     size_t identity_len, const u8 *auts,
     91 			     const u8 *_rand);
     92 
     93 #else /* EAP_SIM */
     94 static inline void *
     95 eap_sim_db_init(const char *config,
     96 		void (*get_complete_cb)(void *ctx, void *session_ctx),
     97 		void *ctx)
     98 {
     99 	return (void *) 1;
    100 }
    101 
    102 static inline void eap_sim_db_deinit(void *priv)
    103 {
    104 }
    105 #endif /* EAP_SIM */
    106 
    107 #endif /* EAP_SIM_DB_H */
    108