This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52832 DK ecdsa signing internal error

I am trying to work with ECC signing on the SDK 13.0.0. I can create the public key and compute the hash without errors. However, the ecdsa_sign_hash always returns the NRF_ERROR_INTERNAL. What am i missing. As far as I know I am following the documentation.

__ALIGN(4) uint8_t privatekeyRaw[32] = { 0xd8,0x17,0x11,0xae,0xab,0x6f,0x75,0xc3,0xcb,0xd3,0xe4,0x17,0x9d,0xfc,0xd2,0x53,0xb4,0x04,0xbc,0x5d,0xfb,0xfb,0x28,0xf9,0x49,0xc3,0xe0,0xcc,0xbf,0xea,0x94,0xf6 };
__ALIGN(4) uint8_t hashText[1] = {0x41};

NRF_CRYPTO_ECC_PRIVATE_KEY_RAW_CREATE(privateKey,SECP256R1);

NRF_CRYPTO_ECC_PUBLIC_KEY_CREATE(publicKey, SECP256R1);

NRF_CRYPTO_HASH_CREATE(hashStruct, SHA256);

const nrf_crypto_hash_info_t hash_info_sha256 =
{
    .hash_type = NRF_CRYPTO_HASH_TYPE_SHA256,
    .endian_type = NRF_CRYPTO_ENDIAN_BE
};

NRF_CRYPTO_ECDSA_SIGNATURE_CREATE(crypto_sig, SECP256R1);


const nrf_crypto_signature_info_t sig_info_p256 =
{
    .curve_type     = NRF_CRYPTO_CURVE_SECP256R1,
    .hash_type      = NRF_CRYPTO_HASH_TYPE_SHA256,
    .endian_type    = NRF_CRYPTO_ENDIAN_BE
};

int main(void)
{
	privateKey.p_value=privatekeyRaw;

    ret_code_t err_code = nrf_crypto_init();
    APP_ERROR_CHECK(err_code);

    err_code = nrf_crypto_ecc_public_key_calculate(BLE_LESC_CURVE_TYPE_INFO,&privateKey, &publicKey);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_crypto_hash_compute(hash_info_sha256 ,hashText, 1, &hashStruct);
    APP_ERROR_CHECK(err_code);

    err_code=nrf_crypto_ecdsa_sign_hash(sig_info_p256,&privateKey, &hashStruct, &crypto_sig);
    APP_ERROR_CHECK(err_code);

    while(1){
	}
}
Related