From 52c6710783d9bdfa5be7226d505ffce4445955c3 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 8 Dec 2022 08:59:00 -0800 Subject: [PATCH 1/2] Fix `test_wc_ecc_import_raw` to handle `ECC_INF_E` or `MP_VAL` on point failures. SP math returns `MP_VAL` in `sp_256_ecc_is_point_4`. --- tests/api.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/api.c b/tests/api.c index c3fa9d2b4..51e5b8948 100644 --- a/tests/api.c +++ b/tests/api.c @@ -25479,9 +25479,11 @@ static int test_wc_ecc_import_raw(void) ret = wc_ecc_init(&key); + /* Test good import */ if (ret == 0) { ret = wc_ecc_import_raw(&key, qx, qy, d, curveName); } + /* Test bad args. */ if (ret == 0) { ret = wc_ecc_import_raw(NULL, qx, qy, d, curveName); @@ -25510,14 +25512,23 @@ static int test_wc_ecc_import_raw(void) wc_ecc_free(&key); #endif ret = wc_ecc_import_raw(&key, "0", qy, d, curveName); + /* Note: SP math "is point" failure returns MP_VAL */ + if (ret == ECC_INF_E || ret == MP_VAL) { + ret = BAD_FUNC_ARG; /* This is expected by other tests */ + } } if (ret == BAD_FUNC_ARG) { #if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH) wc_ecc_free(&key); #endif ret = wc_ecc_import_raw(&key, qx, "0", d, curveName); + /* Note: SP math "is point" failure returns MP_VAL */ + if (ret == ECC_INF_E || ret == MP_VAL) { + ret = BAD_FUNC_ARG; /* This is expected by other tests */ + } } #endif + if (ret == BAD_FUNC_ARG) { ret = 0; } From 793bd6620b43c74b29cbdf965bd32fc8ba6e7423 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 9 Dec 2022 10:36:35 -0800 Subject: [PATCH 2/2] Fix unicode char in logging.c. --- wolfcrypt/src/logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index f2b9f345f..ef2a76d6d 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -684,7 +684,7 @@ int wc_ERR_remove_state(void) * In case all entries are ignored, the ERR queue will be empty afterwards. * For an empty ERR queue 0 is returned. * - * ìgnore_err` may be NULL, in which case this returns the HEAD values. + * `ignore_err` may be NULL, in which case this returns the HEAD values. * * `flags` is present for OpenSSL compatibility, but will always be * set to 0, since we do not keep flags at ERR entries.