]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
EAP-GPSK: Check HMAC-SHA256 result in GKDF and MIC
authorJouni Malinen <j@w1.fi>
Sat, 17 Oct 2015 17:19:52 +0000 (20:19 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 17 Oct 2015 17:40:01 +0000 (20:40 +0300)
hmac_sha256() and hmac_sha256_vector() return a result code now, so use
that return value to terminate HMAC-SHA256-based GKDF/MIC similarly to
what was already done with the CMAC-based GKDF/MIC.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/eap_common/eap_gpsk_common.c

index 8c7ae27b933c2b28a75aedc364ddd8e54a4795e3..b0818797025f2381ddb95e2e130585c232b67993 100644 (file)
@@ -92,7 +92,8 @@ static int eap_gpsk_gkdf_sha256(const u8 *psk /* Y */,
        n = (len + hashlen - 1) / hashlen;
        for (i = 1; i <= n; i++) {
                WPA_PUT_BE16(ibuf, i);
-               hmac_sha256_vector(psk, 32, 2, addr, vlen, hash);
+               if (hmac_sha256_vector(psk, 32, 2, addr, vlen, hash))
+                       return -1;
                clen = left > hashlen ? hashlen : left;
                os_memcpy(opos, hash, clen);
                opos += clen;
@@ -534,8 +535,7 @@ int eap_gpsk_compute_mic(const u8 *sk, size_t sk_len, int vendor,
                break;
 #ifdef EAP_GPSK_SHA256
        case EAP_GPSK_CIPHER_SHA256:
-               hmac_sha256(sk, sk_len, data, len, mic);
-               ret = 0;
+               ret = hmac_sha256(sk, sk_len, data, len, mic);
                break;
 #endif /* EAP_GPSK_SHA256 */
        default:
@@ -545,5 +545,8 @@ int eap_gpsk_compute_mic(const u8 *sk, size_t sk_len, int vendor,
                break;
        }
 
+       if (ret)
+               wpa_printf(MSG_DEBUG, "EAP-GPSK: Could not compute MIC");
+
        return ret;
 }