mirror of https://github.com/wolfSSL/wolfssl.git
Added unit test for wc_ecc_get_curve_id_from_dp_params
parent
f8c9285b92
commit
6b51f2d5b2
44
tests/api.c
44
tests/api.c
|
@ -22701,6 +22701,48 @@ static void test_wc_ecc_get_curve_id_from_name(void)
|
|||
#endif /* HAVE_ECC */
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_EXTRA)
|
||||
static void test_wc_ecc_get_curve_id_from_dp_params(void)
|
||||
{
|
||||
#ifdef HAVE_ECC
|
||||
int id;
|
||||
int curve_id;
|
||||
int ret = 0;
|
||||
WOLFSSL_EC_KEY *ecKey;
|
||||
ecc_key* key;
|
||||
const ecc_set_type* params;
|
||||
|
||||
printf(testingFmt, "wc_ecc_get_curve_id_from_dp_params");
|
||||
|
||||
#if !defined(NO_ECC256) && !defined(NO_ECC_SECP)
|
||||
id = wc_ecc_get_curve_id_from_name("SECP256R1");
|
||||
AssertIntEQ(id, ECC_SECP256R1);
|
||||
#endif
|
||||
|
||||
ecKey = wolfSSL_EC_KEY_new_by_curve_name(id);
|
||||
AssertNotNull(ecKey);
|
||||
|
||||
ret = wolfSSL_EC_KEY_generate_key(ecKey);
|
||||
|
||||
if (ret == 0) {
|
||||
/* normal test */
|
||||
key = (ecc_key*)ecKey->internal;
|
||||
params = key->dp;
|
||||
|
||||
curve_id = wc_ecc_get_curve_id_from_dp_params(params);
|
||||
AssertIntEQ(curve_id, id);
|
||||
}
|
||||
|
||||
/* invalid case, NULL input*/
|
||||
|
||||
id = wc_ecc_get_curve_id_from_dp_params(NULL);
|
||||
AssertIntEQ(id, BAD_FUNC_ARG);
|
||||
|
||||
printf(resultFmt, passed);
|
||||
#endif /* HAVE_ECC */
|
||||
}
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
static void test_wc_ecc_get_curve_id_from_params(void)
|
||||
{
|
||||
#ifdef HAVE_ECC
|
||||
|
@ -24501,7 +24543,6 @@ void ApiTest(void)
|
|||
test_wc_ecc_get_curve_size_from_name();
|
||||
test_wc_ecc_get_curve_id_from_name();
|
||||
test_wc_ecc_get_curve_id_from_params();
|
||||
|
||||
#ifdef WOLFSSL_TLS13
|
||||
/* TLS v1.3 API tests */
|
||||
test_tls13_apis();
|
||||
|
@ -24648,6 +24689,7 @@ void ApiTest(void)
|
|||
test_wolfSSL_EVP_get_cipherbynid();
|
||||
test_wolfSSL_EC();
|
||||
test_wolfSSL_ECDSA_SIG();
|
||||
test_wc_ecc_get_curve_id_from_dp_params();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HASHDRBG
|
||||
|
|
|
@ -155,7 +155,9 @@
|
|||
#pragma warning(disable:4244 4996)
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_CIPHER_LIST_MAX_SIZE
|
||||
#define WOLFSSL_CIPHER_LIST_MAX_SIZE 4096
|
||||
#endif
|
||||
/* Buffer for benchmark tests */
|
||||
#ifndef TEST_BUFFER_SIZE
|
||||
#define TEST_BUFFER_SIZE 16384
|
||||
|
|
Loading…
Reference in New Issue