1

(3 replies, posted in wolfCrypt)

Hi there,

I'm trying to use the STM32WB55's PKA to generate and verify signatures in wolfCrypt 4.7. Whenever I call wc_ecc_verify_hash(), res is set to 0, as returned by HAL_PKA_ECDSAVerif_IsValidSignature() in stm32.c. If I turn PKA support off, res is set to 1.

In my example below, I'm hashing the input, generating a signature, and verifying it. wolfCrypt is configured to use static memory with a buffer size of 16KB. I have also attached the configuration file generated by STM32CubeIDE.

Due to timing and energy constraints, I need to use the PKA. Is there something that I'm missing to get the PKA to work?

Example:
    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);


    // Produce a hash of the input data
    wc_ret = wc_Hash(WC_HASH_TYPE_SHA256, test, sizeof(test), hash, hash_len);
    wc_ret |= wc_ecc_sign_hash(hash, hash_len, sig, (word32*)&sigLen, &rng, &key);
    wc_ret |= wc_ecc_verify_hash(sig, sigLen, hash, hash_len, (int*)&isVerified, &key);

That worked, thank you, David!

Hi,

I'm trying to prototype SRP on an STM32WB55 chip using STM32CubeIDE. I can compile my test program just fine when WOLF_CONF_MATH is set to 1 (FAST); however, in order to try to speed things up, I would like to use SP Cortex-M math. I can't get the program to compile when I set WOLF_CONF_MATH to 4. I keep getting compile errors to undefined reference to sp_submod. Is there anything special I need to do to get this to work?

I have attached my wolfSSL config file for your reference.

Thanks!