From 6fe3ee722d38153b3cca650e2c69ea1d6c48745f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 13 Apr 2019 17:00:55 +0300 Subject: [PATCH] tests: EAP-pwd local failure in crypto_bignum_rand() Signed-off-by: Jouni Malinen --- src/crypto/crypto_openssl.c | 2 ++ src/crypto/crypto_wolfssl.c | 2 ++ tests/hwsim/test_eap_proto.py | 1 + 3 files changed, 5 insertions(+) diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 9672f711c..27e68f739 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -1320,6 +1320,8 @@ int crypto_bignum_to_bin(const struct crypto_bignum *a, int crypto_bignum_rand(struct crypto_bignum *r, const struct crypto_bignum *m) { + if (TEST_FAIL()) + return -1; return BN_rand_range((BIGNUM *) r, (const BIGNUM *) m) == 1 ? 0 : -1; } diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index 07ad1aa4a..6b2ac8c43 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -1085,6 +1085,8 @@ int crypto_bignum_rand(struct crypto_bignum *r, const struct crypto_bignum *m) int ret = 0; WC_RNG rng; + if (TEST_FAIL()) + return -1; if (wc_InitRng(&rng) != 0) return -1; if (mp_rand_prime((mp_int *) r, diff --git a/tests/hwsim/test_eap_proto.py b/tests/hwsim/test_eap_proto.py index 235f73192..e327b2f35 100644 --- a/tests/hwsim/test_eap_proto.py +++ b/tests/hwsim/test_eap_proto.py @@ -6794,6 +6794,7 @@ def test_eap_proto_pwd_errors(dev, apdev): (1, "crypto_bignum_to_bin;compute_password_element"), (1, "crypto_ec_point_compute_y_sqr;compute_password_element"), (1, "crypto_ec_point_solve_y_coord;compute_password_element"), + (1, "crypto_bignum_rand;compute_password_element"), (1, "crypto_bignum_sub;compute_password_element")] for count, func in funcs: with fail_test(dev[0], count, func):