mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
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
.
This commit is contained in:
11
tests/api.c
11
tests/api.c
@@ -25479,9 +25479,11 @@ static int test_wc_ecc_import_raw(void)
|
|||||||
|
|
||||||
ret = wc_ecc_init(&key);
|
ret = wc_ecc_init(&key);
|
||||||
|
|
||||||
|
/* Test good import */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_ecc_import_raw(&key, qx, qy, d, curveName);
|
ret = wc_ecc_import_raw(&key, qx, qy, d, curveName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test bad args. */
|
/* Test bad args. */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_ecc_import_raw(NULL, qx, qy, d, curveName);
|
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);
|
wc_ecc_free(&key);
|
||||||
#endif
|
#endif
|
||||||
ret = wc_ecc_import_raw(&key, "0", qy, d, curveName);
|
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 (ret == BAD_FUNC_ARG) {
|
||||||
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH)
|
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH)
|
||||||
wc_ecc_free(&key);
|
wc_ecc_free(&key);
|
||||||
#endif
|
#endif
|
||||||
ret = wc_ecc_import_raw(&key, qx, "0", d, curveName);
|
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
|
#endif
|
||||||
|
|
||||||
if (ret == BAD_FUNC_ARG) {
|
if (ret == BAD_FUNC_ARG) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user