Merge "fix(mbedtls): fix error return code for calc_hash" into integration
diff --git a/drivers/auth/mbedtls/mbedtls_crypto.c b/drivers/auth/mbedtls/mbedtls_crypto.c
index 9bfcaac..8fe426b 100644
--- a/drivers/auth/mbedtls/mbedtls_crypto.c
+++ b/drivers/auth/mbedtls/mbedtls_crypto.c
@@ -275,6 +275,7 @@
unsigned char output[CRYPTO_MD_MAX_SIZE])
{
const mbedtls_md_info_t *md_info;
+ int rc;
md_info = mbedtls_md_info_from_type(md_type(md_algo));
if (md_info == NULL) {
@@ -286,7 +287,12 @@
* 'output' hash buffer pointer considering its size is always
* bigger than or equal to MBEDTLS_MD_MAX_SIZE.
*/
- return mbedtls_md(md_info, data_ptr, data_len, output);
+ rc = mbedtls_md(md_info, data_ptr, data_len, output);
+ if (rc != 0) {
+ return CRYPTO_ERR_HASH;
+ }
+
+ return CRYPTO_SUCCESS;
}
#endif /* CRYPTO_SUPPORT == CRYPTO_HASH_CALC_ONLY || \
CRYPTO_SUPPORT == CRYPTO_AUTH_VERIFY_AND_HASH_CALC */