Merged SIM/USIM manager/card/provider, avoids code duplication
This commit is contained in:
@@ -496,11 +496,11 @@ static u_char get_identifier()
|
||||
static status_t server_initiate(private_eap_aka_t *this, eap_payload_t **out)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
usim_provider_t *provider;
|
||||
sim_provider_t *provider;
|
||||
char ck[AKA_CK_LEN], ik[AKA_IK_LEN], autn[AKA_AUTN_LEN];
|
||||
bool found = FALSE;
|
||||
|
||||
enumerator = charon->usim->create_provider_enumerator(charon->usim);
|
||||
enumerator = charon->sim->create_provider_enumerator(charon->sim);
|
||||
while (enumerator->enumerate(enumerator, &provider))
|
||||
{
|
||||
if (provider->get_quintuplet(provider, this->peer, this->rand,
|
||||
@@ -537,7 +537,7 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
|
||||
chunk_t attr, message, pos, auts = chunk_empty;
|
||||
aka_attribute_t attribute;
|
||||
enumerator_t *enumerator;
|
||||
usim_provider_t *provider;
|
||||
sim_provider_t *provider;
|
||||
bool found = FALSE;
|
||||
|
||||
message = in->get_data(in);
|
||||
@@ -572,7 +572,7 @@ static status_t server_process_synchronize(private_eap_aka_t *this,
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
enumerator = charon->usim->create_provider_enumerator(charon->usim);
|
||||
enumerator = charon->sim->create_provider_enumerator(charon->sim);
|
||||
while (enumerator->enumerate(enumerator, &provider))
|
||||
{
|
||||
if (provider->resync(provider, this->peer, this->rand, auts.ptr))
|
||||
@@ -708,7 +708,7 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
|
||||
aka_attribute_t attribute;
|
||||
u_int8_t identifier;
|
||||
enumerator_t *enumerator;
|
||||
usim_card_t *card;
|
||||
sim_card_t *card;
|
||||
u_char res[AKA_RES_LEN], ck[AKA_CK_LEN], ik[AKA_IK_LEN], auts[AKA_AUTS_LEN];
|
||||
status_t status = NOT_FOUND;
|
||||
|
||||
@@ -759,7 +759,7 @@ static status_t peer_process_challenge(private_eap_aka_t *this,
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
enumerator = charon->usim->create_card_enumerator(charon->usim);
|
||||
enumerator = charon->sim->create_card_enumerator(charon->sim);
|
||||
while (enumerator->enumerate(enumerator, &card))
|
||||
{
|
||||
status = card->get_quintuplet(card, this->peer, rand.ptr, autn.ptr,
|
||||
|
||||
@@ -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 usim_card_t.get_quintuplet
|
||||
* Implementation of sim_card_t.get_quintuplet
|
||||
*/
|
||||
static status_t get_quintuplet(private_eap_aka_3gpp2_card_t *this,
|
||||
identification_t *imsi, char rand[AKA_RAND_LEN],
|
||||
@@ -111,7 +111,7 @@ static status_t get_quintuplet(private_eap_aka_3gpp2_card_t *this,
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of usim_card_t.resync
|
||||
* Implementation of sim_card_t.resync
|
||||
*/
|
||||
static bool resync(private_eap_aka_3gpp2_card_t *this, identification_t *imsi,
|
||||
char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN])
|
||||
@@ -151,8 +151,9 @@ 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_quintuplet = (status_t(*)(usim_card_t*, identification_t *imsi, char rand[16], char autn[16], char ck[16], char ik[16], char res[16]))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(usim_card_t*, identification_t *imsi, char rand[16], char auts[14]))resync;
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *imsi, 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 *imsi, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_LEN]))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *imsi, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
|
||||
this->public.destroy = (void(*)(eap_aka_3gpp2_card_t*))destroy;
|
||||
|
||||
this->f = f;
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
|
||||
#include "eap_aka_3gpp2_functions.h"
|
||||
|
||||
#include <sa/authenticators/eap/usim_manager.h>
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
|
||||
typedef struct eap_aka_3gpp2_card_t eap_aka_3gpp2_card_t;
|
||||
|
||||
/**
|
||||
* USIM card implementation using a set of AKA functions.
|
||||
* SIM card implementation using a set of AKA functions.
|
||||
*/
|
||||
struct eap_aka_3gpp2_card_t {
|
||||
|
||||
/**
|
||||
* Implements usim_card_t interface
|
||||
* Implements sim_card_t interface
|
||||
*/
|
||||
usim_card_t card;
|
||||
sim_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/usim_manager.h>
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
|
||||
#define AKA_SQN_LEN 6
|
||||
#define AKA_K_LEN 16
|
||||
|
||||
@@ -33,12 +33,12 @@ struct private_eap_aka_3gpp2_t {
|
||||
eap_aka_3gpp2_plugin_t public;
|
||||
|
||||
/**
|
||||
* USIM card
|
||||
* SIM card
|
||||
*/
|
||||
eap_aka_3gpp2_card_t *card;
|
||||
|
||||
/**
|
||||
* USIM provider
|
||||
* SIM provider
|
||||
*/
|
||||
eap_aka_3gpp2_provider_t *provider;
|
||||
|
||||
@@ -53,8 +53,8 @@ struct private_eap_aka_3gpp2_t {
|
||||
*/
|
||||
static void destroy(private_eap_aka_3gpp2_t *this)
|
||||
{
|
||||
charon->usim->remove_card(charon->usim, &this->card->card);
|
||||
charon->usim->remove_provider(charon->usim, &this->provider->provider);
|
||||
charon->sim->remove_card(charon->sim, &this->card->card);
|
||||
charon->sim->remove_provider(charon->sim, &this->provider->provider);
|
||||
this->card->destroy(this->card);
|
||||
this->provider->destroy(this->provider);
|
||||
this->functions->destroy(this->functions);
|
||||
@@ -79,8 +79,8 @@ plugin_t *plugin_create()
|
||||
this->card = eap_aka_3gpp2_card_create(this->functions);
|
||||
this->provider = eap_aka_3gpp2_provider_create(this->functions);
|
||||
|
||||
charon->usim->add_card(charon->usim, &this->card->card);
|
||||
charon->usim->add_provider(charon->usim, &this->provider->provider);
|
||||
charon->sim->add_card(charon->sim, &this->card->card);
|
||||
charon->sim->add_provider(charon->sim, &this->provider->provider);
|
||||
|
||||
return &this->public.plugin;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
typedef struct eap_aka_3gpp2_plugin_t eap_aka_3gpp2_plugin_t;
|
||||
|
||||
/**
|
||||
* Plugin to provide a USIM card/provider using the 3GPP2 (S.S0055) standard.
|
||||
* Plugin to provide a SIM card/provider using the 3GPP2 (S.S0055) standard.
|
||||
*
|
||||
* This plugin implements the standard of the 3GPP2 (S.S0055) and not the one
|
||||
* of 3GGP, completely in software using the libgmp library..
|
||||
|
||||
@@ -184,8 +184,9 @@ 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_quintuplet = (bool(*)(usim_provider_t*, identification_t *imsi, char rand[16], char xres[16], char ck[16], char ik[16], char autn[16]))get_quintuplet;
|
||||
this->public.provider.resync = (bool(*)(usim_provider_t*, identification_t *imsi, char rand[16], char auts[14]))resync;
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *imsi, 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 *imsi, char rand[AKA_RAND_LEN], char xres[AKA_RES_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 *imsi, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))resync;
|
||||
this->public.destroy = (void(*)(eap_aka_3gpp2_provider_t*))destroy;
|
||||
|
||||
this->f = f;
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
|
||||
#include "eap_aka_3gpp2_functions.h"
|
||||
|
||||
#include <sa/authenticators/eap/usim_manager.h>
|
||||
#include <sa/authenticators/eap/sim_manager.h>
|
||||
|
||||
typedef struct eap_aka_3gpp2_provider_t eap_aka_3gpp2_provider_t;
|
||||
|
||||
/**
|
||||
* USIM provider implementation using a set of AKA functions.
|
||||
* SIM provider implementation using a set of AKA functions.
|
||||
*/
|
||||
struct eap_aka_3gpp2_provider_t {
|
||||
|
||||
/**
|
||||
* Implements usim_provider_t interface.
|
||||
* Implements sim_provider_t interface.
|
||||
*/
|
||||
usim_provider_t provider;
|
||||
sim_provider_t provider;
|
||||
|
||||
/**
|
||||
* Destroy a eap_aka_3gpp2_provider_t.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Martin Willi
|
||||
* Copyright (C) 2008-2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -67,6 +67,14 @@ static bool get_triplet(private_eap_sim_file_card_t *this,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_quintuplet
|
||||
*/
|
||||
static bool get_quintuplet()
|
||||
{
|
||||
return NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of eap_sim_file_card_t.destroy.
|
||||
*/
|
||||
@@ -82,7 +90,9 @@ eap_sim_file_card_t *eap_sim_file_card_create(eap_sim_file_triplets_t *triplets)
|
||||
{
|
||||
private_eap_sim_file_card_t *this = malloc_thing(private_eap_sim_file_card_t);
|
||||
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *imsi, char *rand, char *sres, char *kc))get_triplet;
|
||||
this->public.card.get_triplet = (bool(*)(sim_card_t*, identification_t *imsi, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))get_triplet;
|
||||
this->public.card.get_quintuplet = (status_t(*)(sim_card_t*, identification_t *imsi, char rand[AKA_RAND_LEN], char autn[AKA_AUTN_LEN], char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char res[AKA_RES_LEN]))get_quintuplet;
|
||||
this->public.card.resync = (bool(*)(sim_card_t*, identification_t *imsi, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.destroy = (void(*)(eap_sim_file_card_t*))destroy;
|
||||
|
||||
this->triplets = triplets;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Martin Willi
|
||||
* Copyright (C) 2008-2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -76,7 +76,9 @@ eap_sim_file_provider_t *eap_sim_file_provider_create(
|
||||
{
|
||||
private_eap_sim_file_provider_t *this = malloc_thing(private_eap_sim_file_provider_t);
|
||||
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *imsi, char rand[16], char sres[4], char kc[8]))get_triplet;
|
||||
this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *imsi, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))get_triplet;
|
||||
this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *imsi, char rand[AKA_RAND_LEN], char xres[AKA_RES_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 *imsi, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
|
||||
this->public.destroy = (void(*)(eap_sim_file_provider_t*))destroy;
|
||||
|
||||
this->triplets = triplets;
|
||||
|
||||
Reference in New Issue
Block a user