00001
00016 #ifndef EAP_SIM_DB_H
00017 #define EAP_SIM_DB_H
00018
00019 #if defined(EAP_SERVER_SIM) || defined(EAP_SERVER_AKA)
00020
00021 #include "eap_common/eap_sim_common.h"
00022
00023
00024 #define EAP_SIM_PERMANENT_PREFIX '1'
00025 #define EAP_SIM_PSEUDONYM_PREFIX '3'
00026 #define EAP_SIM_REAUTH_ID_PREFIX '5'
00027 #define EAP_AKA_PERMANENT_PREFIX '0'
00028 #define EAP_AKA_PSEUDONYM_PREFIX '2'
00029 #define EAP_AKA_REAUTH_ID_PREFIX '4'
00030
00031 void * eap_sim_db_init(const char *config,
00032 void (*get_complete_cb)(void *ctx, void *session_ctx),
00033 void *ctx);
00034
00035 void eap_sim_db_deinit(void *priv);
00036
00037 int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
00038 size_t identity_len, int max_chal,
00039 u8 *_rand, u8 *kc, u8 *sres,
00040 void *cb_session_ctx);
00041
00042 #define EAP_SIM_DB_FAILURE -1
00043 #define EAP_SIM_DB_PENDING -2
00044
00045 int eap_sim_db_identity_known(void *priv, const u8 *identity,
00046 size_t identity_len);
00047
00048 char * eap_sim_db_get_next_pseudonym(void *priv, int aka);
00049
00050 char * eap_sim_db_get_next_reauth_id(void *priv, int aka);
00051
00052 int eap_sim_db_add_pseudonym(void *priv, const u8 *identity,
00053 size_t identity_len, char *pseudonym);
00054
00055 int eap_sim_db_add_reauth(void *priv, const u8 *identity,
00056 size_t identity_len, char *reauth_id, u16 counter,
00057 const u8 *mk);
00058 int eap_sim_db_add_reauth_prime(void *priv, const u8 *identity,
00059 size_t identity_len, char *reauth_id,
00060 u16 counter, const u8 *k_encr, const u8 *k_aut,
00061 const u8 *k_re);
00062
00063 const u8 * eap_sim_db_get_permanent(void *priv, const u8 *identity,
00064 size_t identity_len, size_t *len);
00065
00066 struct eap_sim_reauth {
00067 struct eap_sim_reauth *next;
00068 u8 *identity;
00069 size_t identity_len;
00070 char *reauth_id;
00071 u16 counter;
00072 int aka_prime;
00073 u8 mk[EAP_SIM_MK_LEN];
00074 u8 k_encr[EAP_SIM_K_ENCR_LEN];
00075 u8 k_aut[EAP_AKA_PRIME_K_AUT_LEN];
00076 u8 k_re[EAP_AKA_PRIME_K_RE_LEN];
00077 };
00078
00079 struct eap_sim_reauth *
00080 eap_sim_db_get_reauth_entry(void *priv, const u8 *identity,
00081 size_t identity_len);
00082
00083 void eap_sim_db_remove_reauth(void *priv, struct eap_sim_reauth *reauth);
00084
00085 int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
00086 size_t identity_len, u8 *_rand, u8 *autn, u8 *ik,
00087 u8 *ck, u8 *res, size_t *res_len,
00088 void *cb_session_ctx);
00089
00090 int eap_sim_db_resynchronize(void *priv, const u8 *identity,
00091 size_t identity_len, const u8 *auts,
00092 const u8 *_rand);
00093
00094 #else
00095 static inline void *
00096 eap_sim_db_init(const char *config,
00097 void (*get_complete_cb)(void *ctx, void *session_ctx),
00098 void *ctx)
00099 {
00100 return (void *) 1;
00101 }
00102
00103 static inline void eap_sim_db_deinit(void *priv)
00104 {
00105 }
00106 #endif
00107
00108 #endif
00109