Query triplet/quintuplet functions with permanent identity only,
extended sim_provider with a is_pseudonym() function.
This commit is contained in:
@@ -62,41 +62,24 @@ static bool equals(identification_t *key1, identification_t *key2)
|
||||
return key1->equals(key1, key2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the permanent identity of pseudonym, if any
|
||||
*/
|
||||
static identification_t *lookup_permanent(private_eap_sim_file_card_t *this,
|
||||
identification_t *pseudonym)
|
||||
{
|
||||
identification_t *permanent;
|
||||
|
||||
permanent = this->permanent->get(this->permanent, pseudonym);
|
||||
if (permanent)
|
||||
{
|
||||
return permanent;
|
||||
}
|
||||
return pseudonym;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_card_t.get_triplet
|
||||
*/
|
||||
static bool get_triplet(private_eap_sim_file_card_t *this,
|
||||
identification_t *imsi, char *rand, char *sres, char *kc)
|
||||
identification_t *id, char *rand, char *sres, char *kc)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
identification_t *id;
|
||||
identification_t *cand;
|
||||
char *c_rand, *c_sres, *c_kc;
|
||||
|
||||
imsi = lookup_permanent(this, imsi);
|
||||
DBG2(DBG_CFG, "looking for triplet: %Y rand %b", imsi, rand, SIM_RAND_LEN);
|
||||
DBG2(DBG_CFG, "looking for triplet: %Y rand %b", id, rand, SIM_RAND_LEN);
|
||||
|
||||
enumerator = this->triplets->create_enumerator(this->triplets);
|
||||
while (enumerator->enumerate(enumerator, &id, &c_rand, &c_sres, &c_kc))
|
||||
while (enumerator->enumerate(enumerator, &cand, &c_rand, &c_sres, &c_kc))
|
||||
{
|
||||
DBG2(DBG_CFG, "got a triplet: %Y rand %b\nsres %b\n kc %b", id,
|
||||
DBG2(DBG_CFG, "got a triplet: %Y rand %b\nsres %b\n kc %b", cand,
|
||||
c_rand, SIM_RAND_LEN, c_sres, SIM_SRES_LEN, c_kc, SIM_KC_LEN);
|
||||
if (imsi->matches(imsi, id))
|
||||
if (id->matches(id, cand))
|
||||
{
|
||||
if (memeq(c_rand, rand, SIM_RAND_LEN))
|
||||
{
|
||||
@@ -189,13 +172,13 @@ 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[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.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]))get_triplet;
|
||||
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_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 *perm, identification_t *pseudonym))set_pseudonym;
|
||||
this->public.card.get_reauth = (identification_t*(*)(sim_card_t*, identification_t *perm, char mk[HASH_SIZE_SHA1], u_int16_t *counter))return_null;
|
||||
this->public.card.set_reauth = (void(*)(sim_card_t*, identification_t *perm, identification_t* next, char mk[HASH_SIZE_SHA1], u_int16_t counter))nop;
|
||||
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.destroy = (void(*)(eap_sim_file_card_t*))destroy;
|
||||
|
||||
this->triplets = triplets;
|
||||
|
||||
@@ -67,39 +67,20 @@ static bool equals(identification_t *key1, identification_t *key2)
|
||||
return key1->equals(key1, key2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the permanent identity of pseudonym, if any
|
||||
*/
|
||||
static identification_t *lookup_permanent(private_eap_sim_file_provider_t *this,
|
||||
identification_t *pseudonym)
|
||||
{
|
||||
identification_t *permanent;
|
||||
|
||||
permanent = this->permanent->get(this->permanent, pseudonym);
|
||||
if (permanent)
|
||||
{
|
||||
return permanent;
|
||||
}
|
||||
return pseudonym;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.get_triplet
|
||||
*/
|
||||
static bool get_triplet(private_eap_sim_file_provider_t *this,
|
||||
identification_t *imsi,
|
||||
char *rand, char *sres, char *kc)
|
||||
identification_t *id, char *rand, char *sres, char *kc)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
identification_t *id;
|
||||
identification_t *cand;
|
||||
char *c_rand, *c_sres, *c_kc;
|
||||
|
||||
imsi = lookup_permanent(this, imsi);
|
||||
|
||||
enumerator = this->triplets->create_enumerator(this->triplets);
|
||||
while (enumerator->enumerate(enumerator, &id, &c_rand, &c_sres, &c_kc))
|
||||
while (enumerator->enumerate(enumerator, &cand, &c_rand, &c_sres, &c_kc))
|
||||
{
|
||||
if (imsi->matches(imsi, id))
|
||||
if (id->matches(id, cand))
|
||||
{
|
||||
memcpy(rand, c_rand, SIM_RAND_LEN);
|
||||
memcpy(sres, c_sres, SIM_SRES_LEN);
|
||||
@@ -112,6 +93,22 @@ static bool get_triplet(private_eap_sim_file_provider_t *this,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.is_pseudonym
|
||||
*/
|
||||
static identification_t* is_pseudonym(private_eap_sim_file_provider_t *this,
|
||||
identification_t *id)
|
||||
{
|
||||
identification_t *permanent;
|
||||
|
||||
permanent = this->permanent->get(this->permanent, id);
|
||||
if (permanent)
|
||||
{
|
||||
return permanent->clone(permanent);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of sim_provider_t.get_triplet
|
||||
*/
|
||||
@@ -182,11 +179,12 @@ 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[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.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]))get_triplet;
|
||||
this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *id, 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 *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 = (bool(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_false;
|
||||
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.destroy = (void(*)(eap_sim_file_provider_t*))destroy;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user