Pass SIM/AKA crypto helper to constructor of message

This commit is contained in:
Martin Willi
2009-11-12 10:34:00 +01:00
parent 13f418b442
commit 0e20893d81
6 changed files with 86 additions and 77 deletions
+21 -21
View File
@@ -62,12 +62,12 @@ static eap_payload_t* create_client_error(private_eap_aka_peer_t *this,
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);
message = simaka_message_create(FALSE, identifier, EAP_AKA,
AKA_CLIENT_ERROR, this->crypto);
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);
out = message->generate(message, chunk_empty);
message->destroy(message);
return out;
}
@@ -133,11 +133,11 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
{
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 = simaka_message_create(FALSE, in->get_identifier(in), EAP_AKA,
AKA_SYNCHRONIZATION_FAILURE, this->crypto);
message->add_attribute(message, AT_AUTS,
chunk_create(auts, AKA_AUTS_LEN));
*out = message->generate(message, this->crypto, chunk_empty);
*out = message->generate(message, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
@@ -145,9 +145,9 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
{
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 = simaka_message_create(FALSE, in->get_identifier(in), EAP_AKA,
AKA_AUTHENTICATION_REJECT, this->crypto);
*out = message->generate(message, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
@@ -158,17 +158,17 @@ static status_t process_challenge(private_eap_aka_peer_t *this,
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))
if (!in->verify(in, 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 = simaka_message_create(FALSE, in->get_identifier(in), EAP_AKA,
AKA_CHALLENGE, this->crypto);
message->add_attribute(message, AT_RES, chunk_create(res, AKA_RES_LEN));
*out = message->generate(message, this->crypto, chunk_empty);
*out = message->generate(message, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
@@ -208,11 +208,11 @@ static status_t process_identity(private_eap_aka_peer_t *this,
}
enumerator->destroy(enumerator);
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_AKA, AKA_IDENTITY);
message = simaka_message_create(FALSE, in->get_identifier(in), EAP_AKA,
AKA_IDENTITY, this->crypto);
message->add_attribute(message, AT_IDENTITY,
this->peer->get_encoding(this->peer));
*out = message->generate(message, this->crypto, chunk_empty);
*out = message->generate(message, chunk_empty);
message->destroy(message);
return NEED_MORE;
}
@@ -262,9 +262,9 @@ static status_t process_notification(private_eap_aka_peer_t *this,
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 = simaka_message_create(FALSE, in->get_identifier(in), EAP_AKA,
AKA_NOTIFICATION, this->crypto);
*out = message->generate(message, chunk_empty);
message->destroy(message);
}
else
@@ -284,13 +284,13 @@ static status_t process(private_eap_aka_peer_t *this,
simaka_message_t *message;
status_t status;
message = simaka_message_create_from_payload(in);
message = simaka_message_create_from_payload(in, this->crypto);
if (!message)
{
*out = create_client_error(this, in->get_identifier(in));
return NEED_MORE;
}
if (!message->parse(message, this->crypto))
if (!message->parse(message))
{
message->destroy(message);
*out = create_client_error(this, in->get_identifier(in));
+6 -6
View File
@@ -126,11 +126,11 @@ static status_t initiate(private_eap_aka_server_t *this, eap_payload_t **out)
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 = simaka_message_create(TRUE, this->identifier++, EAP_AKA,
AKA_CHALLENGE, this->crypto);
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);
*out = message->generate(message, chunk_empty);
message->destroy(message);
this->pending = AKA_CHALLENGE;
@@ -175,7 +175,7 @@ static status_t process_challenge(private_eap_aka_server_t *this,
enumerator->destroy(enumerator);
/* verify MAC of EAP message, AT_MAC */
if (!in->verify(in, this->crypto, chunk_empty))
if (!in->verify(in, chunk_empty))
{
DBG1(DBG_IKE, "AT_MAC verification failed");
return FAILED;
@@ -308,12 +308,12 @@ static status_t process(private_eap_aka_server_t *this,
simaka_message_t *message;
status_t status;
message = simaka_message_create_from_payload(in);
message = simaka_message_create_from_payload(in, this->crypto);
if (!message)
{
return FAILED;
}
if (!message->parse(message, this->crypto))
if (!message->parse(message))
{
message->destroy(message);
return FAILED;
+15 -15
View File
@@ -113,12 +113,12 @@ static eap_payload_t* create_client_error(private_eap_sim_peer_t *this,
DBG1(DBG_IKE, "sending client error '%N'", simaka_client_error_names, code);
message = simaka_message_create(FALSE, identifier,
EAP_SIM, SIM_CLIENT_ERROR);
message = simaka_message_create(FALSE, identifier, EAP_SIM,
SIM_CLIENT_ERROR, this->crypto);
encoded = htons(code);
message->add_attribute(message, AT_CLIENT_ERROR_CODE,
chunk_create((char*)&encoded, sizeof(encoded)));
out = message->generate(message, this->crypto, chunk_empty);
out = message->generate(message, chunk_empty);
message->destroy(message);
return out;
}
@@ -181,11 +181,11 @@ static status_t process_start(private_eap_sim_peer_t *this,
free(this->nonce.ptr);
rng->allocate_bytes(rng, NONCE_LEN, &this->nonce);
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_SIM, SIM_START);
message = simaka_message_create(FALSE, in->get_identifier(in), EAP_SIM,
SIM_START, this->crypto);
message->add_attribute(message, AT_SELECTED_VERSION, version);
message->add_attribute(message, AT_NONCE_MT, this->nonce);
*out = message->generate(message, this->crypto, chunk_empty);
*out = message->generate(message, chunk_empty);
message->destroy(message);
return NEED_MORE;
@@ -264,7 +264,7 @@ static status_t process_challenge(private_eap_sim_peer_t *this,
this->msk = this->crypto->derive_keys_full(this->crypto, this->peer, data);
/* verify AT_MAC attribute, signature is over "EAP packet | NONCE_MT" */
if (!in->verify(in, this->crypto, this->nonce))
if (!in->verify(in, this->nonce))
{
DBG1(DBG_IKE, "AT_MAC verification failed");
*out = create_client_error(this, in->get_identifier(in),
@@ -273,9 +273,9 @@ static status_t process_challenge(private_eap_sim_peer_t *this,
}
/* build response with AT_MAC, built over "EAP packet | n*SRES" */
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_SIM, SIM_CHALLENGE);
*out = message->generate(message, this->crypto, sreses);
message = simaka_message_create(FALSE, in->get_identifier(in), EAP_SIM,
SIM_CHALLENGE, this->crypto);
*out = message->generate(message, sreses);
message->destroy(message);
return NEED_MORE;
}
@@ -325,9 +325,9 @@ static status_t process_notification(private_eap_sim_peer_t *this,
if (success)
{ /* empty notification reply */
message = simaka_message_create(FALSE, in->get_identifier(in),
EAP_SIM, SIM_NOTIFICATION);
*out = message->generate(message, this->crypto, chunk_empty);
message = simaka_message_create(FALSE, in->get_identifier(in), EAP_SIM,
SIM_NOTIFICATION, this->crypto);
*out = message->generate(message, chunk_empty);
message->destroy(message);
}
else
@@ -347,14 +347,14 @@ static status_t process(private_eap_sim_peer_t *this,
simaka_message_t *message;
status_t status;
message = simaka_message_create_from_payload(in);
message = simaka_message_create_from_payload(in, this->crypto);
if (!message)
{
*out = create_client_error(this, in->get_identifier(in),
SIM_UNABLE_TO_PROCESS);
return NEED_MORE;
}
if (!message->parse(message, this->crypto))
if (!message->parse(message))
{
message->destroy(message);
*out = create_client_error(this, in->get_identifier(in),
+9 -9
View File
@@ -173,10 +173,10 @@ static status_t process_start(private_eap_sim_server_t *this,
this->msk = this->crypto->derive_keys_full(this->crypto, this->peer, data);
/* build response with AT_MAC, built over "EAP packet | NONCE_MT" */
message = simaka_message_create(TRUE, this->identifier++,
EAP_SIM, SIM_CHALLENGE);
message = simaka_message_create(TRUE, this->identifier++, EAP_SIM,
SIM_CHALLENGE, this->crypto);
message->add_attribute(message, AT_RAND, rands);
*out = message->generate(message, this->crypto, nonce);
*out = message->generate(message, nonce);
message->destroy(message);
this->pending = SIM_CHALLENGE;
@@ -212,7 +212,7 @@ static status_t process_challenge(private_eap_sim_server_t *this,
enumerator->destroy(enumerator);
/* verify AT_MAC attribute, signature is over "EAP packet | n*SRES" */
if (!in->verify(in, this->crypto, this->sreses))
if (!in->verify(in, this->sreses))
{
DBG1(DBG_IKE, "AT_MAC verification failed");
return FAILED;
@@ -259,12 +259,12 @@ static status_t process(private_eap_sim_server_t *this,
simaka_message_t *message;
status_t status;
message = simaka_message_create_from_payload(in);
message = simaka_message_create_from_payload(in, this->crypto);
if (!message)
{
return FAILED;
}
if (!message->parse(message, this->crypto))
if (!message->parse(message))
{
message->destroy(message);
return FAILED;
@@ -297,10 +297,10 @@ static status_t initiate(private_eap_sim_server_t *this, eap_payload_t **out)
{
simaka_message_t *message;
message = simaka_message_create(TRUE, this->identifier++,
EAP_SIM, SIM_START);
message = simaka_message_create(TRUE, this->identifier++, EAP_SIM,
SIM_START, this->crypto);
message->add_attribute(message, AT_VERSION_LIST, version);
*out = message->generate(message, this->crypto, chunk_empty);
*out = message->generate(message, chunk_empty);
message->destroy(message);
this->pending = SIM_START;