forked from wolfSSL/wolfssl
Added unit test for wc_ecc_get_curve_id_from_dp_params
This commit is contained in:
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 */
|
#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)
|
static void test_wc_ecc_get_curve_id_from_params(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
@@ -24501,7 +24543,6 @@ void ApiTest(void)
|
|||||||
test_wc_ecc_get_curve_size_from_name();
|
test_wc_ecc_get_curve_size_from_name();
|
||||||
test_wc_ecc_get_curve_id_from_name();
|
test_wc_ecc_get_curve_id_from_name();
|
||||||
test_wc_ecc_get_curve_id_from_params();
|
test_wc_ecc_get_curve_id_from_params();
|
||||||
|
|
||||||
#ifdef WOLFSSL_TLS13
|
#ifdef WOLFSSL_TLS13
|
||||||
/* TLS v1.3 API tests */
|
/* TLS v1.3 API tests */
|
||||||
test_tls13_apis();
|
test_tls13_apis();
|
||||||
@@ -24648,6 +24689,7 @@ void ApiTest(void)
|
|||||||
test_wolfSSL_EVP_get_cipherbynid();
|
test_wolfSSL_EVP_get_cipherbynid();
|
||||||
test_wolfSSL_EC();
|
test_wolfSSL_EC();
|
||||||
test_wolfSSL_ECDSA_SIG();
|
test_wolfSSL_ECDSA_SIG();
|
||||||
|
test_wc_ecc_get_curve_id_from_dp_params();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_HASHDRBG
|
#ifdef HAVE_HASHDRBG
|
||||||
|
@@ -155,10 +155,12 @@
|
|||||||
#pragma warning(disable:4244 4996)
|
#pragma warning(disable:4244 4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WOLFSSL_CIPHER_LIST_MAX_SIZE 4096
|
#ifndef WOLFSSL_CIPHER_LIST_MAX_SIZE
|
||||||
|
#define WOLFSSL_CIPHER_LIST_MAX_SIZE 4096
|
||||||
|
#endif
|
||||||
/* Buffer for benchmark tests */
|
/* Buffer for benchmark tests */
|
||||||
#ifndef TEST_BUFFER_SIZE
|
#ifndef TEST_BUFFER_SIZE
|
||||||
#define TEST_BUFFER_SIZE 16384
|
#define TEST_BUFFER_SIZE 16384
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WOLFSSL_HAVE_MIN
|
#ifndef WOLFSSL_HAVE_MIN
|
||||||
|
Reference in New Issue
Block a user