2008-10-10 08:36:01 +00:00
|
|
|
/*
|
2009-10-12 12:40:21 +00:00
|
|
|
* Copyright (C) 2008-2009 Martin Willi
|
2008-10-10 08:36:01 +00:00
|
|
|
* Hochschule fuer Technik Rapperswil
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "eap_sim_file_card.h"
|
|
|
|
|
2009-10-09 08:59:34 +00:00
|
|
|
#include <daemon.h>
|
|
|
|
|
2008-10-10 08:36:01 +00:00
|
|
|
typedef struct private_eap_sim_file_card_t private_eap_sim_file_card_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private data of an eap_sim_file_card_t object.
|
|
|
|
*/
|
|
|
|
struct private_eap_sim_file_card_t {
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-10-10 08:36:01 +00:00
|
|
|
/**
|
|
|
|
* Public eap_sim_file_card_t interface.
|
|
|
|
*/
|
|
|
|
eap_sim_file_card_t public;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-10-10 08:36:01 +00:00
|
|
|
/**
|
2009-09-04 13:02:11 +00:00
|
|
|
* source of triplets
|
|
|
|
*/
|
2008-10-10 08:36:01 +00:00
|
|
|
eap_sim_file_triplets_t *triplets;
|
|
|
|
};
|
|
|
|
|
2011-07-07 10:31:45 +00:00
|
|
|
METHOD(simaka_card_t, get_triplet, bool,
|
2011-04-22 09:30:42 +00:00
|
|
|
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])
|
2008-10-10 08:36:01 +00:00
|
|
|
{
|
|
|
|
enumerator_t *enumerator;
|
2009-10-27 10:10:44 +00:00
|
|
|
identification_t *cand;
|
2008-10-10 08:36:01 +00:00
|
|
|
char *c_rand, *c_sres, *c_kc;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2009-10-27 10:10:44 +00:00
|
|
|
DBG2(DBG_CFG, "looking for triplet: %Y rand %b", id, rand, SIM_RAND_LEN);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-10-10 08:36:01 +00:00
|
|
|
enumerator = this->triplets->create_enumerator(this->triplets);
|
2009-10-27 10:10:44 +00:00
|
|
|
while (enumerator->enumerate(enumerator, &cand, &c_rand, &c_sres, &c_kc))
|
2008-10-10 08:36:01 +00:00
|
|
|
{
|
2009-10-27 10:10:44 +00:00
|
|
|
DBG2(DBG_CFG, "got a triplet: %Y rand %b\nsres %b\n kc %b", cand,
|
2009-10-14 07:55:14 +00:00
|
|
|
c_rand, SIM_RAND_LEN, c_sres, SIM_SRES_LEN, c_kc, SIM_KC_LEN);
|
2009-10-27 10:10:44 +00:00
|
|
|
if (id->matches(id, cand))
|
2008-10-10 08:36:01 +00:00
|
|
|
{
|
2015-04-11 13:25:21 +00:00
|
|
|
if (memeq_const(c_rand, rand, SIM_RAND_LEN))
|
2009-10-09 08:59:34 +00:00
|
|
|
{
|
2009-10-14 07:55:14 +00:00
|
|
|
DBG2(DBG_CFG, " => triplet matches");
|
2009-10-09 08:59:34 +00:00
|
|
|
memcpy(sres, c_sres, SIM_SRES_LEN);
|
|
|
|
memcpy(kc, c_kc, SIM_KC_LEN);
|
|
|
|
enumerator->destroy(enumerator);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-10-10 08:36:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
enumerator->destroy(enumerator);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-07 10:31:45 +00:00
|
|
|
METHOD(simaka_card_t, get_quintuplet, status_t,
|
2011-04-22 09:30:42 +00:00
|
|
|
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)
|
2009-10-12 12:40:21 +00:00
|
|
|
{
|
|
|
|
return NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2011-04-22 09:30:42 +00:00
|
|
|
METHOD(eap_sim_file_card_t, destroy, void,
|
|
|
|
private_eap_sim_file_card_t *this)
|
2008-10-10 08:36:01 +00:00
|
|
|
{
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See header
|
|
|
|
*/
|
|
|
|
eap_sim_file_card_t *eap_sim_file_card_create(eap_sim_file_triplets_t *triplets)
|
|
|
|
{
|
2011-04-22 09:30:42 +00:00
|
|
|
private_eap_sim_file_card_t *this;
|
|
|
|
|
|
|
|
INIT(this,
|
|
|
|
.public = {
|
|
|
|
.card = {
|
|
|
|
.get_triplet = _get_triplet,
|
|
|
|
.get_quintuplet = _get_quintuplet,
|
|
|
|
.resync = (void*)return_false,
|
|
|
|
.get_pseudonym = (void*)return_null,
|
|
|
|
.set_pseudonym = (void*)nop,
|
|
|
|
.get_reauth = (void*)return_null,
|
|
|
|
.set_reauth = (void*)nop,
|
|
|
|
},
|
|
|
|
.destroy = _destroy,
|
|
|
|
},
|
|
|
|
.triplets = triplets,
|
|
|
|
);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2008-10-10 08:36:01 +00:00
|
|
|
return &this->public;
|
|
|
|
}
|