added support for EAP methods not establishing an MSK
This commit is contained in:
@@ -61,21 +61,31 @@ struct private_eap_authenticator_t {
|
||||
chunk_t msk;
|
||||
};
|
||||
|
||||
/**
|
||||
* reuse shared key signature function from PSK authenticator
|
||||
*/
|
||||
extern chunk_t build_shared_key_signature(chunk_t ike_sa_init, chunk_t nonce,
|
||||
chunk_t secret, identification_t *id,
|
||||
prf_t *prf_skp, prf_t *prf);
|
||||
|
||||
chunk_t secret, identification_t *id,
|
||||
chunk_t skp, prf_t *prf);
|
||||
/**
|
||||
* Implementation of authenticator_t.verify.
|
||||
*/
|
||||
static status_t verify(private_eap_authenticator_t *this, chunk_t ike_sa_init,
|
||||
chunk_t my_nonce, auth_payload_t *auth_payload)
|
||||
{
|
||||
chunk_t auth_data, recv_auth_data;
|
||||
chunk_t auth_data, recv_auth_data, secret;
|
||||
identification_t *other_id = this->ike_sa->get_other_id(this->ike_sa);
|
||||
|
||||
auth_data = build_shared_key_signature(ike_sa_init, my_nonce, this->msk,
|
||||
other_id, this->ike_sa->get_auth_verify(this->ike_sa),
|
||||
if (this->msk.len)
|
||||
{ /* use MSK if EAP method established one... */
|
||||
secret = this->msk;
|
||||
}
|
||||
else
|
||||
{ /* ... or use SKp if not */
|
||||
secret = this->ike_sa->get_skp_verify(this->ike_sa);
|
||||
}
|
||||
auth_data = build_shared_key_signature(ike_sa_init, my_nonce, secret,
|
||||
other_id, this->ike_sa->get_skp_verify(this->ike_sa),
|
||||
this->ike_sa->get_prf(this->ike_sa));
|
||||
|
||||
recv_auth_data = auth_payload->get_data(auth_payload);
|
||||
@@ -98,14 +108,22 @@ static status_t verify(private_eap_authenticator_t *this, chunk_t ike_sa_init,
|
||||
static status_t build(private_eap_authenticator_t *this, chunk_t ike_sa_init,
|
||||
chunk_t other_nonce, auth_payload_t **auth_payload)
|
||||
{
|
||||
chunk_t auth_data;
|
||||
chunk_t auth_data, secret;
|
||||
identification_t *my_id = this->ike_sa->get_my_id(this->ike_sa);
|
||||
|
||||
DBG1(DBG_IKE, "authentication of '%D' (myself) with %N",
|
||||
my_id, auth_method_names, AUTH_EAP);
|
||||
|
||||
auth_data = build_shared_key_signature(ike_sa_init, other_nonce, this->msk,
|
||||
my_id, this->ike_sa->get_auth_build(this->ike_sa),
|
||||
|
||||
if (this->msk.len)
|
||||
{ /* use MSK if EAP method established one... */
|
||||
secret = this->msk;
|
||||
}
|
||||
else
|
||||
{ /* ... or use SKp if not */
|
||||
secret = this->ike_sa->get_skp_build(this->ike_sa);
|
||||
}
|
||||
auth_data = build_shared_key_signature(ike_sa_init, other_nonce, secret,
|
||||
my_id, this->ike_sa->get_skp_build(this->ike_sa),
|
||||
this->ike_sa->get_prf(this->ike_sa));
|
||||
|
||||
*auth_payload = auth_payload_create();
|
||||
@@ -233,13 +251,14 @@ static status_t process_server(private_eap_authenticator_t *this,
|
||||
DBG1(DBG_IKE, "EAP method %N succeded, MSK established",
|
||||
eap_type_names, this->method->get_type(this->method));
|
||||
this->msk = chunk_clone(this->msk);
|
||||
*out = eap_payload_create_code(EAP_SUCCESS);
|
||||
return SUCCESS;
|
||||
}
|
||||
DBG1(DBG_IKE, "EAP method %N succeded, but no MSK established",
|
||||
eap_type_names, this->method->get_type(this->method));
|
||||
*out = eap_payload_create_code(EAP_FAILURE);
|
||||
return FAILED;
|
||||
else
|
||||
{
|
||||
DBG1(DBG_IKE, "EAP method %N succeded, no MSK established",
|
||||
eap_type_names, this->method->get_type(this->method));
|
||||
}
|
||||
*out = eap_payload_create_code(EAP_SUCCESS);
|
||||
return SUCCESS;
|
||||
case FAILED:
|
||||
default:
|
||||
DBG1(DBG_IKE, "EAP method %N failed for peer %D",
|
||||
@@ -290,11 +309,8 @@ static status_t process(private_eap_authenticator_t *this, eap_payload_t *in,
|
||||
if (this->method->get_msk(this->method, &this->msk) == SUCCESS)
|
||||
{
|
||||
this->msk = chunk_clone(this->msk);
|
||||
return SUCCESS;
|
||||
}
|
||||
DBG1(DBG_IKE, "EAP method %N has no MSK established",
|
||||
eap_type_names, this->method->get_type(this->method));
|
||||
return FAILED;
|
||||
return SUCCESS;
|
||||
}
|
||||
case EAP_FAILURE:
|
||||
default:
|
||||
|
||||
@@ -77,11 +77,12 @@ chunk_t build_tbs_octets(chunk_t ike_sa_init, chunk_t nonce,
|
||||
*/
|
||||
chunk_t build_shared_key_signature(chunk_t ike_sa_init, chunk_t nonce,
|
||||
chunk_t secret, identification_t *id,
|
||||
prf_t *prf_skp, prf_t *prf)
|
||||
chunk_t skp, prf_t *prf)
|
||||
{
|
||||
chunk_t key_pad, key, auth_data, octets;
|
||||
|
||||
octets = build_tbs_octets(ike_sa_init, nonce, id, prf_skp);
|
||||
prf->set_key(prf, skp);
|
||||
octets = build_tbs_octets(ike_sa_init, nonce, id, prf);
|
||||
/* AUTH = prf(prf(Shared Secret,"Key Pad for IKEv2"), <msg octets>) */
|
||||
key_pad.ptr = IKEV2_KEY_PAD;
|
||||
key_pad.len = IKEV2_KEY_PAD_LENGTH;
|
||||
@@ -121,7 +122,7 @@ static status_t verify(private_psk_authenticator_t *this, chunk_t ike_sa_init,
|
||||
}
|
||||
|
||||
auth_data = build_shared_key_signature(ike_sa_init, my_nonce, shared_key,
|
||||
other_id, this->ike_sa->get_auth_verify(this->ike_sa),
|
||||
other_id, this->ike_sa->get_skp_verify(this->ike_sa),
|
||||
this->ike_sa->get_prf(this->ike_sa));
|
||||
chunk_free(&shared_key);
|
||||
|
||||
@@ -164,7 +165,7 @@ static status_t build(private_psk_authenticator_t *this, chunk_t ike_sa_init,
|
||||
}
|
||||
|
||||
auth_data = build_shared_key_signature(ike_sa_init, other_nonce, shared_key,
|
||||
my_id, this->ike_sa->get_auth_build(this->ike_sa),
|
||||
my_id, this->ike_sa->get_skp_build(this->ike_sa),
|
||||
this->ike_sa->get_prf(this->ike_sa));
|
||||
DBG2(DBG_IKE, "successfully created shared key MAC");
|
||||
chunk_free(&shared_key);
|
||||
|
||||
@@ -62,6 +62,7 @@ static status_t verify(private_rsa_authenticator_t *this, chunk_t ike_sa_init,
|
||||
chunk_t auth_data, octets;
|
||||
rsa_public_key_t *public_key;
|
||||
identification_t *other_id;
|
||||
prf_t *prf;
|
||||
|
||||
other_id = this->ike_sa->get_other_id(this->ike_sa);
|
||||
|
||||
@@ -77,8 +78,9 @@ static status_t verify(private_rsa_authenticator_t *this, chunk_t ike_sa_init,
|
||||
DBG1(DBG_IKE, "no RSA public key found for '%D'", other_id);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
octets = build_tbs_octets(ike_sa_init, my_nonce, other_id,
|
||||
this->ike_sa->get_auth_verify(this->ike_sa));
|
||||
prf = this->ike_sa->get_prf(this->ike_sa);
|
||||
prf->set_key(prf, this->ike_sa->get_skp_verify(this->ike_sa));
|
||||
octets = build_tbs_octets(ike_sa_init, my_nonce, other_id, prf);
|
||||
status = public_key->verify_emsa_pkcs1_signature(public_key, octets, auth_data);
|
||||
chunk_free(&octets);
|
||||
|
||||
@@ -106,6 +108,7 @@ static status_t build(private_rsa_authenticator_t *this, chunk_t ike_sa_init,
|
||||
rsa_public_key_t *my_pubkey;
|
||||
rsa_private_key_t *my_key;
|
||||
identification_t *my_id;
|
||||
prf_t *prf;
|
||||
|
||||
my_id = this->ike_sa->get_my_id(this->ike_sa);
|
||||
DBG1(DBG_IKE, "authentication of '%D' (myself) with %N",
|
||||
@@ -130,8 +133,9 @@ static status_t build(private_rsa_authenticator_t *this, chunk_t ike_sa_init,
|
||||
}
|
||||
DBG2(DBG_IKE, "matching RSA private key found");
|
||||
|
||||
octets = build_tbs_octets(ike_sa_init, other_nonce, my_id,
|
||||
this->ike_sa->get_auth_build(this->ike_sa));
|
||||
prf = this->ike_sa->get_prf(this->ike_sa);
|
||||
prf->set_key(prf, this->ike_sa->get_skp_build(this->ike_sa));
|
||||
octets = build_tbs_octets(ike_sa_init, other_nonce, my_id, prf);
|
||||
status = my_key->build_emsa_pkcs1_signature(my_key, HASH_SHA1, octets, &auth_data);
|
||||
chunk_free(&octets);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user