add sha256 hardware acceleration

This commit is contained in:
JacobBarthelmeh
2020-01-31 14:26:04 -08:00
parent 3508579f4c
commit 6ec136208c

View File

@ -544,6 +544,42 @@ static int InitSha256(wc_Sha256* sha256)
#elif defined(WOLFSSL_DEVCRYPTO_HASH) #elif defined(WOLFSSL_DEVCRYPTO_HASH)
/* implemented in wolfcrypt/src/port/devcrypto/devcrypt_hash.c */ /* implemented in wolfcrypt/src/port/devcrypto/devcrypt_hash.c */
#elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_HASH)
#include "hal_data.h"
#ifndef WOLFSSL_SCE_SHA256_HANDLE
#define WOLFSSL_SCE_SHA256_HANDLE g_sce_hash_0
#endif
#define XTRANSFORM(S, D) wc_Sha256SCE_XTRANSFORM((S), (D))
static int wc_Sha256SCE_XTRANSFORM(wc_Sha256* sha256, const byte* data)
{
if (WOLFSSL_SCE_SHA256_HANDLE.p_api->hashUpdate(WOLFSSL_SCE_SHA256_HANDLE.p_ctrl,
(word32*)data, 8, sha256->digest) != SSP_SUCCESS) {
WOLFSSL_MSG("Unexpected hardware return value");
return WC_HW_E;
}
return 0;
}
int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
{
int ret = 0;
if (sha256 == NULL)
return BAD_FUNC_ARG;
sha256->heap = heap;
ret = InitSha256(sha256);
if (ret != 0)
return ret;
(void)devId;
return ret;
}
#elif defined(WOLFSSL_ESP32WROOM32_CRYPT) && \ #elif defined(WOLFSSL_ESP32WROOM32_CRYPT) && \
!defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH) !defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_HASH)