Splitted EAP-AKA in peer and server implementations, use libsimaka helper library

This commit is contained in:
Martin Willi
2009-11-12 10:33:59 +01:00
parent 6d90881573
commit aea334ec1c
8 changed files with 869 additions and 1122 deletions
+6 -2
View File
@@ -1,10 +1,14 @@
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I$(top_srcdir)/src/charon \
-I$(top_srcdir)/src/libsimaka
AM_CFLAGS = -rdynamic
plugin_LTLIBRARIES = libstrongswan-eap-aka.la
libstrongswan_eap_aka_la_SOURCES = eap_aka_plugin.h eap_aka_plugin.c eap_aka.h eap_aka.c
libstrongswan_eap_aka_la_SOURCES = eap_aka_plugin.h eap_aka_plugin.c \
eap_aka_peer.h eap_aka_peer.c \
eap_aka_server.h eap_aka_server.c
libstrongswan_eap_aka_la_LIBADD = $(top_builddir)/src/libsimaka/libsimaka.a
libstrongswan_eap_aka_la_LDFLAGS = -module -avoid-version
File diff suppressed because it is too large Load Diff
+397
View File
@@ -0,0 +1,397 @@
/*
* Copyright (C) 2006-2009 Martin Willi
* 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_aka_peer.h"
#include <library.h>
#include <daemon.h>
#include <simaka_message.h>
#include <simaka_crypto.h>
typedef struct private_eap_aka_peer_t private_eap_aka_peer_t;
/**
* Private data of an eap_aka_peer_t object.
*/
struct private_eap_aka_peer_t {
/**
* Public authenticator_t interface.
*/
eap_aka_peer_t public;
/**
* EAP-AKA crypto helper
*/
simaka_crypto_t *crypto;
/**
* ID of the peer
*/
identification_t *peer;
/**
* MSK
*/
chunk_t msk;
};
/**
* Create a AKA_CLIENT_ERROR: "Unable to process"
*/
static eap_payload_t* create_client_error(private_eap_aka_peer_t *this,
u_int8_t identifier)
{
simaka_message_t *message;
eap_payload_t *out;
u_int16_t encoded;
DBG1(DBG_IKE, "sending client error '%N'",
simaka_client_error_names, AKA_UNABLE_TO_PROCESS);
message = simaka_message_create(FALSE, identifier,
EAP_AKA, AKA_CLIENT_ERROR);
encoded = htons(AKA_UNABLE_TO_PROCESS);
message->add_attribute(message, AT_CLIENT_ERROR_CODE,
chunk_create((char*)&encoded, sizeof(encoded)));
out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
return out;
}
/**
* Process an EAP-AKA/Request/Challenge message
*/
static status_t process_challenge(private_eap_aka_peer_t *this,
simaka_message_t *in, eap_payload_t **out)
{
simaka_message_t *message;
enumerator_t *enumerator;
simaka_attribute_t type;
sim_card_t *card;
chunk_t data, rand = chunk_empty, autn = chunk_empty;
u_char res[AKA_RES_LEN], ck[AKA_CK_LEN], ik[AKA_IK_LEN], auts[AKA_AUTS_LEN];
status_t status = NOT_FOUND;
enumerator = in->create_attribute_enumerator(in);
while (enumerator->enumerate(enumerator, &type, &data))
{
switch (type)
{
case AT_RAND:
rand = data;
break;
case AT_AUTN:
autn = data;
break;
default:
if (!simaka_attribute_skippable(type))
{
*out = create_client_error(this, in->get_identifier(in));
enumerator->destroy(enumerator);
return NEED_MORE;
}
break;
}
}
enumerator->destroy(enumerator);
if (!rand.len || !autn.len)
{
DBG1(DBG_IKE, "received invalid EAP-AKA challenge message");
*out = create_client_error(this, in->get_identifier(in));
return NEED_MORE;
}
enumerator = charon->sim->create_card_enumerator(charon->sim);
while (enumerator->enumerate(enumerator, &card))
{
status = card->get_quintuplet(card, this->peer, rand.ptr, autn.ptr,
ck, ik, res);
if (status != FAILED)
{ /* try next on error */
break;
}
}
enumerator->destroy(enumerator);
if (status == INVALID_STATE &&
card->resync(card, this->peer, rand.ptr, auts))
{
DBG1(DBG_IKE, "received SQN invalid, sending %N",
simaka_subtype_names, AKA_SYNCHRONIZATION_FAILURE);
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_AKA, AKA_SYNCHRONIZATION_FAILURE);
message->add_attribute(message, AT_AUTS,
chunk_create(auts, AKA_AUTS_LEN));
*out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
if (status != SUCCESS)
{
DBG1(DBG_IKE, "no USIM found with quintuplets for '%Y', sending %N",
this->peer, simaka_subtype_names, AKA_AUTHENTICATION_REJECT);
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_AKA, AKA_AUTHENTICATION_REJECT);
*out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
data = chunk_cata("cc", chunk_create(ik, AKA_IK_LEN),
chunk_create(ck, AKA_CK_LEN));
free(this->msk.ptr);
this->msk = this->crypto->derive_keys_full(this->crypto, this->peer, data);
/* verify EAP message MAC AT_MAC */
if (!in->verify(in, this->crypto, chunk_empty))
{
DBG1(DBG_IKE, "AT_MAC verification failed ");
*out = create_client_error(this, in->get_identifier(in));
return NEED_MORE;
}
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_AKA, AKA_CHALLENGE);
message->add_attribute(message, AT_RES, chunk_create(res, AKA_RES_LEN));
*out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
/**
* Process an EAP-AKA/Request/Identity message
*/
static status_t process_identity(private_eap_aka_peer_t *this,
simaka_message_t *in, eap_payload_t **out)
{
simaka_message_t *message;
enumerator_t *enumerator;
simaka_attribute_t type;
chunk_t data;
enumerator = in->create_attribute_enumerator(in);
while (enumerator->enumerate(enumerator, &type, &data))
{
switch (type)
{
case AT_PERMANENT_ID_REQ:
case AT_FULLAUTH_ID_REQ:
case AT_ANY_ID_REQ:
DBG1(DBG_IKE, "server requested %N, sending '%Y'",
simaka_attribute_names, type, this->peer);
/* we reply with our permanent identity in any case */
break;
default:
if (!simaka_attribute_skippable(type))
{
*out = create_client_error(this, in->get_identifier(in));
enumerator->destroy(enumerator);
return NEED_MORE;
}
break;
}
}
enumerator->destroy(enumerator);
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_AKA, AKA_IDENTITY);
message->add_attribute(message, AT_IDENTITY,
this->peer->get_encoding(this->peer));
*out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
/**
* Process an EAP-AKA/Request/Notification message
*/
static status_t process_notification(private_eap_aka_peer_t *this,
simaka_message_t *in, eap_payload_t **out)
{
simaka_message_t *message;
enumerator_t *enumerator;
simaka_attribute_t type;
chunk_t data;
bool success = TRUE;
enumerator = in->create_attribute_enumerator(in);
while (enumerator->enumerate(enumerator, &type, &data))
{
if (type == AT_NOTIFICATION)
{
u_int16_t code;
memcpy(&code, data.ptr, sizeof(code));
code = ntohs(code);
/* test success bit */
if (!(data.ptr[0] & 0x80))
{
success = FALSE;
DBG1(DBG_IKE, "received EAP-AKA notification error '%N'",
simaka_notification_names, code);
}
else
{
DBG1(DBG_IKE, "received EAP-AKA notification '%N'",
simaka_notification_names, code);
}
}
else if (!simaka_attribute_skippable(type))
{
success = FALSE;
break;
}
}
enumerator->destroy(enumerator);
if (success)
{ /* empty notification reply */
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_AKA, AKA_NOTIFICATION);
*out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
}
else
{
*out = create_client_error(this, in->get_identifier(in));
}
return NEED_MORE;
}
/**
* Implementation of eap_method_t.process
*/
static status_t process(private_eap_aka_peer_t *this,
eap_payload_t *in, eap_payload_t **out)
{
simaka_message_t *message;
status_t status;
message = simaka_message_create_from_payload(in);
if (!message)
{
*out = create_client_error(this, in->get_identifier(in));
return NEED_MORE;
}
if (!message->parse(message, this->crypto))
{
message->destroy(message);
*out = create_client_error(this, in->get_identifier(in));
return NEED_MORE;
}
switch (message->get_subtype(message))
{
case AKA_IDENTITY:
status = process_identity(this, message, out);
break;
case AKA_CHALLENGE:
status = process_challenge(this, message, out);
break;
case AKA_NOTIFICATION:
status = process_notification(this, message, out);
break;
default:
DBG1(DBG_IKE, "unable to process EAP-AKA subtype %N",
simaka_subtype_names, message->get_subtype(message));
*out = create_client_error(this, in->get_identifier(in));
status = NEED_MORE;
break;
}
message->destroy(message);
return status;
}
/**
* Implementation of eap_method_t.initiate
*/
static status_t initiate(private_eap_aka_peer_t *this, eap_payload_t **out)
{
/* peer never initiates */
return FAILED;
}
/**
* Implementation of eap_method_t.get_type.
*/
static eap_type_t get_type(private_eap_aka_peer_t *this, u_int32_t *vendor)
{
*vendor = 0;
return EAP_AKA;
}
/**
* Implementation of eap_method_t.get_msk.
*/
static status_t get_msk(private_eap_aka_peer_t *this, chunk_t *msk)
{
if (this->msk.ptr)
{
*msk = this->msk;
return SUCCESS;
}
return FAILED;
}
/**
* Implementation of eap_method_t.is_mutual.
*/
static bool is_mutual(private_eap_aka_peer_t *this)
{
return TRUE;
}
/**
* Implementation of eap_method_t.destroy.
*/
static void destroy(private_eap_aka_peer_t *this)
{
this->crypto->destroy(this->crypto);
this->peer->destroy(this->peer);
free(this->msk.ptr);
free(this);
}
/*
* Described in header.
*/
eap_aka_peer_t *eap_aka_peer_create(identification_t *server,
identification_t *peer)
{
private_eap_aka_peer_t *this = malloc_thing(private_eap_aka_peer_t);
this->public.interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate;
this->public.interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process;
this->public.interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
this->public.interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
this->public.interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
this->public.interface.destroy = (void(*)(eap_method_t*))destroy;
this->crypto = simaka_crypto_create();
if (!this->crypto)
{
free(this);
return NULL;
}
this->peer = peer->clone(peer);
this->msk = chunk_empty;
return &this->public;
}
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2008-2009 Martin Willi
* 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.
*/
/**
* @defgroup eap_aka_peer eap_aka_peer
* @{ @ingroup eap_aka
*/
#ifndef EAP_AKA_PEER_H_
#define EAP_AKA_PEER_H_
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.
*/
struct eap_aka_peer_t {
/**
* Implemented eap_method_t interface.
*/
eap_method_t interface;
};
/**
* Creates the peer implementation of the EAP method EAP-AKA.
*
* @param server ID of the EAP server
* @param peer ID of the EAP client
* @return eap_aka_peer_t object
*/
eap_aka_peer_t *eap_aka_peer_create(identification_t *server,
identification_t *peer);
#endif /** EAP_AKA_PEER_H_ @}*/
+7 -6
View File
@@ -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
@@ -15,7 +15,8 @@
#include "eap_aka_plugin.h"
#include "eap_aka.h"
#include "eap_aka_peer.h"
#include "eap_aka_server.h"
#include <daemon.h>
@@ -25,9 +26,9 @@
static void destroy(eap_aka_plugin_t *this)
{
charon->eap->remove_method(charon->eap,
(eap_constructor_t)eap_aka_create_server);
(eap_constructor_t)eap_aka_server_create);
charon->eap->remove_method(charon->eap,
(eap_constructor_t)eap_aka_create_peer);
(eap_constructor_t)eap_aka_peer_create);
free(this);
}
@@ -41,9 +42,9 @@ plugin_t *plugin_create()
this->plugin.destroy = (void(*)(plugin_t*))destroy;
charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_SERVER,
(eap_constructor_t)eap_aka_create_server);
(eap_constructor_t)eap_aka_server_create);
charon->eap->add_method(charon->eap, EAP_AKA, 0, EAP_PEER,
(eap_constructor_t)eap_aka_create_peer);
(eap_constructor_t)eap_aka_peer_create);
return &this->plugin;
}
+5 -2
View File
@@ -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
@@ -29,7 +29,10 @@
typedef struct eap_aka_plugin_t eap_aka_plugin_t;
/**
* EAP-AKA plugin
* EAP-AKA plugin.
*
* EAP-AKA uses 3rd generation mobile phone standard authentication
* mechanism for authentication, as defined RFC4187.
*/
struct eap_aka_plugin_t {
+394
View File
@@ -0,0 +1,394 @@
/*
* Copyright (C) 2006-2009 Martin Willi
* 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_aka_server.h"
#include <daemon.h>
#include <library.h>
#include <simaka_message.h>
#include <simaka_crypto.h>
typedef struct private_eap_aka_server_t private_eap_aka_server_t;
/**
* Private data of an eap_aka_server_t object.
*/
struct private_eap_aka_server_t {
/**
* Public authenticator_t interface.
*/
eap_aka_server_t public;
/**
* EAP-AKA crypto helper
*/
simaka_crypto_t *crypto;
/**
* ID of the peer
*/
identification_t *peer;
/**
* EAP identifier value
*/
u_int8_t identifier;
/**
* MSK
*/
chunk_t msk;
/**
* Expected Result XRES
*/
chunk_t xres;
/**
* Random value RAND
*/
chunk_t rand;
};
/**
* Check if an unknown attribute is skippable
*/
static bool attribute_skippable(simaka_attribute_t attribute)
{
if (attribute >= 0 && attribute <= 127)
{
DBG1(DBG_IKE, "ignoring skippable attribute %N",
simaka_attribute_names, attribute);
return TRUE;
}
return FALSE;
}
/**
* Implementation of eap_method_t.initiate
*/
static status_t initiate(private_eap_aka_server_t *this, eap_payload_t **out)
{
simaka_message_t *message;
enumerator_t *enumerator;
sim_provider_t *provider;
char rand[AKA_RAND_LEN], xres[AKA_RES_LEN];
char ck[AKA_CK_LEN], ik[AKA_IK_LEN], autn[AKA_AUTN_LEN];
chunk_t data;
bool found = FALSE;
enumerator = charon->sim->create_provider_enumerator(charon->sim);
while (enumerator->enumerate(enumerator, &provider))
{
if (provider->get_quintuplet(provider, this->peer,
rand, xres, ck, ik, autn))
{
found = TRUE;
break;
}
}
enumerator->destroy(enumerator);
if (!found)
{
DBG1(DBG_IKE, "no AKA provider found with quintuplets for '%Y'",
this->peer);
return FAILED;
}
data = chunk_cata("cc", chunk_create(ik, AKA_IK_LEN),
chunk_create(ck, AKA_CK_LEN));
free(this->msk.ptr);
this->msk = this->crypto->derive_keys_full(this->crypto, this->peer, data);
this->rand = chunk_clone(chunk_create(rand, AKA_RAND_LEN));
this->xres = chunk_clone(chunk_create(xres, AKA_RES_LEN));
message = simaka_message_create(TRUE, this->identifier++,
EAP_AKA, AKA_CHALLENGE);
message->add_attribute(message, AT_RAND, this->rand);
message->add_attribute(message, AT_AUTN, chunk_create(autn, AKA_AUTN_LEN));
*out = message->generate(message, this->crypto, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
/**
* Process EAP-AKA/Response/Challenge message
*/
static status_t process_challenge(private_eap_aka_server_t *this,
simaka_message_t *in)
{
enumerator_t *enumerator;
simaka_attribute_t type;
chunk_t data, res = chunk_empty;
enumerator = in->create_attribute_enumerator(in);
while (enumerator->enumerate(enumerator, &type, &data))
{
switch (type)
{
case AT_RES:
res = data;
break;
default:
if (!attribute_skippable(type))
{
enumerator->destroy(enumerator);
DBG1(DBG_IKE, "found non skippable attribute %N",
simaka_attribute_names, type);
return FAILED;
}
break;
}
}
enumerator->destroy(enumerator);
/* verify MAC of EAP message, AT_MAC */
if (!in->verify(in, this->crypto, chunk_empty))
{
DBG1(DBG_IKE, "AT_MAC verification failed");
return FAILED;
}
/* compare received RES against stored XRES */
if (!chunk_equals(res, this->xres))
{
DBG1(DBG_IKE, "received RES does not match XRES");
return FAILED;
}
return SUCCESS;
}
/**
* Process EAP-AKA/Response/SynchronizationFailure message
*/
static status_t process_synchronize(private_eap_aka_server_t *this,
simaka_message_t *in, eap_payload_t **out)
{
sim_provider_t *provider;
enumerator_t *enumerator;
simaka_attribute_t type;
chunk_t data, auts = chunk_empty;
bool found = FALSE;
DBG1(DBG_IKE, "received synchronization request, retrying...");
enumerator = in->create_attribute_enumerator(in);
while (enumerator->enumerate(enumerator, &type, &data))
{
switch (type)
{
case AT_AUTS:
auts = data;
break;
default:
if (!attribute_skippable(type))
{
enumerator->destroy(enumerator);
DBG1(DBG_IKE, "found non skippable attribute %N",
simaka_attribute_names, type);
return FAILED;
}
break;
}
}
enumerator->destroy(enumerator);
if (!auts.len)
{
DBG1(DBG_IKE, "synchronization request didn't contain usable AUTS");
return FAILED;
}
enumerator = charon->sim->create_provider_enumerator(charon->sim);
while (enumerator->enumerate(enumerator, &provider))
{
if (provider->resync(provider, this->peer, this->rand.ptr, auts.ptr))
{
found = TRUE;
break;
}
}
enumerator->destroy(enumerator);
if (!found)
{
DBG1(DBG_IKE, "no AKA provider found supporting "
"resynchronization for '%Y'", this->peer);
return FAILED;
}
return initiate(this, out);
}
/**
* Process EAP-AKA/Response/ClientErrorCode message
*/
static status_t process_client_error(private_eap_aka_server_t *this,
simaka_message_t *in)
{
enumerator_t *enumerator;
simaka_attribute_t type;
chunk_t data;
enumerator = in->create_attribute_enumerator(in);
while (enumerator->enumerate(enumerator, &type, &data))
{
if (type == AT_CLIENT_ERROR_CODE)
{
u_int16_t code;
memcpy(&code, data.ptr, sizeof(code));
DBG1(DBG_IKE, "received EAP-AKA client error '%N'",
simaka_client_error_names, ntohs(code));
}
else if (!simaka_attribute_skippable(type))
{
break;
}
}
enumerator->destroy(enumerator);
return FAILED;
}
/**
* Process EAP-AKA/Response/AuthenticationReject message
*/
static status_t process_authentication_reject(private_eap_aka_server_t *this,
simaka_message_t *in)
{
DBG1(DBG_IKE, "received %N, authentication failed",
simaka_subtype_names, in->get_subtype(in));
return FAILED;
}
/**
* Implementation of eap_method_t.process
*/
static status_t process(private_eap_aka_server_t *this,
eap_payload_t *in, eap_payload_t **out)
{
simaka_message_t *message;
status_t status;
message = simaka_message_create_from_payload(in);
if (!message)
{
return FAILED;
}
if (!message->parse(message, this->crypto))
{
message->destroy(message);
return FAILED;
}
switch (message->get_subtype(message))
{
case AKA_CHALLENGE:
status = process_challenge(this, message);
break;
case AKA_SYNCHRONIZATION_FAILURE:
status = process_synchronize(this, message, out);
break;
case AKA_CLIENT_ERROR:
status = process_client_error(this, message);
break;
case AKA_AUTHENTICATION_REJECT:
status = process_authentication_reject(this, message);
break;
default:
DBG1(DBG_IKE, "unable to process EAP-AKA subtype %N",
simaka_subtype_names, message->get_subtype(message));
status = FAILED;
break;
}
message->destroy(message);
return status;
}
/**
* Implementation of eap_method_t.get_type.
*/
static eap_type_t get_type(private_eap_aka_server_t *this, u_int32_t *vendor)
{
*vendor = 0;
return EAP_AKA;
}
/**
* Implementation of eap_method_t.get_msk.
*/
static status_t get_msk(private_eap_aka_server_t *this, chunk_t *msk)
{
if (this->msk.ptr)
{
*msk = this->msk;
return SUCCESS;
}
return FAILED;
}
/**
* Implementation of eap_method_t.is_mutual.
*/
static bool is_mutual(private_eap_aka_server_t *this)
{
return TRUE;
}
/**
* Implementation of eap_method_t.destroy.
*/
static void destroy(private_eap_aka_server_t *this)
{
this->crypto->destroy(this->crypto);
this->peer->destroy(this->peer);
free(this->msk.ptr);
free(this->xres.ptr);
free(this->rand.ptr);
free(this);
}
/*
* Described in header.
*/
eap_aka_server_t *eap_aka_server_create(identification_t *server,
identification_t *peer)
{
private_eap_aka_server_t *this = malloc_thing(private_eap_aka_server_t);
this->public.interface.initiate = (status_t(*)(eap_method_t*,eap_payload_t**))initiate;
this->public.interface.process = (status_t(*)(eap_method_t*,eap_payload_t*,eap_payload_t**))process;
this->public.interface.get_type = (eap_type_t(*)(eap_method_t*,u_int32_t*))get_type;
this->public.interface.is_mutual = (bool(*)(eap_method_t*))is_mutual;
this->public.interface.get_msk = (status_t(*)(eap_method_t*,chunk_t*))get_msk;
this->public.interface.destroy = (void(*)(eap_method_t*))destroy;
this->crypto = simaka_crypto_create();
if (!this->crypto)
{
free(this);
return NULL;
}
this->peer = peer->clone(peer);
this->msk = chunk_empty;
this->xres = chunk_empty;
this->rand = chunk_empty;
/* generate a non-zero identifier */
do {
this->identifier = random();
} while (!this->identifier);
return &this->public;
}
@@ -14,29 +14,26 @@
*/
/**
* @defgroup eap_aka_i eap_aka
* @defgroup eap_aka_server eap_aka_server
* @{ @ingroup eap_aka
*/
#ifndef EAP_AKA_H_
#define EAP_AKA_H_
#ifndef EAP_AKA_SERVER_H_
#define EAP_AKA_SERVER_H_
typedef struct eap_aka_t eap_aka_t;
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.
*
* EAP-AKA uses 3rd generation mobile phone standard authentication
* mechanism for authentication, as defined RFC4187.
* Implementation of the eap_method_t interface using EAP-AKA as server.
*/
struct eap_aka_t {
struct eap_aka_server_t {
/**
* Implemented eap_method_t interface.
*/
eap_method_t eap_method_interface;
eap_method_t interface;
};
/**
@@ -44,17 +41,9 @@ struct eap_aka_t {
*
* @param server ID of the EAP server
* @param peer ID of the EAP client
* @return eap_aka_t object
* @return eap_aka_server_t object
*/
eap_aka_t *eap_aka_create_server(identification_t *server, identification_t *peer);
eap_aka_server_t *eap_aka_server_create(identification_t *server,
identification_t *peer);
/**
* Creates the peer implementation of the EAP method EAP-AKA.
*
* @param server ID of the EAP server
* @param peer ID of the EAP client
* @return eap_aka_t object
*/
eap_aka_t *eap_aka_create_peer(identification_t *server, identification_t *peer);
#endif /** EAP_AKA_H_ @}*/
#endif /** EAP_AKA_SERVER_H_ @}*/