forked from wolfSSL/wolfssl
Ed25519: fix tests to compile with feature defines
ge_operations.c: USe WOLFSSL_NO_MALLOC rather than WOLFSSL_SP_NO_MALLOC.
This commit is contained in:
@@ -54725,7 +54725,11 @@ static int test_wolfSSL_private_keys(void)
|
|||||||
ExpectNotNull(ssl = SSL_new(ctx));
|
ExpectNotNull(ssl = SSL_new(ctx));
|
||||||
|
|
||||||
#if !defined(NO_CHECK_PRIVATE_KEY)
|
#if !defined(NO_CHECK_PRIVATE_KEY)
|
||||||
|
#ifdef HAVE_ED25519_MAKE_KEY
|
||||||
ExpectIntNE(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
|
ExpectIntNE(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
|
||||||
|
#else
|
||||||
|
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SSL_free(ssl);
|
SSL_free(ssl);
|
||||||
|
@@ -9392,7 +9392,7 @@ B is the Ed25519 base point (x,4/5) with x positive.
|
|||||||
int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a,
|
int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a,
|
||||||
const ge_p3 *A, const unsigned char *b)
|
const ge_p3 *A, const unsigned char *b)
|
||||||
{
|
{
|
||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
signed char *aslide = NULL;
|
signed char *aslide = NULL;
|
||||||
signed char *bslide = NULL;
|
signed char *bslide = NULL;
|
||||||
ge_cached *Ai = NULL; /* A,3A,5A,7A,9A,11A,13A,15A */
|
ge_cached *Ai = NULL; /* A,3A,5A,7A,9A,11A,13A,15A */
|
||||||
@@ -9413,7 +9413,7 @@ int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a,
|
|||||||
#endif
|
#endif
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
if (((aslide = (signed char *)XMALLOC(SLIDE_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER))== NULL) ||
|
if (((aslide = (signed char *)XMALLOC(SLIDE_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER))== NULL) ||
|
||||||
((bslide = (signed char *)XMALLOC(SLIDE_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER))== NULL) ||
|
((bslide = (signed char *)XMALLOC(SLIDE_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER))== NULL) ||
|
||||||
((Ai = (ge_cached *)XMALLOC(8 * sizeof(*Ai), NULL, DYNAMIC_TYPE_TMP_BUFFER))== NULL) ||
|
((Ai = (ge_cached *)XMALLOC(8 * sizeof(*Ai), NULL, DYNAMIC_TYPE_TMP_BUFFER))== NULL) ||
|
||||||
@@ -9475,7 +9475,7 @@ int ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
out:
|
out:
|
||||||
|
|
||||||
XFREE(aslide, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(aslide, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
@@ -36697,23 +36697,33 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ed25519_test(void)
|
|||||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
wc_ed25519_init_ex(key, HEAP_HINT, devId);
|
ret = wc_ed25519_init_ex(key, HEAP_HINT, devId);
|
||||||
wc_ed25519_init_ex(key2, HEAP_HINT, devId);
|
if (ret != 0)
|
||||||
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
|
ret = wc_ed25519_init_ex(key2, HEAP_HINT, devId);
|
||||||
|
if (ret != 0)
|
||||||
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
#if !defined(NO_ASN) && defined(HAVE_ED25519_SIGN)
|
#if !defined(NO_ASN) && defined(HAVE_ED25519_SIGN)
|
||||||
wc_ed25519_init_ex(key3, HEAP_HINT, devId);
|
ret = wc_ed25519_init_ex(key3, HEAP_HINT, devId);
|
||||||
|
if (ret != 0)
|
||||||
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ED25519_MAKE_KEY
|
#ifdef HAVE_ED25519_MAKE_KEY
|
||||||
wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, key);
|
ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, key);
|
||||||
wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, key2);
|
if (ret != 0)
|
||||||
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
|
ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, key2);
|
||||||
|
if (ret != 0)
|
||||||
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* helper functions for signature and key size */
|
/* helper functions for signature and key size */
|
||||||
keySz = (word32)wc_ed25519_size(key);
|
keySz = (word32)wc_ed25519_size(key);
|
||||||
sigSz = (word32)wc_ed25519_sig_size(key);
|
sigSz = (word32)wc_ed25519_sig_size(key);
|
||||||
|
|
||||||
#if defined(HAVE_ED25519_SIGN) && defined(HAVE_ED25519_KEY_EXPORT) &&\
|
#if defined(HAVE_ED25519_SIGN) && defined(HAVE_ED25519_KEY_EXPORT) && \
|
||||||
defined(HAVE_ED25519_KEY_IMPORT)
|
defined(HAVE_ED25519_KEY_IMPORT)
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
outlen = sizeof(out);
|
outlen = sizeof(out);
|
||||||
@@ -36788,6 +36798,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ed25519_test(void)
|
|||||||
#endif /* HAVE_ED25519_VERIFY */
|
#endif /* HAVE_ED25519_VERIFY */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ED25519_VERIFY
|
||||||
{
|
{
|
||||||
/* Run tests for some rare code paths */
|
/* Run tests for some rare code paths */
|
||||||
/* sig is exactly equal to the order */
|
/* sig is exactly equal to the order */
|
||||||
@@ -36860,6 +36871,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ed25519_test(void)
|
|||||||
if (ret != WC_NO_ERR_TRACE(SIG_VERIFY_E))
|
if (ret != WC_NO_ERR_TRACE(SIG_VERIFY_E))
|
||||||
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup);
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_ED25519_VERIFY */
|
||||||
|
|
||||||
ret = ed25519ctx_test();
|
ret = ed25519ctx_test();
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@@ -36928,18 +36940,14 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ed25519_test(void)
|
|||||||
|
|
||||||
if (XMEMCMP(out, sigs[0], 64))
|
if (XMEMCMP(out, sigs[0], 64))
|
||||||
ERROR_OUT(WC_TEST_RET_ENC_NC, cleanup);
|
ERROR_OUT(WC_TEST_RET_ENC_NC, cleanup);
|
||||||
|
|
||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
|
||||||
wc_ed25519_delete(key3, &key3);
|
|
||||||
#else
|
|
||||||
wc_ed25519_free(key3);
|
|
||||||
#endif
|
|
||||||
#endif /* NO_ASN */
|
#endif /* NO_ASN */
|
||||||
#endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_EXPORT && HAVE_ED25519_KEY_IMPORT */
|
#endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_EXPORT && HAVE_ED25519_KEY_IMPORT */
|
||||||
|
|
||||||
|
#if defined(HAVE_ED25519_KEY_IMPORT)
|
||||||
ret = ed25519_test_check_key();
|
ret = ed25519_test_check_key();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
#endif
|
||||||
#ifdef WOLFSSL_TEST_CERT
|
#ifdef WOLFSSL_TEST_CERT
|
||||||
ret = ed25519_test_cert();
|
ret = ed25519_test_cert();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -36957,9 +36965,15 @@ cleanup:
|
|||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
wc_ed25519_delete(key, &key);
|
wc_ed25519_delete(key, &key);
|
||||||
wc_ed25519_delete(key2, &key2);
|
wc_ed25519_delete(key2, &key2);
|
||||||
|
#if !defined(NO_ASN) && defined(HAVE_ED25519_SIGN)
|
||||||
|
wc_ed25519_delete(key3, &key3);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
wc_ed25519_free(key);
|
wc_ed25519_free(key);
|
||||||
wc_ed25519_free(key2);
|
wc_ed25519_free(key2);
|
||||||
|
#if !defined(NO_ASN) && defined(HAVE_ED25519_SIGN)
|
||||||
|
wc_ed25519_free(key3);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
||||||
|
Reference in New Issue
Block a user