Migrated eap_aka_3gpp2_functions_t to INIT/METHOD macros.
This commit is contained in:
@@ -284,9 +284,10 @@ static void f5x(prf_t *prf, u_char f, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate MAC from RAND, SQN, AMF using K
|
||||
*/
|
||||
static void f1(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char sqn[AKA_SQN_LEN],
|
||||
u_char amf[AKA_AMF_LEN], u_char mac[AKA_MAC_LEN])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f1, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char sqn[AKA_SQN_LEN],
|
||||
u_char amf[AKA_AMF_LEN], u_char mac[AKA_MAC_LEN])
|
||||
{
|
||||
f1x(this->prf, F1, k, rand, sqn, amf, mac);
|
||||
DBG3(DBG_IKE, "MAC %b", mac, AKA_MAC_LEN);
|
||||
@@ -295,9 +296,10 @@ static void f1(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate MACS from RAND, SQN, AMF using K
|
||||
*/
|
||||
static void f1star(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char sqn[AKA_SQN_LEN],
|
||||
u_char amf[AKA_AMF_LEN], u_char macs[AKA_MAC_LEN])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f1star, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char sqn[AKA_SQN_LEN],
|
||||
u_char amf[AKA_AMF_LEN], u_char macs[AKA_MAC_LEN])
|
||||
{
|
||||
f1x(this->prf, F1STAR, k, rand, sqn, amf, macs);
|
||||
DBG3(DBG_IKE, "MACS %b", macs, AKA_MAC_LEN);
|
||||
@@ -306,8 +308,9 @@ static void f1star(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate RES from RAND using K
|
||||
*/
|
||||
static void f2(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char res[AKA_RES_MAX])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f2, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char res[AKA_RES_MAX])
|
||||
{
|
||||
fx(this->prf, F2, k, rand, res);
|
||||
DBG3(DBG_IKE, "RES %b", res, AKA_RES_MAX);
|
||||
@@ -316,8 +319,9 @@ static void f2(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate CK from RAND using K
|
||||
*/
|
||||
static void f3(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char ck[AKA_CK_LEN])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f3, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char ck[AKA_CK_LEN])
|
||||
{
|
||||
fx(this->prf, F3, k, rand, ck);
|
||||
DBG3(DBG_IKE, "CK %b", ck, AKA_CK_LEN);
|
||||
@@ -326,8 +330,9 @@ static void f3(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate IK from RAND using K
|
||||
*/
|
||||
static void f4(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char ik[AKA_IK_LEN])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f4, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char ik[AKA_IK_LEN])
|
||||
{
|
||||
fx(this->prf, F4, k, rand, ik);
|
||||
DBG3(DBG_IKE, "IK %b", ik, AKA_IK_LEN);
|
||||
@@ -336,8 +341,9 @@ static void f4(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate AK from a RAND using K
|
||||
*/
|
||||
static void f5(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char ak[AKA_AK_LEN])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f5, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char ak[AKA_AK_LEN])
|
||||
{
|
||||
f5x(this->prf, F5, k, rand, ak);
|
||||
DBG3(DBG_IKE, "AK %b", ak, AKA_AK_LEN);
|
||||
@@ -346,18 +352,16 @@ static void f5(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
/**
|
||||
* Calculate AKS from a RAND using K
|
||||
*/
|
||||
static void f5star(private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char aks[AKA_AK_LEN])
|
||||
METHOD(eap_aka_3gpp2_functions_t, f5star, void,
|
||||
private_eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN],
|
||||
u_char rand[AKA_RAND_LEN], u_char aks[AKA_AK_LEN])
|
||||
{
|
||||
f5x(this->prf, F5STAR, k, rand, aks);
|
||||
DBG3(DBG_IKE, "AKS %b", aks, AKA_AK_LEN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of eap_aka_3gpp2_functions_t.destroy.
|
||||
*/
|
||||
static void destroy(private_eap_aka_3gpp2_functions_t *this)
|
||||
METHOD(eap_aka_3gpp2_functions_t, destroy, void,
|
||||
private_eap_aka_3gpp2_functions_t *this)
|
||||
{
|
||||
this->prf->destroy(this->prf);
|
||||
free(this);
|
||||
@@ -370,18 +374,19 @@ eap_aka_3gpp2_functions_t *eap_aka_3gpp2_functions_create()
|
||||
{
|
||||
private_eap_aka_3gpp2_functions_t *this;
|
||||
|
||||
this = malloc_thing(private_eap_aka_3gpp2_functions_t);
|
||||
|
||||
this->public.f1 = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char sqn[AKA_SQN_LEN], u_char amf[AKA_AMF_LEN], u_char mac[AKA_MAC_LEN]))f1;
|
||||
this->public.f1star = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char sqn[AKA_SQN_LEN], u_char amf[AKA_AMF_LEN], u_char macs[AKA_MAC_LEN]))f1star;
|
||||
this->public.f2 = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char res[AKA_RES_MAX]))f2;
|
||||
this->public.f3 = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char ck[AKA_CK_LEN]))f3;
|
||||
this->public.f4 = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char ik[AKA_IK_LEN]))f4;
|
||||
this->public.f5 = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char ak[AKA_AK_LEN]))f5;
|
||||
this->public.f5star = (void(*)(eap_aka_3gpp2_functions_t *this, u_char k[AKA_K_LEN], u_char rand[AKA_RAND_LEN], u_char aks[AKA_AK_LEN]))f5star;
|
||||
this->public.destroy = (void(*)(eap_aka_3gpp2_functions_t*))destroy;
|
||||
|
||||
this->prf = lib->crypto->create_prf(lib->crypto, PRF_KEYED_SHA1);
|
||||
INIT(this,
|
||||
.public = {
|
||||
.f1 = _f1,
|
||||
.f1star = _f1star,
|
||||
.f2 = _f2,
|
||||
.f3 = _f3,
|
||||
.f4 = _f4,
|
||||
.f5 = _f5,
|
||||
.f5star = _f5star,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.prf = lib->crypto->create_prf(lib->crypto, PRF_KEYED_SHA1),
|
||||
);
|
||||
if (!this->prf)
|
||||
{
|
||||
DBG1(DBG_CFG, "%N not supported, unable to use 3GPP2 algorithm",
|
||||
|
||||
Reference in New Issue
Block a user