From 52b1cb5d73d56798698f0d18292d3b332928ac36 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 13 Apr 2019 12:53:42 +0300 Subject: [PATCH] tests: crypto_hash_finish() failure in eap_pwd_kdf() Signed-off-by: Jouni Malinen --- src/crypto/crypto_internal.c | 3 +++ src/crypto/crypto_libtomcrypt.c | 3 +++ src/crypto/crypto_linux.c | 3 +++ src/crypto/crypto_openssl.c | 3 +++ src/crypto/crypto_wolfssl.c | 2 ++ tests/hwsim/test_eap_proto.py | 24 +++++++++++++----------- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/crypto/crypto_internal.c b/src/crypto/crypto_internal.c index d391f48ab..aad40af16 100644 --- a/src/crypto/crypto_internal.c +++ b/src/crypto/crypto_internal.c @@ -310,6 +310,9 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) os_free(ctx); + if (TEST_FAIL()) + return -1; + return 0; } diff --git a/src/crypto/crypto_libtomcrypt.c b/src/crypto/crypto_libtomcrypt.c index 980fa4227..ed30efa02 100644 --- a/src/crypto/crypto_libtomcrypt.c +++ b/src/crypto/crypto_libtomcrypt.c @@ -278,6 +278,9 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) os_free(ctx); + if (TEST_FAIL()) + return -1; + return ret; } diff --git a/src/crypto/crypto_linux.c b/src/crypto/crypto_linux.c index 8099193bf..17244561b 100644 --- a/src/crypto/crypto_linux.c +++ b/src/crypto/crypto_linux.c @@ -386,6 +386,9 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) } crypto_hash_deinit(ctx); + + if (TEST_FAIL()) + return -1; return 0; } diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 0f52101ea..9672f711c 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -1054,6 +1054,9 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) HMAC_CTX_free(ctx->ctx); bin_clear_free(ctx, sizeof(*ctx)); + if (TEST_FAIL()) + return -1; + if (res == 1) { *len = mdlen; return 0; diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index 10cdae604..07ad1aa4a 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -953,6 +953,8 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) ret = 0; done: bin_clear_free(ctx, sizeof(*ctx)); + if (TEST_FAIL()) + return -1; return ret; } diff --git a/tests/hwsim/test_eap_proto.py b/tests/hwsim/test_eap_proto.py index 971ae8cbc..b6b42bcc2 100644 --- a/tests/hwsim/test_eap_proto.py +++ b/tests/hwsim/test_eap_proto.py @@ -6783,17 +6783,19 @@ def test_eap_proto_pwd_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - with fail_test(dev[0], 1, - "hash_nt_password_hash;eap_pwd_perform_commit_exchange"): - dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", - eap="PWD", identity="pwd-hash", - password_hex="hash:e3718ece8ab74792cbbfffd316d2d19a", - wait_connect=False) - ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10) - if ev is None: - raise Exception("No EAP-Failure reported") - dev[0].request("REMOVE_NETWORK all") - dev[0].wait_disconnected() + funcs = ["hash_nt_password_hash;eap_pwd_perform_commit_exchange", + "crypto_hash_finish;eap_pwd_kdf"] + for func in funcs: + with fail_test(dev[0], 1, func): + dev[0].connect("eap-test", key_mgmt="WPA-EAP", scan_freq="2412", + eap="PWD", identity="pwd-hash", + password_hex="hash:e3718ece8ab74792cbbfffd316d2d19a", + wait_connect=False) + ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10) + if ev is None: + raise Exception("No EAP-Failure reported") + dev[0].request("REMOVE_NETWORK all") + dev[0].wait_disconnected() params = {"ssid": "eap-test2", "wpa": "2", "wpa_key_mgmt": "WPA-EAP", "rsn_pairwise": "CCMP", "ieee8021x": "1",