Merge pull request #1571 from aaronjense/unit-test-curve25519

Added unit-test for wc_curve25519_init and wc_curve25519_free
pull/1575/head
Chris Conlon 2018-05-21 13:42:11 -06:00 committed by GitHub
commit 6e13bfcfce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 0 deletions

View File

@ -265,6 +265,10 @@
#include <wolfssl/wolfcrypt/ed25519.h>
#endif
#ifdef HAVE_CURVE25519
#include <wolfssl/wolfcrypt/curve25519.h>
#endif
#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL))
#include <wolfssl/openssl/ssl.h>
#ifndef NO_ASN
@ -12115,6 +12119,43 @@ static int test_wc_ed25519_exportKey (void)
} /* END test_wc_ed25519_exportKey */
/*
* Testing wc_curve25519_init and wc_curve25519_free.
*/
static int test_wc_curve25519_init (void)
{
int ret = 0;
#if defined(HAVE_CURVE25519)
curve25519_key key;
printf(testingFmt, "wc_curve25519_init()");
ret = wc_curve25519_init(&key);
/* Test bad args for wc_curve25519_init */
if (ret == 0) {
ret = wc_curve25519_init(NULL);
if (ret == BAD_FUNC_ARG) {
ret = 0;
} else if (ret == 0) {
ret = SSL_FATAL_ERROR;
}
}
printf(resultFmt, ret == 0 ? passed : failed);
/* Test good args for wc_curve_25519_free */
wc_curve25519_free(&key);
wc_curve25519_free(NULL);
#endif
return ret;
} /* END test_wc_curve25519_init and wc_curve_25519_free*/
/*
* Testing wc_ecc_make_key.
*/
@ -18842,6 +18883,8 @@ void ApiTest(void)
AssertIntEQ(test_wc_ed25519_size(), 0);
AssertIntEQ(test_wc_ed25519_exportKey(), 0);
AssertIntEQ(test_wc_curve25519_init(), 0);
AssertIntEQ(test_wc_ecc_make_key(), 0);
AssertIntEQ(test_wc_ecc_init(), 0);
AssertIntEQ(test_wc_ecc_check_key(), 0);