From 0c61a5b1fdfab75eb8afb0c31652cec3f4034b4a Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Wed, 5 Apr 2017 11:18:47 -0600 Subject: [PATCH] add invalid test case for wc_ecc_get_curve_id_from_params() --- tests/api.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/api.c b/tests/api.c index 270839803..85da22241 100644 --- a/tests/api.c +++ b/tests/api.c @@ -3140,6 +3140,14 @@ static void test_wc_ecc_get_curve_id_from_params(void) 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF }; + const byte primeInvalid[] = + { + 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x01 + }; + const byte Af[] = { 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x01, @@ -3198,12 +3206,19 @@ static void test_wc_ecc_get_curve_id_from_params(void) Gx, sizeof(Gx), Gy, sizeof(Gy), cofactor); AssertIntEQ(id, ECC_CURVE_INVALID); - /* invalid case, NULL prime */ + /* invalid case, NULL prime */ id = wc_ecc_get_curve_id_from_params(fieldSize, NULL, sizeof(prime), Af, sizeof(Af), Bf, sizeof(Bf), order, sizeof(order), Gx, sizeof(Gx), Gy, sizeof(Gy), cofactor); AssertIntEQ(id, BAD_FUNC_ARG); + /* invalid case, invalid prime */ + id = wc_ecc_get_curve_id_from_params(fieldSize, + primeInvalid, sizeof(primeInvalid), + Af, sizeof(Af), Bf, sizeof(Bf), order, sizeof(order), + Gx, sizeof(Gx), Gy, sizeof(Gy), cofactor); + AssertIntEQ(id, ECC_CURVE_INVALID); + printf(resultFmt, passed); #endif }