Migrated all SIM/AKA code to libsimaka, use SIM and AKA backend managers registered by name
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <simaka_message.h>
|
||||
#include <simaka_crypto.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
typedef struct private_eap_aka_peer_t private_eap_aka_peer_t;
|
||||
|
||||
@@ -33,6 +34,11 @@ struct private_eap_aka_peer_t {
|
||||
*/
|
||||
eap_aka_peer_t public;
|
||||
|
||||
/**
|
||||
* AKA backend manager
|
||||
*/
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
/**
|
||||
* EAP-AKA crypto helper
|
||||
*/
|
||||
@@ -91,7 +97,7 @@ static eap_payload_t* create_client_error(private_eap_aka_peer_t *this)
|
||||
encoded = htons(AKA_UNABLE_TO_PROCESS);
|
||||
message->add_attribute(message, AT_CLIENT_ERROR_CODE,
|
||||
chunk_create((char*)&encoded, sizeof(encoded)));
|
||||
out = message->generate(message, chunk_empty);
|
||||
out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
return out;
|
||||
}
|
||||
@@ -140,7 +146,7 @@ static status_t process_identity(private_eap_aka_peer_t *this,
|
||||
switch (id_req)
|
||||
{
|
||||
case AT_ANY_ID_REQ:
|
||||
this->reauth = charon->sim->card_get_reauth(charon->sim,
|
||||
this->reauth = this->mgr->card_get_reauth(this->mgr,
|
||||
this->permanent, this->mk, &this->counter);
|
||||
if (this->reauth)
|
||||
{
|
||||
@@ -149,8 +155,8 @@ static status_t process_identity(private_eap_aka_peer_t *this,
|
||||
}
|
||||
/* FALL */
|
||||
case AT_FULLAUTH_ID_REQ:
|
||||
this->pseudonym = charon->sim->card_get_pseudonym(charon->sim,
|
||||
this->permanent);
|
||||
this->pseudonym = this->mgr->card_get_pseudonym(this->mgr,
|
||||
this->permanent);
|
||||
if (this->pseudonym)
|
||||
{
|
||||
id = this->pseudonym->get_encoding(this->pseudonym);
|
||||
@@ -169,7 +175,7 @@ static status_t process_identity(private_eap_aka_peer_t *this,
|
||||
{
|
||||
message->add_attribute(message, AT_IDENTITY, id);
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
return NEED_MORE;
|
||||
@@ -220,10 +226,10 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
status = charon->sim->card_get_quintuplet(charon->sim, this->permanent,
|
||||
status = this->mgr->card_get_quintuplet(this->mgr, this->permanent,
|
||||
rand.ptr, autn.ptr, ck, ik, res, &res_len);
|
||||
if (status == INVALID_STATE &&
|
||||
charon->sim->card_resync(charon->sim, this->permanent, rand.ptr, auts))
|
||||
this->mgr->card_resync(this->mgr, this->permanent, rand.ptr, auts))
|
||||
{
|
||||
DBG1(DBG_IKE, "received SQN invalid, sending %N",
|
||||
simaka_subtype_names, AKA_SYNCHRONIZATION_FAILURE);
|
||||
@@ -231,7 +237,8 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
|
||||
AKA_SYNCHRONIZATION_FAILURE, this->crypto);
|
||||
message->add_attribute(message, AT_AUTS,
|
||||
chunk_create(auts, AKA_AUTS_LEN));
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message,
|
||||
chunk_empty));
|
||||
message->destroy(message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -241,7 +248,8 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
|
||||
this->permanent, simaka_subtype_names, AKA_AUTHENTICATION_REJECT);
|
||||
message = simaka_message_create(FALSE, in->get_identifier(in), EAP_AKA,
|
||||
AKA_AUTHENTICATION_REJECT, this->crypto);
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message,
|
||||
chunk_empty));
|
||||
message->destroy(message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -274,13 +282,13 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
|
||||
case AT_NEXT_REAUTH_ID:
|
||||
this->counter = 0;
|
||||
id = identification_create_from_data(data);
|
||||
charon->sim->card_set_reauth(charon->sim, this->permanent, id,
|
||||
this->mk, this->counter);
|
||||
this->mgr->card_set_reauth(this->mgr, this->permanent, id,
|
||||
this->mk, this->counter);
|
||||
id->destroy(id);
|
||||
break;
|
||||
case AT_NEXT_PSEUDONYM:
|
||||
id = identification_create_from_data(data);
|
||||
charon->sim->card_set_pseudonym(charon->sim, this->permanent, id);
|
||||
this->mgr->card_set_pseudonym(this->mgr, this->permanent, id);
|
||||
id->destroy(id);
|
||||
break;
|
||||
default:
|
||||
@@ -292,7 +300,7 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
|
||||
message = simaka_message_create(FALSE, this->identifier, EAP_AKA,
|
||||
AKA_CHALLENGE, this->crypto);
|
||||
message->add_attribute(message, AT_RES, chunk_create(res, res_len));
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -389,13 +397,13 @@ static status_t process_reauthentication(private_eap_aka_peer_t *this,
|
||||
identification_t *reauth;
|
||||
|
||||
reauth = identification_create_from_data(data);
|
||||
charon->sim->card_set_reauth(charon->sim, this->permanent, reauth,
|
||||
this->mk, this->counter);
|
||||
this->mgr->card_set_reauth(this->mgr, this->permanent, reauth,
|
||||
this->mk, this->counter);
|
||||
reauth->destroy(reauth);
|
||||
}
|
||||
}
|
||||
message->add_attribute(message, AT_COUNTER, counter);
|
||||
*out = message->generate(message, nonce);
|
||||
*out = eap_payload_create_data_own(message->generate(message, nonce));
|
||||
message->destroy(message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -446,7 +454,8 @@ static status_t process_notification(private_eap_aka_peer_t *this,
|
||||
{ /* empty notification reply */
|
||||
message = simaka_message_create(FALSE, this->identifier, EAP_AKA,
|
||||
AKA_NOTIFICATION, this->crypto);
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message,
|
||||
chunk_empty));
|
||||
message->destroy(message);
|
||||
}
|
||||
else
|
||||
@@ -466,7 +475,7 @@ METHOD(eap_method_t, process, status_t,
|
||||
/* store received EAP message identifier */
|
||||
this->identifier = in->get_identifier(in);
|
||||
|
||||
message = simaka_message_create_from_payload(in, this->crypto);
|
||||
message = simaka_message_create_from_payload(in->get_data(in), this->crypto);
|
||||
if (!message)
|
||||
{
|
||||
*out = create_client_error(this);
|
||||
@@ -578,7 +587,8 @@ eap_aka_peer_t *eap_aka_peer_create(identification_t *server,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.crypto = simaka_crypto_create(),
|
||||
.crypto = simaka_crypto_create(EAP_AKA),
|
||||
.mgr = lib->get(lib, "aka-manager"),
|
||||
);
|
||||
|
||||
if (!this->crypto)
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct eap_aka_peer_t eap_aka_peer_t;
|
||||
#include <sa/authenticators/eap/eap_method.h>
|
||||
|
||||
/**
|
||||
* Implementation of the eap_method_t interface using EAP-AKA as a client.
|
||||
* EAP-AKA peer implementation.
|
||||
*/
|
||||
struct eap_aka_peer_t {
|
||||
|
||||
|
||||
@@ -19,20 +19,41 @@
|
||||
#include "eap_aka_server.h"
|
||||
|
||||
#include <daemon.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
typedef struct private_eap_aka_plugin_t private_eap_aka_plugin_t;
|
||||
|
||||
/**
|
||||
* Private data of an eap_sim_plugin_t object.
|
||||
*/
|
||||
struct private_eap_aka_plugin_t {
|
||||
|
||||
/**
|
||||
* Public interface.
|
||||
*/
|
||||
eap_aka_plugin_t public;
|
||||
|
||||
/**
|
||||
* EAP-AKA backend manager
|
||||
*/
|
||||
simaka_manager_t *mgr;
|
||||
};
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
eap_aka_plugin_t *this)
|
||||
private_eap_aka_plugin_t *this)
|
||||
{
|
||||
return "eap-aka";
|
||||
}
|
||||
|
||||
METHOD(plugin_t, destroy, void,
|
||||
eap_aka_plugin_t *this)
|
||||
private_eap_aka_plugin_t *this)
|
||||
{
|
||||
lib->set(lib, "aka-manager", NULL);
|
||||
charon->eap->remove_method(charon->eap,
|
||||
(eap_constructor_t)eap_aka_server_create);
|
||||
charon->eap->remove_method(charon->eap,
|
||||
(eap_constructor_t)eap_aka_peer_create);
|
||||
this->mgr->destroy(this->mgr);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -41,21 +62,24 @@ METHOD(plugin_t, destroy, void,
|
||||
*/
|
||||
plugin_t *eap_aka_plugin_create()
|
||||
{
|
||||
eap_aka_plugin_t *this;
|
||||
private_eap_aka_plugin_t *this;
|
||||
|
||||
INIT(this,
|
||||
.plugin = {
|
||||
.get_name = _get_name,
|
||||
.reload = (void*)return_false,
|
||||
.destroy = _destroy,
|
||||
.public = {
|
||||
.plugin = {
|
||||
.get_name = _get_name,
|
||||
.reload = (void*)return_false,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.mgr = simaka_manager_create(),
|
||||
);
|
||||
|
||||
charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_SERVER,
|
||||
(eap_constructor_t)eap_aka_server_create);
|
||||
charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_PEER,
|
||||
(eap_constructor_t)eap_aka_peer_create);
|
||||
lib->set(lib, "aka-manager", this->mgr);
|
||||
|
||||
return &this->plugin;
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ typedef struct eap_aka_plugin_t eap_aka_plugin_t;
|
||||
*
|
||||
* EAP-AKA uses 3rd generation mobile phone standard authentication
|
||||
* mechanism for authentication, as defined RFC4187.
|
||||
*
|
||||
* This plugin implements the protocol level of EAP-AKA and uses simaka_card_t
|
||||
* and simaka_provider_t backends to provide triplets. It registers a
|
||||
* simaka_manager_t on the library as "aka-manager", other plugins can use it
|
||||
* to provide the required backends.
|
||||
*/
|
||||
struct eap_aka_plugin_t {
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <simaka_message.h>
|
||||
#include <simaka_crypto.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
/** length of the AT_NONCE_S value */
|
||||
#define NONCE_LEN 16
|
||||
@@ -36,6 +37,11 @@ struct private_eap_aka_server_t {
|
||||
*/
|
||||
eap_aka_server_t public;
|
||||
|
||||
/**
|
||||
* AKA backend manager
|
||||
*/
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
/**
|
||||
* EAP-AKA crypto helper
|
||||
*/
|
||||
@@ -133,7 +139,7 @@ static status_t identity(private_eap_aka_server_t *this, eap_payload_t **out)
|
||||
{
|
||||
message->add_attribute(message, AT_PERMANENT_ID_REQ, chunk_empty);
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
this->pending = AKA_IDENTITY;
|
||||
@@ -152,7 +158,7 @@ static status_t challenge(private_eap_aka_server_t *this, eap_payload_t **out)
|
||||
chunk_t data, mk;
|
||||
identification_t *id;
|
||||
|
||||
if (!charon->sim->provider_get_quintuplet(charon->sim, this->permanent,
|
||||
if (!this->mgr->provider_get_quintuplet(this->mgr, this->permanent,
|
||||
rand, xres, &xres_len, ck, ik, autn))
|
||||
{
|
||||
if (this->use_pseudonym)
|
||||
@@ -183,7 +189,7 @@ static status_t challenge(private_eap_aka_server_t *this, eap_payload_t **out)
|
||||
AKA_CHALLENGE, this->crypto);
|
||||
message->add_attribute(message, AT_RAND, this->rand);
|
||||
message->add_attribute(message, AT_AUTN, chunk_create(autn, AKA_AUTN_LEN));
|
||||
id = charon->sim->provider_gen_reauth(charon->sim, this->permanent, mk.ptr);
|
||||
id = this->mgr->provider_gen_reauth(this->mgr, this->permanent, mk.ptr);
|
||||
if (id)
|
||||
{
|
||||
message->add_attribute(message, AT_NEXT_REAUTH_ID,
|
||||
@@ -192,7 +198,7 @@ static status_t challenge(private_eap_aka_server_t *this, eap_payload_t **out)
|
||||
}
|
||||
else
|
||||
{
|
||||
id = charon->sim->provider_gen_pseudonym(charon->sim, this->permanent);
|
||||
id = this->mgr->provider_gen_pseudonym(this->mgr, this->permanent);
|
||||
if (id)
|
||||
{
|
||||
message->add_attribute(message, AT_NEXT_PSEUDONYM,
|
||||
@@ -200,7 +206,7 @@ static status_t challenge(private_eap_aka_server_t *this, eap_payload_t **out)
|
||||
id->destroy(id);
|
||||
}
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
free(mk.ptr);
|
||||
@@ -237,14 +243,14 @@ static status_t reauthenticate(private_eap_aka_server_t *this,
|
||||
AKA_REAUTHENTICATION, this->crypto);
|
||||
message->add_attribute(message, AT_COUNTER, this->counter);
|
||||
message->add_attribute(message, AT_NONCE_S, this->nonce);
|
||||
next = charon->sim->provider_gen_reauth(charon->sim, this->permanent, mk);
|
||||
next = this->mgr->provider_gen_reauth(this->mgr, this->permanent, mk);
|
||||
if (next)
|
||||
{
|
||||
message->add_attribute(message, AT_NEXT_REAUTH_ID,
|
||||
next->get_encoding(next));
|
||||
next->destroy(next);
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
this->pending = SIM_REAUTHENTICATION;
|
||||
@@ -310,8 +316,7 @@ static status_t process_identity(private_eap_aka_server_t *this,
|
||||
char mk[HASH_SIZE_SHA1];
|
||||
u_int16_t counter;
|
||||
|
||||
permanent = charon->sim->provider_is_reauth(charon->sim, id,
|
||||
mk, &counter);
|
||||
permanent = this->mgr->provider_is_reauth(this->mgr, id, mk, &counter);
|
||||
if (permanent)
|
||||
{
|
||||
this->permanent->destroy(this->permanent);
|
||||
@@ -325,7 +330,7 @@ static status_t process_identity(private_eap_aka_server_t *this,
|
||||
}
|
||||
if (this->use_pseudonym)
|
||||
{
|
||||
permanent = charon->sim->provider_is_pseudonym(charon->sim, id);
|
||||
permanent = this->mgr->provider_is_pseudonym(this->mgr, id);
|
||||
if (permanent)
|
||||
{
|
||||
this->permanent->destroy(this->permanent);
|
||||
@@ -506,8 +511,8 @@ static status_t process_synchronize(private_eap_aka_server_t *this,
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (!charon->sim->provider_resync(charon->sim, this->permanent,
|
||||
this->rand.ptr, auts.ptr))
|
||||
if (!this->mgr->provider_resync(this->mgr, this->permanent,
|
||||
this->rand.ptr, auts.ptr))
|
||||
{
|
||||
DBG1(DBG_IKE, "no AKA provider found supporting "
|
||||
"resynchronization for '%Y'", this->permanent);
|
||||
@@ -564,7 +569,7 @@ METHOD(eap_method_t, process, status_t,
|
||||
simaka_message_t *message;
|
||||
status_t status;
|
||||
|
||||
message = simaka_message_create_from_payload(in, this->crypto);
|
||||
message = simaka_message_create_from_payload(in->get_data(in), this->crypto);
|
||||
if (!message)
|
||||
{
|
||||
return FAILED;
|
||||
@@ -676,7 +681,8 @@ eap_aka_server_t *eap_aka_server_create(identification_t *server,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.crypto = simaka_crypto_create(),
|
||||
.crypto = simaka_crypto_create(EAP_AKA),
|
||||
.mgr = lib->get(lib, "aka-manager"),
|
||||
);
|
||||
|
||||
if (!this->crypto)
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct eap_aka_server_t eap_aka_server_t;
|
||||
#include <sa/authenticators/eap/eap_method.h>
|
||||
|
||||
/**
|
||||
* Implementation of the eap_method_t interface using EAP-AKA as server.
|
||||
* EAP-AKA server implementation.
|
||||
*/
|
||||
struct eap_aka_server_t {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
-I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
|
||||
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ bool eap_aka_3gpp2_get_k(identification_t *id, char k[AKA_K_LEN]);
|
||||
void eap_aka_3gpp2_get_sqn(char sqn[AKA_SQN_LEN], int offset);
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_quintuplet
|
||||
* Implementation of simaka_card_t.get_quintuplet
|
||||
*/
|
||||
static status_t get_quintuplet(private_eap_aka_3gpp2_card_t *this,
|
||||
identification_t *id, char rand[AKA_RAND_LEN],
|
||||
@@ -113,7 +113,7 @@ static status_t get_quintuplet(private_eap_aka_3gpp2_card_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.resync
|
||||
* Implementation of simaka_card_t.resync
|
||||
*/
|
||||
static bool resync(private_eap_aka_3gpp2_card_t *this, identification_t *id,
|
||||
char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN])
|
||||
@@ -153,13 +153,13 @@ eap_aka_3gpp2_card_t *eap_aka_3gpp2_card_create(eap_aka_3gpp2_functions_t *f)
|
||||
{
|
||||
private_eap_aka_3gpp2_card_t *this = malloc_thing(private_eap_aka_3gpp2_card_t);
|
||||
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.card.get_quintuplet = (status_t(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
|
||||
this->public.card.get_pseudonym = (identification_t*(*)(sim_card_t*, identification_t *id))return_null;
|
||||
this->public.card.set_pseudonym = (void(*)(sim_card_t*, identification_t *id, identification_t *pseudonym))nop;
|
||||
this->public.card.get_reauth = (identification_t*(*)(sim_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.card.set_reauth = (void(*)(sim_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))nop;
|
||||
this->public.card.get_triplet = (bool(*)(simaka_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.card.get_quintuplet = (status_t(*)(simaka_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(simaka_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
|
||||
this->public.card.get_pseudonym = (identification_t*(*)(simaka_card_t*, identification_t *id))return_null;
|
||||
this->public.card.set_pseudonym = (void(*)(simaka_card_t*, identification_t *id, identification_t *pseudonym))nop;
|
||||
this->public.card.get_reauth = (identification_t*(*)(simaka_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.card.set_reauth = (void(*)(simaka_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))nop;
|
||||
this->public.destroy = (void(*)(eap_aka_3gpp2_card_t*))destroy;
|
||||
|
||||
this->f = f;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "eap_aka_3gpp2_functions.h"
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_card.h>
|
||||
|
||||
typedef struct eap_aka_3gpp2_card_t eap_aka_3gpp2_card_t;
|
||||
|
||||
@@ -33,9 +33,9 @@ typedef struct eap_aka_3gpp2_card_t eap_aka_3gpp2_card_t;
|
||||
struct eap_aka_3gpp2_card_t {
|
||||
|
||||
/**
|
||||
* Implements sim_card_t interface
|
||||
* Implements simaka_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
simaka_card_t card;
|
||||
|
||||
/**
|
||||
* Destroy a eap_aka_3gpp2_card_t.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef EAP_AKA_3GPP2_FUNCTIONS_H_
|
||||
#define EAP_AKA_3GPP2_FUNCTIONS_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
#define AKA_SQN_LEN 6
|
||||
#define AKA_K_LEN 16
|
||||
|
||||
@@ -57,8 +57,14 @@ METHOD(plugin_t, get_name, char*,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_eap_aka_3gpp2_t *this)
|
||||
{
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
charon->sim->remove_provider(charon->sim, &this->provider->provider);
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
this->card->destroy(this->card);
|
||||
this->provider->destroy(this->provider);
|
||||
this->functions->destroy(this->functions);
|
||||
@@ -71,6 +77,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *eap_aka_3gpp2_plugin_create()
|
||||
{
|
||||
private_eap_aka_3gpp2_t *this;
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -91,9 +98,12 @@ plugin_t *eap_aka_3gpp2_plugin_create()
|
||||
this->card = eap_aka_3gpp2_card_create(this->functions);
|
||||
this->provider = eap_aka_3gpp2_provider_create(this->functions);
|
||||
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
charon->sim->add_provider(charon->sim, &this->provider->provider);
|
||||
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void eap_aka_3gpp2_get_sqn(char sqn[AKA_SQN_LEN], int offset)
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of usim_provider_t.get_quintuplet
|
||||
* Implementation of simaka_provider_t.get_quintuplet
|
||||
*/
|
||||
static bool get_quintuplet(private_eap_aka_3gpp2_provider_t *this,
|
||||
identification_t *id, char rand[AKA_RAND_LEN],
|
||||
@@ -132,7 +132,7 @@ static bool get_quintuplet(private_eap_aka_3gpp2_provider_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of usim_provider_t.resync
|
||||
* Implementation of simaka_provider_t.resync
|
||||
*/
|
||||
static bool resync(private_eap_aka_3gpp2_provider_t *this,
|
||||
identification_t *id, char rand[AKA_RAND_LEN],
|
||||
@@ -185,13 +185,13 @@ eap_aka_3gpp2_provider_t *eap_aka_3gpp2_provider_create(
|
||||
{
|
||||
private_eap_aka_3gpp2_provider_t *this = malloc_thing(private_eap_aka_3gpp2_provider_t);
|
||||
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))get_quintuplet;
|
||||
this->public.provider.resync = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
|
||||
this->public.provider.is_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.gen_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.is_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.provider.gen_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
|
||||
this->public.provider.get_triplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.provider.get_quintuplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))get_quintuplet;
|
||||
this->public.provider.resync = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
|
||||
this->public.provider.is_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.gen_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.is_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.provider.gen_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
|
||||
this->public.destroy = (void(*)(eap_aka_3gpp2_provider_t*))destroy;
|
||||
|
||||
this->f = f;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "eap_aka_3gpp2_functions.h"
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_provider.h>
|
||||
|
||||
typedef struct eap_aka_3gpp2_provider_t eap_aka_3gpp2_provider_t;
|
||||
|
||||
@@ -33,9 +33,9 @@ typedef struct eap_aka_3gpp2_provider_t eap_aka_3gpp2_provider_t;
|
||||
struct eap_aka_3gpp2_provider_t {
|
||||
|
||||
/**
|
||||
* Implements sim_provider_t interface.
|
||||
* Implements simaka_provider_t interface.
|
||||
*/
|
||||
sim_provider_t provider;
|
||||
simaka_provider_t provider;
|
||||
|
||||
/**
|
||||
* Destroy a eap_aka_3gpp2_provider_t.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <daemon.h>
|
||||
|
||||
#include <simaka_message.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
/* number of tries we do authenticate */
|
||||
#define MAX_TRIES 3
|
||||
@@ -40,6 +41,11 @@ struct private_eap_sim_peer_t {
|
||||
*/
|
||||
eap_sim_peer_t public;
|
||||
|
||||
/**
|
||||
* SIM backend manager
|
||||
*/
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
/**
|
||||
* permanent ID of peer
|
||||
*/
|
||||
@@ -116,7 +122,7 @@ static eap_payload_t* create_client_error(private_eap_sim_peer_t *this,
|
||||
encoded = htons(code);
|
||||
message->add_attribute(message, AT_CLIENT_ERROR_CODE,
|
||||
chunk_create((char*)&encoded, sizeof(encoded)));
|
||||
out = message->generate(message, chunk_empty);
|
||||
out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
return out;
|
||||
}
|
||||
@@ -188,7 +194,7 @@ static status_t process_start(private_eap_sim_peer_t *this,
|
||||
switch (id_req)
|
||||
{
|
||||
case AT_ANY_ID_REQ:
|
||||
this->reauth = charon->sim->card_get_reauth(charon->sim,
|
||||
this->reauth = this->mgr->card_get_reauth(this->mgr,
|
||||
this->permanent, this->mk, &this->counter);
|
||||
if (this->reauth)
|
||||
{
|
||||
@@ -197,8 +203,8 @@ static status_t process_start(private_eap_sim_peer_t *this,
|
||||
}
|
||||
/* FALL */
|
||||
case AT_FULLAUTH_ID_REQ:
|
||||
this->pseudonym = charon->sim->card_get_pseudonym(charon->sim,
|
||||
this->permanent);
|
||||
this->pseudonym = this->mgr->card_get_pseudonym(this->mgr,
|
||||
this->permanent);
|
||||
if (this->pseudonym)
|
||||
{
|
||||
id = this->pseudonym->get_encoding(this->pseudonym);
|
||||
@@ -228,7 +234,7 @@ static status_t process_start(private_eap_sim_peer_t *this,
|
||||
{
|
||||
message->add_attribute(message, AT_IDENTITY, id);
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
return NEED_MORE;
|
||||
@@ -287,8 +293,8 @@ static status_t process_challenge(private_eap_sim_peer_t *this,
|
||||
sreses = sres = chunk_alloca(rands.len / 4);
|
||||
while (rands.len >= SIM_RAND_LEN)
|
||||
{
|
||||
if (!charon->sim->card_get_triplet(charon->sim, this->permanent,
|
||||
rands.ptr, sres.ptr, kc.ptr))
|
||||
if (!this->mgr->card_get_triplet(this->mgr, this->permanent,
|
||||
rands.ptr, sres.ptr, kc.ptr))
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to get EAP-SIM triplet");
|
||||
*out = create_client_error(this, SIM_UNABLE_TO_PROCESS);
|
||||
@@ -328,13 +334,13 @@ static status_t process_challenge(private_eap_sim_peer_t *this,
|
||||
case AT_NEXT_REAUTH_ID:
|
||||
this->counter = 0;
|
||||
id = identification_create_from_data(data);
|
||||
charon->sim->card_set_reauth(charon->sim, this->permanent, id,
|
||||
this->mk, this->counter);
|
||||
this->mgr->card_set_reauth(this->mgr, this->permanent, id,
|
||||
this->mk, this->counter);
|
||||
id->destroy(id);
|
||||
break;
|
||||
case AT_NEXT_PSEUDONYM:
|
||||
id = identification_create_from_data(data);
|
||||
charon->sim->card_set_pseudonym(charon->sim, this->permanent, id);
|
||||
this->mgr->card_set_pseudonym(this->mgr, this->permanent, id);
|
||||
id->destroy(id);
|
||||
break;
|
||||
default:
|
||||
@@ -346,7 +352,7 @@ static status_t process_challenge(private_eap_sim_peer_t *this,
|
||||
/* build response with AT_MAC, built over "EAP packet | n*SRES" */
|
||||
message = simaka_message_create(FALSE, this->identifier, EAP_SIM,
|
||||
SIM_CHALLENGE, this->crypto);
|
||||
*out = message->generate(message, sreses);
|
||||
*out = eap_payload_create_data_own(message->generate(message, sreses));
|
||||
message->destroy(message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -443,13 +449,13 @@ static status_t process_reauthentication(private_eap_sim_peer_t *this,
|
||||
identification_t *reauth;
|
||||
|
||||
reauth = identification_create_from_data(data);
|
||||
charon->sim->card_set_reauth(charon->sim, this->permanent, reauth,
|
||||
this->mk, this->counter);
|
||||
this->mgr->card_set_reauth(this->mgr, this->permanent, reauth,
|
||||
this->mk, this->counter);
|
||||
reauth->destroy(reauth);
|
||||
}
|
||||
}
|
||||
message->add_attribute(message, AT_COUNTER, counter);
|
||||
*out = message->generate(message, nonce);
|
||||
*out = eap_payload_create_data_own(message->generate(message, nonce));
|
||||
message->destroy(message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -500,7 +506,8 @@ static status_t process_notification(private_eap_sim_peer_t *this,
|
||||
{ /* empty notification reply */
|
||||
message = simaka_message_create(FALSE, this->identifier, EAP_SIM,
|
||||
SIM_NOTIFICATION, this->crypto);
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message,
|
||||
chunk_empty));
|
||||
message->destroy(message);
|
||||
}
|
||||
else
|
||||
@@ -519,7 +526,7 @@ METHOD(eap_method_t, process, status_t,
|
||||
/* store received EAP message identifier */
|
||||
this->identifier = in->get_identifier(in);
|
||||
|
||||
message = simaka_message_create_from_payload(in, this->crypto);
|
||||
message = simaka_message_create_from_payload(in->get_data(in), this->crypto);
|
||||
if (!message)
|
||||
{
|
||||
*out = create_client_error(this, SIM_UNABLE_TO_PROCESS);
|
||||
@@ -633,7 +640,8 @@ eap_sim_peer_t *eap_sim_peer_create(identification_t *server,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.crypto = simaka_crypto_create(),
|
||||
.crypto = simaka_crypto_create(EAP_SIM),
|
||||
.mgr = lib->get(lib, "sim-manager"),
|
||||
);
|
||||
|
||||
if (!this->crypto)
|
||||
|
||||
@@ -27,9 +27,6 @@ typedef struct eap_sim_peer_t eap_sim_peer_t;
|
||||
|
||||
/**
|
||||
* EAP-SIM peer implementation.
|
||||
*
|
||||
* This EAP-SIM module uses sim_card_t implementations for triplet calculation,
|
||||
* found via the eap_sim_manager_t.
|
||||
*/
|
||||
struct eap_sim_peer_t {
|
||||
|
||||
|
||||
@@ -19,20 +19,41 @@
|
||||
#include "eap_sim_peer.h"
|
||||
|
||||
#include <daemon.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
typedef struct private_eap_sim_plugin_t private_eap_sim_plugin_t;
|
||||
|
||||
/**
|
||||
* Private data of an eap_sim_plugin_t object.
|
||||
*/
|
||||
struct private_eap_sim_plugin_t {
|
||||
|
||||
/**
|
||||
* Public interface.
|
||||
*/
|
||||
eap_sim_plugin_t public;
|
||||
|
||||
/**
|
||||
* EAP-SIM backend manager
|
||||
*/
|
||||
simaka_manager_t *mgr;
|
||||
};
|
||||
|
||||
METHOD(plugin_t, get_name, char*,
|
||||
eap_sim_plugin_t *this)
|
||||
private_eap_sim_plugin_t *this)
|
||||
{
|
||||
return "eap-sim";
|
||||
}
|
||||
|
||||
METHOD(plugin_t, destroy, void,
|
||||
eap_sim_plugin_t *this)
|
||||
private_eap_sim_plugin_t *this)
|
||||
{
|
||||
lib->set(lib, "sim-manager", NULL);
|
||||
charon->eap->remove_method(charon->eap,
|
||||
(eap_constructor_t)eap_sim_server_create);
|
||||
charon->eap->remove_method(charon->eap,
|
||||
(eap_constructor_t)eap_sim_peer_create);
|
||||
this->mgr->destroy(this->mgr);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -41,21 +62,25 @@ METHOD(plugin_t, destroy, void,
|
||||
*/
|
||||
plugin_t *eap_sim_plugin_create()
|
||||
{
|
||||
eap_sim_plugin_t *this;
|
||||
private_eap_sim_plugin_t *this;
|
||||
|
||||
INIT(this,
|
||||
.plugin = {
|
||||
.get_name = _get_name,
|
||||
.reload = (void*)return_false,
|
||||
.destroy = _destroy,
|
||||
.public = {
|
||||
.plugin = {
|
||||
.get_name = _get_name,
|
||||
.reload = (void*)return_false,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.mgr = simaka_manager_create(),
|
||||
);
|
||||
|
||||
charon->eap->add_method(charon->eap, EAP_SIM, 0, EAP_SERVER,
|
||||
(eap_constructor_t)eap_sim_server_create);
|
||||
charon->eap->add_method(charon->eap, EAP_SIM, 0, EAP_PEER,
|
||||
(eap_constructor_t)eap_sim_peer_create);
|
||||
lib->set(lib, "sim-manager", this->mgr);
|
||||
|
||||
return &this->plugin;
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ typedef struct eap_sim_plugin_t eap_sim_plugin_t;
|
||||
|
||||
/**
|
||||
* EAP-SIM plugin.
|
||||
*
|
||||
* This plugin implements the protocol level of EAP-SIM and uses simaka_card_t
|
||||
* and simaka_provider_t backends to provide triplets. It registers a
|
||||
* simaka_manager_t on the library as "sim-manager", other plugins can use it
|
||||
* to provide the required backends.
|
||||
*/
|
||||
struct eap_sim_plugin_t {
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <simaka_message.h>
|
||||
#include <simaka_crypto.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
/* number of triplets for one authentication */
|
||||
#define TRIPLET_COUNT 3
|
||||
@@ -38,6 +39,11 @@ struct private_eap_sim_server_t {
|
||||
*/
|
||||
eap_sim_server_t public;
|
||||
|
||||
/**
|
||||
* SIM backend manager
|
||||
*/
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
/**
|
||||
* permanent ID of peer
|
||||
*/
|
||||
@@ -127,7 +133,7 @@ METHOD(eap_method_t, initiate, status_t,
|
||||
{
|
||||
message->add_attribute(message, AT_PERMANENT_ID_REQ, chunk_empty);
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
this->pending = SIM_START;
|
||||
@@ -163,14 +169,14 @@ static status_t reauthenticate(private_eap_sim_server_t *this,
|
||||
SIM_REAUTHENTICATION, this->crypto);
|
||||
message->add_attribute(message, AT_COUNTER, this->counter);
|
||||
message->add_attribute(message, AT_NONCE_S, this->nonce);
|
||||
next = charon->sim->provider_gen_reauth(charon->sim, this->permanent, mk);
|
||||
next = this->mgr->provider_gen_reauth(this->mgr, this->permanent, mk);
|
||||
if (next)
|
||||
{
|
||||
message->add_attribute(message, AT_NEXT_REAUTH_ID,
|
||||
next->get_encoding(next));
|
||||
next->destroy(next);
|
||||
}
|
||||
*out = message->generate(message, chunk_empty);
|
||||
*out = eap_payload_create_data_own(message->generate(message, chunk_empty));
|
||||
message->destroy(message);
|
||||
|
||||
this->pending = SIM_REAUTHENTICATION;
|
||||
@@ -298,8 +304,8 @@ static status_t process_start(private_eap_sim_server_t *this,
|
||||
char mk[HASH_SIZE_SHA1];
|
||||
u_int16_t counter;
|
||||
|
||||
permanent = charon->sim->provider_is_reauth(charon->sim, id,
|
||||
mk, &counter);
|
||||
permanent = this->mgr->provider_is_reauth(this->mgr, id,
|
||||
mk, &counter);
|
||||
if (permanent)
|
||||
{
|
||||
this->permanent->destroy(this->permanent);
|
||||
@@ -315,7 +321,7 @@ static status_t process_start(private_eap_sim_server_t *this,
|
||||
}
|
||||
if (this->use_pseudonym)
|
||||
{
|
||||
permanent = charon->sim->provider_is_pseudonym(charon->sim, id);
|
||||
permanent = this->mgr->provider_is_pseudonym(this->mgr, id);
|
||||
if (permanent)
|
||||
{
|
||||
this->permanent->destroy(this->permanent);
|
||||
@@ -348,8 +354,8 @@ static status_t process_start(private_eap_sim_server_t *this,
|
||||
rands.len = kcs.len = sreses.len = 0;
|
||||
for (i = 0; i < TRIPLET_COUNT; i++)
|
||||
{
|
||||
if (!charon->sim->provider_get_triplet(charon->sim, this->permanent,
|
||||
rand.ptr, sres.ptr, kc.ptr))
|
||||
if (!this->mgr->provider_get_triplet(this->mgr, this->permanent,
|
||||
rand.ptr, sres.ptr, kc.ptr))
|
||||
{
|
||||
if (this->use_pseudonym)
|
||||
{
|
||||
@@ -386,7 +392,7 @@ static status_t process_start(private_eap_sim_server_t *this,
|
||||
message = simaka_message_create(TRUE, this->identifier++, EAP_SIM,
|
||||
SIM_CHALLENGE, this->crypto);
|
||||
message->add_attribute(message, AT_RAND, rands);
|
||||
id = charon->sim->provider_gen_reauth(charon->sim, this->permanent, mk.ptr);
|
||||
id = this->mgr->provider_gen_reauth(this->mgr, this->permanent, mk.ptr);
|
||||
if (id)
|
||||
{
|
||||
message->add_attribute(message, AT_NEXT_REAUTH_ID,
|
||||
@@ -395,7 +401,7 @@ static status_t process_start(private_eap_sim_server_t *this,
|
||||
}
|
||||
else
|
||||
{
|
||||
id = charon->sim->provider_gen_pseudonym(charon->sim, this->permanent);
|
||||
id = this->mgr->provider_gen_pseudonym(this->mgr, this->permanent);
|
||||
if (id)
|
||||
{
|
||||
message->add_attribute(message, AT_NEXT_PSEUDONYM,
|
||||
@@ -403,7 +409,7 @@ static status_t process_start(private_eap_sim_server_t *this,
|
||||
id->destroy(id);
|
||||
}
|
||||
}
|
||||
*out = message->generate(message, nonce);
|
||||
*out = eap_payload_create_data_own(message->generate(message, nonce));
|
||||
message->destroy(message);
|
||||
|
||||
free(mk.ptr);
|
||||
@@ -483,7 +489,7 @@ METHOD(eap_method_t, process, status_t,
|
||||
simaka_message_t *message;
|
||||
status_t status;
|
||||
|
||||
message = simaka_message_create_from_payload(in, this->crypto);
|
||||
message = simaka_message_create_from_payload(in->get_data(in), this->crypto);
|
||||
if (!message)
|
||||
{
|
||||
return FAILED;
|
||||
@@ -588,7 +594,8 @@ eap_sim_server_t *eap_sim_server_create(identification_t *server,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.crypto = simaka_crypto_create(),
|
||||
.crypto = simaka_crypto_create(EAP_SIM),
|
||||
.mgr = lib->get(lib, "sim-manager"),
|
||||
);
|
||||
|
||||
if (!this->crypto)
|
||||
|
||||
@@ -27,9 +27,6 @@ typedef struct eap_sim_server_t eap_sim_server_t;
|
||||
|
||||
/**
|
||||
* EAP-SIM server implementation.
|
||||
*
|
||||
* This EAP-SIM module uses sim_provider_t implementations for triplet
|
||||
* calculation, found via the eap_sim_manager_t.
|
||||
*/
|
||||
struct eap_sim_server_t {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
-I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
|
||||
|
||||
AM_CFLAGS = -rdynamic -DIPSEC_CONFDIR=\"${sysconfdir}\"
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct private_eap_sim_file_card_t {
|
||||
eap_sim_file_triplets_t *triplets;
|
||||
};
|
||||
|
||||
METHOD(sim_card_t, get_triplet, bool,
|
||||
METHOD(simaka_card_t, get_triplet, bool,
|
||||
private_eap_sim_file_card_t *this, identification_t *id,
|
||||
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
|
||||
{
|
||||
@@ -66,7 +66,7 @@ METHOD(sim_card_t, get_triplet, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(sim_card_t, get_quintuplet, status_t,
|
||||
METHOD(simaka_card_t, get_quintuplet, status_t,
|
||||
private_eap_sim_file_card_t *this, identification_t *id,
|
||||
char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN],
|
||||
char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "eap_sim_file_triplets.h"
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_card.h>
|
||||
|
||||
typedef struct eap_sim_file_card_t eap_sim_file_card_t;
|
||||
|
||||
@@ -33,9 +33,9 @@ typedef struct eap_sim_file_card_t eap_sim_file_card_t;
|
||||
struct eap_sim_file_card_t {
|
||||
|
||||
/**
|
||||
* Implements sim_card_t interface
|
||||
* Implements simaka_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
simaka_card_t card;
|
||||
|
||||
/**
|
||||
* Destroy a eap_sim_file_card_t.
|
||||
|
||||
@@ -59,8 +59,14 @@ METHOD(plugin_t, get_name, char*,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_eap_sim_file_t *this)
|
||||
{
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
charon->sim->remove_provider(charon->sim, &this->provider->provider);
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
this->card->destroy(this->card);
|
||||
this->provider->destroy(this->provider);
|
||||
this->triplets->destroy(this->triplets);
|
||||
@@ -73,6 +79,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *eap_sim_file_plugin_create()
|
||||
{
|
||||
private_eap_sim_file_t *this;
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -94,9 +101,12 @@ plugin_t *eap_sim_file_plugin_create()
|
||||
}
|
||||
this->card = eap_sim_file_card_create(this->triplets);
|
||||
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
charon->sim->add_provider(charon->sim, &this->provider->provider);
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct private_eap_sim_file_provider_t {
|
||||
eap_sim_file_triplets_t *triplets;
|
||||
};
|
||||
|
||||
METHOD(sim_provider_t, get_triplet, bool,
|
||||
METHOD(simaka_provider_t, get_triplet, bool,
|
||||
private_eap_sim_file_provider_t *this, identification_t *id,
|
||||
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "eap_sim_file_triplets.h"
|
||||
|
||||
#include <simaka_provider.h>
|
||||
|
||||
typedef struct eap_sim_file_provider_t eap_sim_file_provider_t;
|
||||
|
||||
/**
|
||||
@@ -31,9 +33,9 @@ typedef struct eap_sim_file_provider_t eap_sim_file_provider_t;
|
||||
struct eap_sim_file_provider_t {
|
||||
|
||||
/**
|
||||
* Implements sim_provider_t interface.
|
||||
* Implements simaka_provider_t interface.
|
||||
*/
|
||||
sim_provider_t provider;
|
||||
simaka_provider_t provider;
|
||||
|
||||
/**
|
||||
* Destroy a eap_sim_file_provider_t.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <daemon.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <threading/mutex.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
typedef struct private_eap_sim_file_triplets_t private_eap_sim_file_triplets_t;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef EAP_SIM_FILE_TRIPLETS_H_
|
||||
#define EAP_SIM_FILE_TRIPLETS_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <utils/enumerator.h>
|
||||
|
||||
typedef struct eap_sim_file_triplets_t eap_sim_file_triplets_t;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
-I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
|
||||
|
||||
AM_CFLAGS = -rdynamic ${pcsclite_CFLAGS}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ static bool decode_imsi_ef(unsigned char *input, int input_len, char *output)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(sim_card_t, get_triplet, bool,
|
||||
METHOD(simaka_card_t, get_triplet, bool,
|
||||
private_eap_sim_pcsc_card_t *this, identification_t *id,
|
||||
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
|
||||
{
|
||||
@@ -351,7 +351,7 @@ METHOD(sim_card_t, get_triplet, bool,
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(sim_card_t, get_quintuplet, status_t,
|
||||
METHOD(simaka_card_t, get_quintuplet, status_t,
|
||||
private_eap_sim_pcsc_card_t *this, identification_t *id,
|
||||
char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN],
|
||||
char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef EAP_SIM_PCSC_CARD_H_
|
||||
#define EAP_SIM_PCSC_CARD_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_card.h>
|
||||
|
||||
typedef struct eap_sim_pcsc_card_t eap_sim_pcsc_card_t;
|
||||
|
||||
@@ -30,9 +30,9 @@ typedef struct eap_sim_pcsc_card_t eap_sim_pcsc_card_t;
|
||||
struct eap_sim_pcsc_card_t {
|
||||
|
||||
/**
|
||||
* Implements sim_card_t interface
|
||||
* Implements simaka_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
simaka_card_t card;
|
||||
|
||||
/**
|
||||
* Destroy a eap_sim_pcsc_card_t.
|
||||
|
||||
@@ -44,7 +44,13 @@ METHOD(plugin_t, get_name, char*,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_eap_sim_pcsc_plugin_t *this)
|
||||
{
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
}
|
||||
this->card->destroy(this->card);
|
||||
free(this);
|
||||
}
|
||||
@@ -55,6 +61,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *eap_sim_pcsc_plugin_create()
|
||||
{
|
||||
private_eap_sim_pcsc_plugin_t *this;
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -66,8 +73,12 @@ plugin_t *eap_sim_pcsc_plugin_create()
|
||||
},
|
||||
.card = eap_sim_pcsc_card_create(),
|
||||
);
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
-I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
|
||||
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ static bool equals(identification_t *key1, identification_t *key2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_pseudonym
|
||||
* Implementation of simaka_card_t.get_pseudonym
|
||||
*/
|
||||
static identification_t *get_pseudonym(private_eap_simaka_pseudonym_card_t *this,
|
||||
identification_t *id)
|
||||
@@ -74,7 +74,7 @@ static identification_t *get_pseudonym(private_eap_simaka_pseudonym_card_t *this
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.set_pseudonym
|
||||
* Implementation of simaka_card_t.set_pseudonym
|
||||
*/
|
||||
static void set_pseudonym(private_eap_simaka_pseudonym_card_t *this,
|
||||
identification_t *id, identification_t *pseudonym)
|
||||
@@ -93,7 +93,7 @@ static void set_pseudonym(private_eap_simaka_pseudonym_card_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_quintuplet
|
||||
* Implementation of simaka_card_t.get_quintuplet
|
||||
*/
|
||||
static status_t get_quintuplet()
|
||||
{
|
||||
@@ -137,13 +137,13 @@ eap_simaka_pseudonym_card_t *eap_simaka_pseudonym_card_create()
|
||||
|
||||
this = malloc_thing(private_eap_simaka_pseudonym_card_t);
|
||||
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.card.get_quintuplet = (status_t(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.card.get_pseudonym = (identification_t*(*)(sim_card_t*, identification_t *perm))get_pseudonym;
|
||||
this->public.card.set_pseudonym = (void(*)(sim_card_t*, identification_t *id, identification_t *pseudonym))set_pseudonym;
|
||||
this->public.card.get_reauth = (identification_t*(*)(sim_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.card.set_reauth = (void(*)(sim_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))nop;
|
||||
this->public.card.get_triplet = (bool(*)(simaka_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.card.get_quintuplet = (status_t(*)(simaka_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(simaka_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.card.get_pseudonym = (identification_t*(*)(simaka_card_t*, identification_t *perm))get_pseudonym;
|
||||
this->public.card.set_pseudonym = (void(*)(simaka_card_t*, identification_t *id, identification_t *pseudonym))set_pseudonym;
|
||||
this->public.card.get_reauth = (identification_t*(*)(simaka_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.card.set_reauth = (void(*)(simaka_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))nop;
|
||||
this->public.destroy = (void(*)(eap_simaka_pseudonym_card_t*))destroy;
|
||||
|
||||
this->pseudonym = hashtable_create((void*)hash, (void*)equals, 0);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef EAP_SIMAKA_PSEUDONYM_CARD_H_
|
||||
#define EAP_SIMAKA_PSEUDONYM_CARD_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_card.h>
|
||||
|
||||
typedef struct eap_simaka_pseudonym_card_t eap_simaka_pseudonym_card_t;
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct eap_simaka_pseudonym_card_t eap_simaka_pseudonym_card_t;
|
||||
struct eap_simaka_pseudonym_card_t {
|
||||
|
||||
/**
|
||||
* Implements sim_card_t interface
|
||||
* Implements simaka_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
simaka_card_t card;
|
||||
|
||||
/**
|
||||
* Destroy a eap_simaka_pseudonym_card_t.
|
||||
|
||||
@@ -51,8 +51,20 @@ METHOD(plugin_t, get_name, char*,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_eap_simaka_pseudonym_t *this)
|
||||
{
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
charon->sim->remove_provider(charon->sim, &this->provider->provider);
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
this->card->destroy(this->card);
|
||||
this->provider->destroy(this->provider);
|
||||
free(this);
|
||||
@@ -64,6 +76,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *eap_simaka_pseudonym_plugin_create()
|
||||
{
|
||||
private_eap_simaka_pseudonym_t *this;
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -83,9 +96,18 @@ plugin_t *eap_simaka_pseudonym_plugin_create()
|
||||
}
|
||||
this->card = eap_simaka_pseudonym_card_create();
|
||||
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
charon->sim->add_provider(charon->sim, &this->provider->provider);
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ static bool equals(identification_t *key1, identification_t *key2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.is_pseudonym
|
||||
* Implementation of simaka_provider_t.is_pseudonym
|
||||
*/
|
||||
static identification_t* is_pseudonym(
|
||||
private_eap_simaka_pseudonym_provider_t *this, identification_t *id)
|
||||
@@ -92,7 +92,7 @@ static identification_t *gen_identity(
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.get_pseudonym
|
||||
* Implementation of simaka_provider_t.get_pseudonym
|
||||
*/
|
||||
static identification_t* gen_pseudonym(
|
||||
private_eap_simaka_pseudonym_provider_t *this, identification_t *id)
|
||||
@@ -159,13 +159,13 @@ eap_simaka_pseudonym_provider_t *eap_simaka_pseudonym_provider_create()
|
||||
|
||||
this = malloc_thing(private_eap_simaka_pseudonym_provider_t);
|
||||
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))return_false;
|
||||
this->public.provider.resync = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.provider.is_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))is_pseudonym;
|
||||
this->public.provider.gen_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))gen_pseudonym;
|
||||
this->public.provider.is_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.provider.gen_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
|
||||
this->public.provider.get_triplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.provider.get_quintuplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))return_false;
|
||||
this->public.provider.resync = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.provider.is_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))is_pseudonym;
|
||||
this->public.provider.gen_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))gen_pseudonym;
|
||||
this->public.provider.is_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.provider.gen_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
|
||||
this->public.destroy = (void(*)(eap_simaka_pseudonym_provider_t*))destroy;
|
||||
|
||||
this->rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef EAP_SIMAKA_PSEDUONYM_PROVIDER_H_
|
||||
#define EAP_SIMAKA_PSEDUONYM_PROVIDER_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_provider.h>
|
||||
|
||||
typedef struct eap_simaka_pseudonym_provider_t eap_simaka_pseudonym_provider_t;
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct eap_simaka_pseudonym_provider_t eap_simaka_pseudonym_provider_t;
|
||||
struct eap_simaka_pseudonym_provider_t {
|
||||
|
||||
/**
|
||||
* Implements sim_provider_t interface.
|
||||
* Implements simaka_provider_t interface.
|
||||
*/
|
||||
sim_provider_t provider;
|
||||
simaka_provider_t provider;
|
||||
|
||||
/**
|
||||
* Destroy a eap_simaka_pseudonym_provider_t.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
-I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
|
||||
|
||||
AM_CFLAGS = -rdynamic
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static bool equals(identification_t *key1, identification_t *key2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_reauth
|
||||
* Implementation of simaka_card_t.get_reauth
|
||||
*/
|
||||
static identification_t *get_reauth(private_eap_simaka_reauth_card_t *this,
|
||||
identification_t *id, char mk[HASH_SIZE_SHA1],
|
||||
@@ -91,7 +91,7 @@ static identification_t *get_reauth(private_eap_simaka_reauth_card_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.set_reauth
|
||||
* Implementation of simaka_card_t.set_reauth
|
||||
*/
|
||||
static void set_reauth(private_eap_simaka_reauth_card_t *this,
|
||||
identification_t *id, identification_t* next,
|
||||
@@ -116,7 +116,7 @@ static void set_reauth(private_eap_simaka_reauth_card_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_quintuplet
|
||||
* Implementation of simaka_card_t.get_quintuplet
|
||||
*/
|
||||
static status_t get_quintuplet()
|
||||
{
|
||||
@@ -154,13 +154,13 @@ eap_simaka_reauth_card_t *eap_simaka_reauth_card_create()
|
||||
|
||||
this = malloc_thing(private_eap_simaka_reauth_card_t);
|
||||
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_null;
|
||||
this->public.card.get_quintuplet = (status_t(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.card.get_pseudonym = (identification_t*(*)(sim_card_t*, identification_t *perm))return_null;
|
||||
this->public.card.set_pseudonym = (void(*)(sim_card_t*, identification_t *id, identification_t *pseudonym))nop;
|
||||
this->public.card.get_reauth = (identification_t*(*)(sim_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))get_reauth;
|
||||
this->public.card.set_reauth = (void(*)(sim_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))set_reauth;
|
||||
this->public.card.get_triplet = (bool(*)(simaka_card_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_null;
|
||||
this->public.card.get_quintuplet = (status_t(*)(simaka_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(simaka_card_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.card.get_pseudonym = (identification_t*(*)(simaka_card_t*, identification_t *perm))return_null;
|
||||
this->public.card.set_pseudonym = (void(*)(simaka_card_t*, identification_t *id, identification_t *pseudonym))nop;
|
||||
this->public.card.get_reauth = (identification_t*(*)(simaka_card_t*, identification_t *id, char mk[HASH_SIZE_SHA1], u_int16_t *counter))get_reauth;
|
||||
this->public.card.set_reauth = (void(*)(simaka_card_t*, identification_t *id, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))set_reauth;
|
||||
this->public.destroy = (void(*)(eap_simaka_reauth_card_t*))destroy;
|
||||
|
||||
this->reauth = hashtable_create((void*)hash, (void*)equals, 0);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef EAP_SIMAKA_REAUTH_CARD_H_
|
||||
#define EAP_SIMAKA_REAUTH_CARD_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_provider.h>
|
||||
|
||||
typedef struct eap_simaka_reauth_card_t eap_simaka_reauth_card_t;
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct eap_simaka_reauth_card_t eap_simaka_reauth_card_t;
|
||||
struct eap_simaka_reauth_card_t {
|
||||
|
||||
/**
|
||||
* Implements sim_card_t interface
|
||||
* Implements simaka_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
simaka_card_t card;
|
||||
|
||||
/**
|
||||
* Destroy a eap_simaka_reauth_card_t.
|
||||
|
||||
@@ -51,8 +51,20 @@ METHOD(plugin_t, get_name, char*,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_eap_simaka_reauth_t *this)
|
||||
{
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
charon->sim->remove_provider(charon->sim, &this->provider->provider);
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
this->card->destroy(this->card);
|
||||
this->provider->destroy(this->provider);
|
||||
free(this);
|
||||
@@ -64,6 +76,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *eap_simaka_reauth_plugin_create()
|
||||
{
|
||||
private_eap_simaka_reauth_t *this;
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -83,9 +96,18 @@ plugin_t *eap_simaka_reauth_plugin_create()
|
||||
}
|
||||
this->card = eap_simaka_reauth_card_create();
|
||||
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
charon->sim->add_provider(charon->sim, &this->provider->provider);
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ static identification_t *gen_identity(private_eap_simaka_reauth_provider_t *this
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.is_reauth
|
||||
* Implementation of simaka_provider_t.is_reauth
|
||||
*/
|
||||
static identification_t *is_reauth(private_eap_simaka_reauth_provider_t *this,
|
||||
identification_t *id, char mk[HASH_SIZE_SHA1],
|
||||
@@ -115,7 +115,7 @@ static identification_t *is_reauth(private_eap_simaka_reauth_provider_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.gen_reauth
|
||||
* Implementation of simaka_provider_t.gen_reauth
|
||||
*/
|
||||
static identification_t *gen_reauth(private_eap_simaka_reauth_provider_t *this,
|
||||
identification_t *id, char mk[HASH_SIZE_SHA1])
|
||||
@@ -186,13 +186,13 @@ eap_simaka_reauth_provider_t *eap_simaka_reauth_provider_create()
|
||||
{
|
||||
private_eap_simaka_reauth_provider_t *this = malloc_thing(private_eap_simaka_reauth_provider_t);
|
||||
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))return_false;
|
||||
this->public.provider.resync = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.provider.is_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.gen_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.is_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))is_reauth;
|
||||
this->public.provider.gen_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))gen_reauth;
|
||||
this->public.provider.get_triplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))return_false;
|
||||
this->public.provider.get_quintuplet = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))return_false;
|
||||
this->public.provider.resync = (bool(*)(simaka_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.provider.is_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.gen_pseudonym = (identification_t*(*)(simaka_provider_t*, identification_t *id))return_null;
|
||||
this->public.provider.is_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))is_reauth;
|
||||
this->public.provider.gen_reauth = (identification_t*(*)(simaka_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))gen_reauth;
|
||||
this->public.destroy = (void(*)(eap_simaka_reauth_provider_t*))destroy;
|
||||
|
||||
this->rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef EAP_SIMAKA_REAUTH_PROVIDER_H_
|
||||
#define EAP_SIMAKA_REAUTH_PROVIDER_H_
|
||||
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_provider.h>
|
||||
|
||||
typedef struct eap_simaka_reauth_provider_t eap_simaka_reauth_provider_t;
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct eap_simaka_reauth_provider_t eap_simaka_reauth_provider_t;
|
||||
struct eap_simaka_reauth_provider_t {
|
||||
|
||||
/**
|
||||
* Implements sim_provider_t interface.
|
||||
* Implements simaka_provider_t interface.
|
||||
*/
|
||||
sim_provider_t provider;
|
||||
simaka_provider_t provider;
|
||||
|
||||
/**
|
||||
* Destroy a eap_simaka_reauth_provider_t.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/libhydra \
|
||||
-I$(top_srcdir)/src/libcharon
|
||||
-I$(top_srcdir)/src/libcharon -I$(top_srcdir)/src/libsimaka
|
||||
|
||||
AM_CFLAGS = -rdynamic -DIPSEC_CONFDIR=\"${sysconfdir}\"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct private_eap_simaka_sql_card_t {
|
||||
bool remove_used;
|
||||
};
|
||||
|
||||
METHOD(sim_card_t, get_triplet, bool,
|
||||
METHOD(simaka_card_t, get_triplet, bool,
|
||||
private_eap_simaka_sql_card_t *this, identification_t *id,
|
||||
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
|
||||
{
|
||||
@@ -90,7 +90,7 @@ METHOD(sim_card_t, get_triplet, bool,
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(sim_card_t, get_quintuplet, status_t,
|
||||
METHOD(simaka_card_t, get_quintuplet, status_t,
|
||||
private_eap_simaka_sql_card_t *this, identification_t *id,
|
||||
char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN],
|
||||
char ik[AKA_IK_LEN], char res[AKA_RES_MAX], int *res_len)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define EAP_SIMAKA_SQL_CARD_H_
|
||||
|
||||
#include <database/database.h>
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_manager.h>
|
||||
|
||||
typedef struct eap_simaka_sql_card_t eap_simaka_sql_card_t;
|
||||
|
||||
@@ -32,9 +32,9 @@ typedef struct eap_simaka_sql_card_t eap_simaka_sql_card_t;
|
||||
struct eap_simaka_sql_card_t {
|
||||
|
||||
/**
|
||||
* Implements sim_card_t interface
|
||||
* Implements simaka_card_t interface
|
||||
*/
|
||||
sim_card_t card;
|
||||
simaka_card_t card;
|
||||
|
||||
/**
|
||||
* Destroy a eap_simaka_sql_card_t.
|
||||
|
||||
@@ -56,8 +56,20 @@ METHOD(plugin_t, get_name, char*,
|
||||
METHOD(plugin_t, destroy, void,
|
||||
private_eap_simaka_sql_t *this)
|
||||
{
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
charon->sim->remove_provider(charon->sim, &this->provider->provider);
|
||||
simaka_manager_t *mgr;
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->remove_card(mgr, &this->card->card);
|
||||
mgr->remove_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
this->card->destroy(this->card);
|
||||
this->provider->destroy(this->provider);
|
||||
this->db->destroy(this->db);
|
||||
@@ -70,6 +82,7 @@ METHOD(plugin_t, destroy, void,
|
||||
plugin_t *eap_simaka_sql_plugin_create()
|
||||
{
|
||||
private_eap_simaka_sql_t *this;
|
||||
simaka_manager_t *mgr;
|
||||
database_t *db;
|
||||
bool remove_used;
|
||||
char *uri;
|
||||
@@ -103,8 +116,17 @@ plugin_t *eap_simaka_sql_plugin_create()
|
||||
.card = eap_simaka_sql_card_create(db, remove_used),
|
||||
);
|
||||
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
charon->sim->add_provider(charon->sim, &this->provider->provider);
|
||||
|
||||
mgr = lib->get(lib, "sim-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
mgr = lib->get(lib, "aka-manager");
|
||||
if (mgr)
|
||||
{
|
||||
mgr->add_card(mgr, &this->card->card);
|
||||
mgr->add_provider(mgr, &this->provider->provider);
|
||||
}
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ struct private_eap_simaka_sql_provider_t {
|
||||
bool remove_used;
|
||||
};
|
||||
|
||||
METHOD(sim_provider_t, get_triplet, bool,
|
||||
METHOD(simaka_provider_t, get_triplet, bool,
|
||||
private_eap_simaka_sql_provider_t *this, identification_t *id,
|
||||
char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN])
|
||||
{
|
||||
@@ -90,7 +90,7 @@ METHOD(sim_provider_t, get_triplet, bool,
|
||||
return found;
|
||||
}
|
||||
|
||||
METHOD(sim_provider_t, get_quintuplet, bool,
|
||||
METHOD(simaka_provider_t, get_quintuplet, bool,
|
||||
private_eap_simaka_sql_provider_t *this, identification_t *id,
|
||||
char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len,
|
||||
char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN])
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define EAP_SIMAKA_SQL_PROVIDER_H_
|
||||
|
||||
#include <database/database.h>
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
#include <simaka_provider.h>
|
||||
|
||||
typedef struct eap_simaka_sql_provider_t eap_simaka_sql_provider_t;
|
||||
|
||||
@@ -32,9 +32,9 @@ typedef struct eap_simaka_sql_provider_t eap_simaka_sql_provider_t;
|
||||
struct eap_simaka_sql_provider_t {
|
||||
|
||||
/**
|
||||
* Implements sim_provider_t interface
|
||||
* Implements simaka_provider_t interface
|
||||
*/
|
||||
sim_provider_t provider;
|
||||
simaka_provider_t provider;
|
||||
|
||||
/**
|
||||
* Destroy a eap_simaka_sql_provider_t.
|
||||
|
||||
Reference in New Issue
Block a user