]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
EAP-IKEv2: Use os_memcmp_const() for hash/password comparisons
authorJouni Malinen <j@w1.fi>
Sun, 29 Jun 2014 17:18:40 +0000 (20:18 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 2 Jul 2014 09:38:47 +0000 (12:38 +0300)
This makes the implementation less likely to provide useful timing
information to potential attackers from comparisons of information
received from a remote device and private material known only by the
authorized devices.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/eap_common/eap_ikev2_common.c
src/eap_common/ikev2_common.c
src/eap_peer/ikev2.c
src/eap_server/ikev2.c

index da9f3cc59ae4425ac7aab88775758be39c15d702..585c79c47052e814b38859d7ddb2c3bf8de83150 100644 (file)
@@ -100,7 +100,7 @@ int eap_ikev2_validate_icv(int integ_alg, struct ikev2_keys *keys,
                return -1;
        }
 
-       if (os_memcmp(icv, end - icv_len, icv_len) != 0) {
+       if (os_memcmp_const(icv, end - icv_len, icv_len) != 0) {
                wpa_printf(MSG_INFO, "EAP-IKEV2: Invalid ICV");
                wpa_hexdump(MSG_DEBUG, "EAP-IKEV2: Calculated ICV",
                            icv, icv_len);
index b98a3e8e37ceed3b7314900514214bc07d69e90e..3d4fb6f927d0b581ea3cb12462040add6cc57724 100644 (file)
@@ -477,7 +477,7 @@ u8 * ikev2_decrypt_payload(int encr_id, int integ_id,
                           "hash");
                return NULL;
        }
-       if (os_memcmp(integ, hash, integ_alg->hash_len) != 0) {
+       if (os_memcmp_const(integ, hash, integ_alg->hash_len) != 0) {
                wpa_printf(MSG_INFO, "IKEV2: Incorrect Integrity Checksum "
                           "Data");
                return NULL;
index fb2f6199d6129f74cb5aa6d363871b3a3e8f136f..8186afb53e299d05263aa524832fd9ea2f86e732 100644 (file)
@@ -565,7 +565,7 @@ static int ikev2_process_auth_secret(struct ikev2_responder_data *data,
                return -1;
 
        if (auth_len != prf->hash_len ||
-           os_memcmp(auth, auth_data, auth_len) != 0) {
+           os_memcmp_const(auth, auth_data, auth_len) != 0) {
                wpa_printf(MSG_INFO, "IKEV2: Invalid Authentication Data");
                wpa_hexdump(MSG_DEBUG, "IKEV2: Received Authentication Data",
                            auth, auth_len);
index 512ba30747e59970411f8fa6f6cacc42f71b93cc..632598fac72ae6950ffe56c3791f897146dc8e90 100644 (file)
@@ -633,7 +633,7 @@ static int ikev2_process_auth_secret(struct ikev2_initiator_data *data,
                return -1;
 
        if (auth_len != prf->hash_len ||
-           os_memcmp(auth, auth_data, auth_len) != 0) {
+           os_memcmp_const(auth, auth_data, auth_len) != 0) {
                wpa_printf(MSG_INFO, "IKEV2: Invalid Authentication Data");
                wpa_hexdump(MSG_DEBUG, "IKEV2: Received Authentication Data",
                            auth, auth_len);