EAP-AKA': Use SHA256 for AT_CHECKCODE
This commit is contained in:
parent
f09d19d46a
commit
f54e2c34bf
4 changed files with 46 additions and 20 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "eap_common/eap_sim_common.h"
|
||||
#include "eap_server/eap_sim_db.h"
|
||||
#include "sha1.h"
|
||||
#include "sha256.h"
|
||||
#include "crypto.h"
|
||||
|
||||
|
||||
|
@ -149,7 +150,7 @@ static void eap_aka_add_checkcode(struct eap_aka_data *data,
|
|||
{
|
||||
const u8 *addr;
|
||||
size_t len;
|
||||
u8 hash[SHA1_MAC_LEN];
|
||||
u8 hash[SHA256_MAC_LEN];
|
||||
|
||||
wpa_printf(MSG_DEBUG, " AT_CHECKCODE");
|
||||
|
||||
|
@ -166,10 +167,14 @@ static void eap_aka_add_checkcode(struct eap_aka_data *data,
|
|||
addr = wpabuf_head(data->id_msgs);
|
||||
len = wpabuf_len(data->id_msgs);
|
||||
wpa_hexdump(MSG_MSGDUMP, "EAP-AKA: AT_CHECKCODE data", addr, len);
|
||||
sha1_vector(1, &addr, &len, hash);
|
||||
if (data->eap_method == EAP_TYPE_AKA_PRIME)
|
||||
sha256_vector(1, &addr, &len, hash);
|
||||
else
|
||||
sha1_vector(1, &addr, &len, hash);
|
||||
|
||||
eap_sim_msg_add(msg, EAP_SIM_AT_CHECKCODE, 0, hash,
|
||||
EAP_AKA_CHECKCODE_LEN);
|
||||
data->eap_method == EAP_TYPE_AKA_PRIME ?
|
||||
EAP_AKA_PRIME_CHECKCODE_LEN : EAP_AKA_CHECKCODE_LEN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,7 +183,8 @@ static int eap_aka_verify_checkcode(struct eap_aka_data *data,
|
|||
{
|
||||
const u8 *addr;
|
||||
size_t len;
|
||||
u8 hash[SHA1_MAC_LEN];
|
||||
u8 hash[SHA256_MAC_LEN];
|
||||
size_t hash_len;
|
||||
|
||||
if (checkcode == NULL)
|
||||
return -1;
|
||||
|
@ -193,7 +199,10 @@ static int eap_aka_verify_checkcode(struct eap_aka_data *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (checkcode_len != EAP_AKA_CHECKCODE_LEN) {
|
||||
hash_len = data->eap_method == EAP_TYPE_AKA_PRIME ?
|
||||
EAP_AKA_PRIME_CHECKCODE_LEN : EAP_AKA_CHECKCODE_LEN;
|
||||
|
||||
if (checkcode_len != hash_len) {
|
||||
wpa_printf(MSG_DEBUG, "EAP-AKA: Checkcode from peer indicates "
|
||||
"that AKA/Identity message were not used, but they "
|
||||
"were");
|
||||
|
@ -203,9 +212,12 @@ static int eap_aka_verify_checkcode(struct eap_aka_data *data,
|
|||
/* Checkcode is SHA1 hash over all EAP-AKA/Identity packets. */
|
||||
addr = wpabuf_head(data->id_msgs);
|
||||
len = wpabuf_len(data->id_msgs);
|
||||
sha1_vector(1, &addr, &len, hash);
|
||||
if (data->eap_method == EAP_TYPE_AKA_PRIME)
|
||||
sha256_vector(1, &addr, &len, hash);
|
||||
else
|
||||
sha1_vector(1, &addr, &len, hash);
|
||||
|
||||
if (os_memcmp(hash, checkcode, EAP_AKA_CHECKCODE_LEN) != 0) {
|
||||
if (os_memcmp(hash, checkcode, hash_len) != 0) {
|
||||
wpa_printf(MSG_DEBUG, "EAP-AKA: Mismatch in AT_CHECKCODE");
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue