Hi Keeperp,
At first I ran this test on my STM32WB55 and it worked, but realized you were using math = 1 (fast math) and I was using SP math.
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/hash.h>
void custom_test(void)
{
void* _wcHeapHint = NULL;
int wc_ret;
ecc_key key;
uint32_t keysize = wc_ecc_get_curve_size_from_id(ECC_SECP256R1);
WC_RNG rng;
byte test[] = "sunny days!", sig[72];
memset(sig, 0, sizeof(sig));
uint32_t sigLen = sizeof(sig);
uint8_t hash[WC_SHA256_DIGEST_SIZE];
memset(hash, 0, sizeof(hash));
uint32_t hash_len = WC_SHA256_DIGEST_SIZE;
int32_t isVerified = 0;
//HAL_PKA_Init(&hpka);
wc_ret = wc_InitRng_ex(&rng, _wcHeapHint, INVALID_DEVID);
wc_ret |= wc_ecc_init_ex(&key, _wcHeapHint, INVALID_DEVID);
wc_ret |= wc_ecc_make_key_ex(&rng, keysize, &key, ECC_SECP256R1);
printf("Make Key %d\n", wc_ret);
// Produce a hash of the input data
wc_ret = wc_Hash(WC_HASH_TYPE_SHA256, test, sizeof(test), hash, hash_len);
printf("HASH %d\n", wc_ret);
wc_ret = wc_ecc_sign_hash(hash, hash_len, sig, (word32*)&sigLen, &rng, &key);
printf("SIGN %d\n", wc_ret);
wc_ret = wc_ecc_verify_hash(sig, sigLen, hash, hash_len, (int*)&isVerified, &key);
printf("VERIFY %d, %d\n", wc_ret, isVerified);
}
Results:
Make Key 0
HASH 0
SIGN 0
VERIFY 0, 1
I am debugging the fast math case and should have a fix shortly.
Thanks,
David Garske, wolfSSL