Hi,
I've noticed that when using the CC310 hardware accelerated cryptographic backend the call to nrf_crypto_hash_compute() seems to return an error (not supported) despite using a supported hash, SHA256. This seems to be related to this check:
if (!hash_algorithm_get(hash_info.hash_type, &hash_type))
{
return NRF_ERROR_NOT_SUPPORTED;
}
The hash_algorithm_get function will always return 0 if it is successful though because NRF_SUCCESS is 0, as shown:
bool hash_algorithm_get(nrf_hash_type_t hash_type, CRYS_HASH_OperationMode_t * p_hash_mode)
{
if (p_hash_mode == NULL)
{
return false;
}
switch (hash_type)
{
case NRF_CRYPTO_HASH_TYPE_MD5:
(*p_hash_mode) = CRYS_HASH_MD5_mode;
break;
...
case NRF_CRYPTO_HASH_TYPE_SHA512:
(*p_hash_mode) = CRYS_HASH_SHA512_mode;
break;
default:
return NRF_ERROR_NOT_SUPPORTED;
}
return NRF_SUCCESS;
}
Should the line therefore be negated?
`
if (hash_algorithm_get(hash_info.hash_type, &hash_type))
{
return NRF_ERROR_NOT_SUPPORTED;
}