Refactor to use HASH_KEEP option instead of dedicated context for SHA, also add HASH_KEEP to sha1 context with correct init/free calls

This commit is contained in:
night1rider
2026-02-20 16:31:03 -07:00
parent 2f2fca6a91
commit c3b329eb2e
9 changed files with 348 additions and 549 deletions
+302 -444
View File
@@ -34,7 +34,7 @@
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#include <wolfssl/wolfcrypt/port/maxim/max3266x.h>
#include <wolfssl/wolfcrypt/hash.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
#else
@@ -136,123 +136,78 @@ int wc_MxcAesCryptoCb(wc_CryptoInfo* info)
#ifdef MAX3266X_SHA_CB
/* Shared callback handler: Update grows buffer, Final computes hash. */
static int wc_MxcShaCbDispatch(byte** msg, word32* used, word32* len,
void* heap, const byte* in, word32 inSz,
byte* digest, MXC_TPU_HASH_TYPE algo)
{
if (in != NULL && digest == NULL) {
MAX3266X_MSG("Update CB");
return _wc_Hash_Grow(msg, used, len, in, (int)inSz, heap);
}
if (in == NULL && digest != NULL) {
MAX3266X_MSG("Final CB");
return wc_MXC_TPU_SHA_Final(msg, used, len, heap, digest, algo);
}
if (inSz == 0) {
return 0; /* Don't need to Update when Size is Zero */
}
return BAD_FUNC_ARG;
}
int wc_MxcShaCryptoCb(wc_CryptoInfo* info)
{
switch (info->hash.type) {
#ifndef NO_SHA
case WC_HASH_TYPE_SHA:
MAX3266X_MSG("SHA-1 CB:");
/* Update Case */
if (info->hash.in != NULL && info->hash.digest == NULL) {
MAX3266X_MSG("Update CB");
return wc_MXC_TPU_SHA_Update(&(info->hash.sha1->mxcCtx),
info->hash.in, info->hash.inSz);
}
/* Sha 1 Final Case */
if (info->hash.in == NULL && info->hash.digest != NULL) {
MAX3266X_MSG("Final CB");
return wc_MXC_TPU_SHA_Final(&(info->hash.sha1->mxcCtx),
info->hash.digest,
MXC_TPU_HASH_SHA1);
}
break; /* Break Out and Return Error */
return wc_MxcShaCbDispatch(&info->hash.sha1->msg,
&info->hash.sha1->used, &info->hash.sha1->len,
info->hash.sha1->heap, info->hash.in,
info->hash.inSz, info->hash.digest,
MXC_TPU_HASH_SHA1);
#endif
#ifdef WOLFSSL_SHA224
case WC_HASH_TYPE_SHA224:
MAX3266X_MSG("SHA-224 CB:");
/* Update Case */
if (info->hash.in != NULL && info->hash.digest == NULL) {
MAX3266X_MSG("Update CB");
return wc_MXC_TPU_SHA_Update(&(info->hash.sha224->mxcCtx),
info->hash.in, info->hash.inSz);
}
/* Sha 256 Final Case */
if (info->hash.in == NULL && info->hash.digest != NULL) {
MAX3266X_MSG("Final CB");
return wc_MXC_TPU_SHA_Final(&(info->hash.sha224->mxcCtx),
info->hash.digest,
MXC_TPU_HASH_SHA224);
}
break; /* Break Out and Return Error */
return wc_MxcShaCbDispatch(&info->hash.sha224->msg,
&info->hash.sha224->used, &info->hash.sha224->len,
info->hash.sha224->heap, info->hash.in,
info->hash.inSz, info->hash.digest,
MXC_TPU_HASH_SHA224);
#endif
#ifndef NO_SHA256
case WC_HASH_TYPE_SHA256:
MAX3266X_MSG("SHA-256 CB:");
/* Update Case */
if (info->hash.in != NULL && info->hash.digest == NULL) {
MAX3266X_MSG("Update CB");
return wc_MXC_TPU_SHA_Update(&(info->hash.sha256->mxcCtx),
info->hash.in, info->hash.inSz);
}
/* Sha 256 Final Case */
if (info->hash.in == NULL && info->hash.digest != NULL) {
MAX3266X_MSG("Final CB");
return wc_MXC_TPU_SHA_Final(&(info->hash.sha256->mxcCtx),
info->hash.digest,
MXC_TPU_HASH_SHA256);
}
break; /* Break Out and Return Error */
return wc_MxcShaCbDispatch(&info->hash.sha256->msg,
&info->hash.sha256->used, &info->hash.sha256->len,
info->hash.sha256->heap, info->hash.in,
info->hash.inSz, info->hash.digest,
MXC_TPU_HASH_SHA256);
#endif
#ifdef WOLFSSL_SHA384
case WC_HASH_TYPE_SHA384:
MAX3266X_MSG("SHA-384 CB:");
/* Update Case */
if (info->hash.in != NULL && info->hash.digest == NULL) {
MAX3266X_MSG("Update CB");
return wc_MXC_TPU_SHA_Update(&(info->hash.sha384->mxcCtx),
info->hash.in, info->hash.inSz);
}
/* Sha 384 Final Case */
if (info->hash.in == NULL && info->hash.digest != NULL) {
MAX3266X_MSG("Final CB");
return wc_MXC_TPU_SHA_Final(&(info->hash.sha384->mxcCtx),
info->hash.digest,
MXC_TPU_HASH_SHA384);
}
break; /* Break Out and Return Error */
return wc_MxcShaCbDispatch(&info->hash.sha384->msg,
&info->hash.sha384->used, &info->hash.sha384->len,
info->hash.sha384->heap, info->hash.in,
info->hash.inSz, info->hash.digest,
MXC_TPU_HASH_SHA384);
#endif
#ifdef WOLFSSL_SHA512
case WC_HASH_TYPE_SHA512:
MAX3266X_MSG("SHA-512 CB:");
/* Update Case */
if (info->hash.in != NULL && info->hash.digest == NULL) {
MAX3266X_MSG("Update CB");
return wc_MXC_TPU_SHA_Update(&(info->hash.sha512->mxcCtx),
info->hash.in, info->hash.inSz);
}
/* Sha 512 Final Case */
if (info->hash.in == NULL && info->hash.digest != NULL) {
MAX3266X_MSG("Final CB");
return wc_MXC_TPU_SHA_Final(&(info->hash.sha512->mxcCtx),
info->hash.digest,
MXC_TPU_HASH_SHA512);
}
break; /* Break Out and Return Error */
return wc_MxcShaCbDispatch(&info->hash.sha512->msg,
&info->hash.sha512->used, &info->hash.sha512->len,
info->hash.sha512->heap, info->hash.in,
info->hash.inSz, info->hash.digest,
MXC_TPU_HASH_SHA512);
#endif
default:
/* Hash type not supported */
return WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
}
if (info->hash.inSz == 0) {
return 0; /* Dont need to Update when Size is Zero */
}
return BAD_FUNC_ARG;
}
#endif /* MAX3266X_SHA_CB */
/* Determines AES Type for Callback */
/* General Callback Function to determine ALGO Type */
int wc_MxcCryptoCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
{
int ret;
#ifdef MAX3266X_SHA_CB
int savedDevId;
wc_MXC_Sha *srcMxcCtx;
wc_MXC_Sha *dstMxcCtx;
int *srcDevId;
int *dstDevId;
word32 copySize;
#endif
(void)ctx;
(void)devIdArg;
@@ -274,132 +229,6 @@ int wc_MxcCryptoCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
MAX3266X_MSG("Using MXC SHA HW Callback:");
ret = wc_MxcShaCryptoCb(info); /* Determine SHA HW or SW */
break;
case WC_ALGO_TYPE_COPY:
MAX3266X_MSG("Using MXC Copy Callback:");
if (info->copy.algo == WC_ALGO_TYPE_HASH) {
srcMxcCtx = NULL;
dstMxcCtx = NULL;
srcDevId = NULL;
dstDevId = NULL;
copySize = 0;
/* Get pointers and size based on hash type */
switch (info->copy.type) {
#ifndef NO_SHA
case WC_HASH_TYPE_SHA:
srcMxcCtx = &((wc_Sha*)info->copy.src)->mxcCtx;
dstMxcCtx = &((wc_Sha*)info->copy.dst)->mxcCtx;
srcDevId = &((wc_Sha*)info->copy.src)->devId;
dstDevId = &((wc_Sha*)info->copy.dst)->devId;
copySize = sizeof(wc_Sha);
break;
#endif
#ifdef WOLFSSL_SHA224
case WC_HASH_TYPE_SHA224:
srcMxcCtx = &((wc_Sha224*)info->copy.src)->mxcCtx;
dstMxcCtx = &((wc_Sha224*)info->copy.dst)->mxcCtx;
srcDevId = &((wc_Sha224*)info->copy.src)->devId;
dstDevId = &((wc_Sha224*)info->copy.dst)->devId;
copySize = sizeof(wc_Sha224);
break;
#endif
#ifndef NO_SHA256
case WC_HASH_TYPE_SHA256:
srcMxcCtx = &((wc_Sha256*)info->copy.src)->mxcCtx;
dstMxcCtx = &((wc_Sha256*)info->copy.dst)->mxcCtx;
srcDevId = &((wc_Sha256*)info->copy.src)->devId;
dstDevId = &((wc_Sha256*)info->copy.dst)->devId;
copySize = sizeof(wc_Sha256);
break;
#endif
#ifdef WOLFSSL_SHA384
case WC_HASH_TYPE_SHA384:
srcMxcCtx = &((wc_Sha384*)info->copy.src)->mxcCtx;
dstMxcCtx = &((wc_Sha384*)info->copy.dst)->mxcCtx;
srcDevId = &((wc_Sha384*)info->copy.src)->devId;
dstDevId = &((wc_Sha384*)info->copy.dst)->devId;
copySize = sizeof(wc_Sha384);
break;
#endif
#ifdef WOLFSSL_SHA512
case WC_HASH_TYPE_SHA512:
srcMxcCtx = &((wc_Sha512*)info->copy.src)->mxcCtx;
dstMxcCtx = &((wc_Sha512*)info->copy.dst)->mxcCtx;
srcDevId = &((wc_Sha512*)info->copy.src)->devId;
dstDevId = &((wc_Sha512*)info->copy.dst)->devId;
copySize = sizeof(wc_Sha512);
break;
#endif
default:
return WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
}
/* Software copy */
savedDevId = *srcDevId;
XMEMCPY(info->copy.dst, info->copy.src, copySize);
*dstDevId = savedDevId;
/* Hardware copy - handles shallow copy from XMEMCPY */
ret = wc_MXC_TPU_SHA_Copy(srcMxcCtx, dstMxcCtx);
}
else {
ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
}
break;
case WC_ALGO_TYPE_FREE:
MAX3266X_MSG("Using MXC Free Callback:");
if (info->free.algo == WC_ALGO_TYPE_HASH) {
dstMxcCtx = NULL;
dstDevId = NULL;
copySize = 0;
/* Get pointers and size based on hash type */
switch (info->free.type) {
#ifndef NO_SHA
case WC_HASH_TYPE_SHA:
dstMxcCtx = &((wc_Sha*)info->free.obj)->mxcCtx;
dstDevId = &((wc_Sha*)info->free.obj)->devId;
copySize = sizeof(wc_Sha);
break;
#endif
#ifdef WOLFSSL_SHA224
case WC_HASH_TYPE_SHA224:
dstMxcCtx = &((wc_Sha224*)info->free.obj)->mxcCtx;
dstDevId = &((wc_Sha224*)info->free.obj)->devId;
copySize = sizeof(wc_Sha224);
break;
#endif
#ifndef NO_SHA256
case WC_HASH_TYPE_SHA256:
dstMxcCtx = &((wc_Sha256*)info->free.obj)->mxcCtx;
dstDevId = &((wc_Sha256*)info->free.obj)->devId;
copySize = sizeof(wc_Sha256);
break;
#endif
#ifdef WOLFSSL_SHA384
case WC_HASH_TYPE_SHA384:
dstMxcCtx = &((wc_Sha384*)info->free.obj)->mxcCtx;
dstDevId = &((wc_Sha384*)info->free.obj)->devId;
copySize = sizeof(wc_Sha384);
break;
#endif
#ifdef WOLFSSL_SHA512
case WC_HASH_TYPE_SHA512:
dstMxcCtx = &((wc_Sha512*)info->free.obj)->mxcCtx;
dstDevId = &((wc_Sha512*)info->free.obj)->devId;
copySize = sizeof(wc_Sha512);
break;
#endif
default:
return WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
}
/* Hardware free */
wc_MXC_TPU_SHA_Free(dstMxcCtx);
/* Software free */
*dstDevId = INVALID_DEVID;
ForceZero(info->free.obj, copySize);
ret = 0;
}
else {
ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
}
break;
#endif /* MAX3266X_SHA_CB */
default:
MAX3266X_MSG("Callback not support with MXC, using SW");
@@ -723,194 +552,16 @@ int wc_MxcCb_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
#if defined(MAX3266X_SHA) || defined(MAX3266X_SHA_CB)
int wc_MXC_TPU_SHA_Init(wc_MXC_Sha *hash)
{
if (hash == NULL) {
return BAD_FUNC_ARG; /* Appropriate error handling for null argument */
}
hash->msg = NULL;
hash->used = 0;
hash->size = 0;
return 0;
}
/* Used to update the msg. Currently the SDK only supports 1 shots, so the */
/* hash->msg buffer needs to be updated and resized. hash->msg will keep the */
/* unhashed msg and produce a digest when wc_MXC_TPU_SHA_Final or */
/* wc_MXC_TPU_SHA_GetHash is called */
int wc_MXC_TPU_SHA_Update(wc_MXC_Sha *hash, const unsigned char* data,
unsigned int size)
{
void *p;
/* Only update if size is not 0 */
if (size == 0) {
return 0;
}
/* Check for NULL pointers After Size Check */
if (hash == NULL || data == NULL) {
return BAD_FUNC_ARG;
}
if (hash->size < hash->used+size) {
if (hash->msg == NULL) {
p = XMALLOC(hash->used+size, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
else {
#ifdef WOLFSSL_NO_REALLOC
p = XMALLOC(hash->used + size, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (p != NULL) {
XMEMCPY(p, hash->msg, hash->used);
XFREE(hash->msg, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
#else
p = XREALLOC(hash->msg, hash->used+size, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
#endif
}
if (p == NULL) {
return MEMORY_E;
}
hash->msg = p;
hash->size = hash->used+size;
}
XMEMCPY(hash->msg+hash->used, data, size);
hash->used += size;
if (hash->msg == NULL) {
return BAD_FUNC_ARG;
}
return 0;
}
int wc_MXC_TPU_SHA_GetHash(wc_MXC_Sha *hash, unsigned char* digest,
MXC_TPU_HASH_TYPE algo)
{
int status;
if (hash == NULL || digest == NULL) {
return BAD_FUNC_ARG;
}
status = wc_MXC_TPU_SHA_GetDigest(hash, digest, algo);
/* True Case that msg is an empty string */
if (status == 1) {
/* Hardware cannot handle the case of an empty string */
/* so in the case of this we will provide the hash via software */
return 0;
}
/* False Case where msg needs to be processed */
else if (status == 0) {
status = wolfSSL_HwHashMutexLock(); /* Set Mutex */
if (status != 0) { /* Mutex Call Check */
return status;
}
MXC_TPU_Init(MXC_SYS_PERIPH_CLOCK_TPU);
MXC_TPU_Hash_Config(algo);
status = MXC_TPU_Hash_SHA((const char *)hash->msg, algo, hash->size,
(char *)digest);
MAX3266X_MSG("SHA HW Acceleration Used");
wolfSSL_HwHashMutexUnLock(); /* Release Mutex */
if (wc_MXC_error(&status) != 0) {
MAX3266X_MSG("SHA HW Error Occurred");
return status;
}
}
/* Error Occurred */
return status;
}
/* Calls GetHash to determine the digest and then reinitialize the hash */
/* struct */
int wc_MXC_TPU_SHA_Final(wc_MXC_Sha *hash, unsigned char* digest,
MXC_TPU_HASH_TYPE algo)
{
int status;
if (hash == NULL || digest == NULL) {
return BAD_FUNC_ARG;
}
status = wc_MXC_TPU_SHA_GetHash(hash, digest, algo);
/* Free hash->msg no matter result */
XFREE(hash->msg, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (status != 0) {
return status;
}
status = wc_MXC_TPU_SHA_Init(hash);
if (status != 0) {
return status;
}
return status;
}
/* Copies Struct values from SRC struct to DST struct */
int wc_MXC_TPU_SHA_Copy(wc_MXC_Sha* src, wc_MXC_Sha* dst)
{
if (src == NULL || dst == NULL) {
return BAD_FUNC_ARG;
}
/* Handle case where src has no data */
if (src->msg == NULL || src->size == 0) {
/* Free dst if it has different data, then zero it */
if (dst->msg != NULL && dst->msg != src->msg) {
wc_MXC_TPU_SHA_Free(dst);
}
else {
dst->msg = NULL;
dst->used = 0;
dst->size = 0;
}
return 0;
}
/* Only free dst if it points to different memory than src */
if (dst->msg != NULL && dst->msg != src->msg) {
wc_MXC_TPU_SHA_Free(dst);
}
else {
/* Reset dst without freeing (would free src's buffer) */
dst->msg = NULL;
dst->used = 0;
dst->size = 0;
}
/* Allocate new buffer for dst */
dst->msg = (unsigned char*)XMALLOC(src->size, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
dst->used = src->used;
dst->size = src->size;
return 0;
}
/* Free the given struct's msg buffer and then reinitialize the struct to 0 */
/* returns void to match other wc_Sha*Free api */
void wc_MXC_TPU_SHA_Free(wc_MXC_Sha* hash)
{
if (hash == NULL) {
return; /* Hash Struct is Null already, dont edit potentially */
/* undefined memory by accident */
}
/* Securely zero the buffer before freeing */
if (hash->msg != NULL) {
ForceZero(hash->msg, hash->size);
XFREE(hash->msg, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
/* Reset struct members to initial state */
hash->msg = NULL;
hash->used = 0;
hash->size = 0;
return;
}
/* Acts as a True/False if true it will provide the stored digest */
/* for the edge case of an empty string */
int wc_MXC_TPU_SHA_GetDigest(wc_MXC_Sha *hash, unsigned char* digest,
/* Check for empty message and provide pre-computed digest if so */
/* Returns 1 if empty (digest filled), 0 if needs hardware processing */
int wc_MXC_TPU_SHA_GetDigest(const unsigned char* msg, unsigned int msgSz,
unsigned char* digest,
MXC_TPU_HASH_TYPE algo)
{
if (hash == NULL || digest == NULL) {
if (digest == NULL) {
return BAD_FUNC_ARG;
}
if (hash->msg == 0 && hash->size == 0) {
if (msg == NULL && msgSz == 0) {
switch (algo) {
#ifndef NO_SHA
case MXC_TPU_HASH_SHA1:
@@ -940,9 +591,79 @@ int wc_MXC_TPU_SHA_GetDigest(wc_MXC_Sha *hash, unsigned char* digest,
default:
return BAD_FUNC_ARG;
}
return 1; /* True */
return 1; /* True: empty digest provided */
}
return 0; /* False */
return 0; /* False: needs hardware processing */
}
/* Compute hash from accumulated message using TPU hardware */
int wc_MXC_TPU_SHA_GetHash(const unsigned char* msg, unsigned int msgSz,
unsigned char* digest,
MXC_TPU_HASH_TYPE algo)
{
int status;
if (digest == NULL || (msg == NULL && msgSz != 0)) {
return BAD_FUNC_ARG;
}
status = wc_MXC_TPU_SHA_GetDigest(msg, msgSz, digest, algo);
/* True Case that msg is an empty string */
if (status == 1) {
/* Hardware cannot handle the case of an empty string */
/* so in the case of this we will provide the hash via software */
return 0;
}
/* False Case where msg needs to be processed */
else if (status == 0) {
status = wolfSSL_HwHashMutexLock(); /* Set Mutex */
if (status != 0) { /* Mutex Call Check */
return status;
}
MXC_TPU_Init(MXC_SYS_PERIPH_CLOCK_TPU);
MXC_TPU_Hash_Config(algo);
status = MXC_TPU_Hash_SHA((const char *)msg, algo, msgSz,
(char *)digest);
MAX3266X_MSG("SHA HW Acceleration Used");
wolfSSL_HwHashMutexUnLock(); /* Release Mutex */
if (wc_MXC_error(&status) != 0) {
MAX3266X_MSG("SHA HW Error Occurred");
return status;
}
}
/* Error Occurred */
return status;
}
/* Free HASH_KEEP message buffer and reset fields */
void wc_MXC_TPU_SHA_Free(byte** msg, word32* used, word32* len, void* heap)
{
if (msg == NULL) {
return;
}
if (*msg != NULL) {
XFREE(*msg, heap, DYNAMIC_TYPE_TMP_BUFFER);
*msg = NULL;
}
if (used != NULL) {
*used = 0;
}
if (len != NULL) {
*len = 0;
}
}
/* Compute hash, free message buffer, and reset HASH_KEEP fields */
int wc_MXC_TPU_SHA_Final(unsigned char** msg, unsigned int* used,
unsigned int* len, void* heap,
unsigned char* digest,
MXC_TPU_HASH_TYPE algo)
{
int status;
if (msg == NULL || used == NULL || len == NULL || digest == NULL) {
return BAD_FUNC_ARG;
}
status = wc_MXC_TPU_SHA_GetHash(*msg, *used, digest, algo);
wc_MXC_TPU_SHA_Free(msg, used, len, heap);
return status;
}
#ifndef MAX3266X_SHA_CB
@@ -953,38 +674,63 @@ WOLFSSL_API int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId)
if (sha == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return wc_MXC_TPU_SHA_Init(&(sha->mxcCtx));
XMEMSET(sha, 0, sizeof(*sha));
sha->heap = heap;
return 0;
}
WOLFSSL_API int wc_ShaUpdate(wc_Sha* sha, const unsigned char* data,
unsigned int len)
{
return wc_MXC_TPU_SHA_Update(&(sha->mxcCtx), data, len);
if (sha == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
return _wc_Hash_Grow(&sha->msg, &sha->used, &sha->len,
data, (int)len, sha->heap);
}
WOLFSSL_API int wc_ShaFinal(wc_Sha* sha, unsigned char* hash)
{
return wc_MXC_TPU_SHA_Final(&(sha->mxcCtx), hash,
MXC_TPU_HASH_SHA1);
if (sha == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_Final(&sha->msg, &sha->used, &sha->len,
sha->heap, hash, MXC_TPU_HASH_SHA1);
}
WOLFSSL_API int wc_ShaGetHash(wc_Sha* sha, unsigned char* hash)
{
return wc_MXC_TPU_SHA_GetHash(&(sha->mxcCtx), hash,
MXC_TPU_HASH_SHA1);
if (sha == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_GetHash((const unsigned char*)sha->msg,
sha->used, hash, MXC_TPU_HASH_SHA1);
}
WOLFSSL_API int wc_ShaCopy(wc_Sha* src, wc_Sha* dst)
{
return wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (src == NULL || dst == NULL) {
return BAD_FUNC_ARG;
}
XMEMCPY(dst, src, sizeof(*src));
if (src->msg != NULL) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
}
return 0;
}
WOLFSSL_API void wc_ShaFree(wc_Sha* sha)
{
wc_MXC_TPU_SHA_Free(&(sha->mxcCtx));
return;
if (sha == NULL) {
return;
}
wc_MXC_TPU_SHA_Free(&sha->msg, &sha->used, &sha->len, sha->heap);
}
#endif /* NO_SHA */
@@ -996,9 +742,10 @@ WOLFSSL_API int wc_InitSha224_ex(wc_Sha224* sha224, void* heap, int devId)
if (sha224 == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return wc_MXC_TPU_SHA_Init(&(sha224->mxcCtx));
XMEMSET(sha224, 0, sizeof(*sha224));
sha224->heap = heap;
return 0;
}
WOLFSSL_API int wc_InitSha224(wc_Sha224* sha224)
@@ -1009,30 +756,57 @@ WOLFSSL_API int wc_InitSha224(wc_Sha224* sha224)
WOLFSSL_API int wc_Sha224Update(wc_Sha224* sha224, const unsigned char* data,
unsigned int len)
{
return wc_MXC_TPU_SHA_Update(&(sha224->mxcCtx), data, len);
if (sha224 == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
return _wc_Hash_Grow(&sha224->msg, &sha224->used, &sha224->len,
data, (int)len, sha224->heap);
}
WOLFSSL_API int wc_Sha224Final(wc_Sha224* sha224, unsigned char* hash)
{
return wc_MXC_TPU_SHA_Final(&(sha224->mxcCtx), hash,
if (sha224 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_Final(&sha224->msg, &sha224->used, &sha224->len,
sha224->heap, hash,
MXC_TPU_HASH_SHA224);
}
WOLFSSL_API int wc_Sha224GetHash(wc_Sha224* sha224, unsigned char* hash)
{
return wc_MXC_TPU_SHA_GetHash(&(sha224->mxcCtx), hash,
if (sha224 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_GetHash((const unsigned char*)sha224->msg,
sha224->used, hash,
MXC_TPU_HASH_SHA224);
}
WOLFSSL_API int wc_Sha224Copy(wc_Sha224* src, wc_Sha224* dst)
{
return wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (src == NULL || dst == NULL) {
return BAD_FUNC_ARG;
}
XMEMCPY(dst, src, sizeof(*src));
if (src->msg != NULL) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
}
return 0;
}
WOLFSSL_API void wc_Sha224Free(wc_Sha224* sha224)
{
wc_MXC_TPU_SHA_Free(&(sha224->mxcCtx));
return;
if (sha224 == NULL) {
return;
}
wc_MXC_TPU_SHA_Free(&sha224->msg, &sha224->used, &sha224->len,
sha224->heap);
}
#endif /* WOLFSSL_SHA224 */
@@ -1044,9 +818,10 @@ WOLFSSL_API int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
if (sha256 == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return wc_MXC_TPU_SHA_Init(&(sha256->mxcCtx));
XMEMSET(sha256, 0, sizeof(*sha256));
sha256->heap = heap;
return 0;
}
WOLFSSL_API int wc_InitSha256(wc_Sha256* sha256)
@@ -1057,30 +832,57 @@ WOLFSSL_API int wc_InitSha256(wc_Sha256* sha256)
WOLFSSL_API int wc_Sha256Update(wc_Sha256* sha256, const unsigned char* data,
unsigned int len)
{
return wc_MXC_TPU_SHA_Update(&(sha256->mxcCtx), data, len);
if (sha256 == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
return _wc_Hash_Grow(&sha256->msg, &sha256->used, &sha256->len,
data, (int)len, sha256->heap);
}
WOLFSSL_API int wc_Sha256Final(wc_Sha256* sha256, unsigned char* hash)
{
return wc_MXC_TPU_SHA_Final(&(sha256->mxcCtx), hash,
if (sha256 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_Final(&sha256->msg, &sha256->used, &sha256->len,
sha256->heap, hash,
MXC_TPU_HASH_SHA256);
}
WOLFSSL_API int wc_Sha256GetHash(wc_Sha256* sha256, unsigned char* hash)
{
return wc_MXC_TPU_SHA_GetHash(&(sha256->mxcCtx), hash,
if (sha256 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_GetHash((const unsigned char*)sha256->msg,
sha256->used, hash,
MXC_TPU_HASH_SHA256);
}
WOLFSSL_API int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst)
{
return wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (src == NULL || dst == NULL) {
return BAD_FUNC_ARG;
}
XMEMCPY(dst, src, sizeof(*src));
if (src->msg != NULL) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
}
return 0;
}
WOLFSSL_API void wc_Sha256Free(wc_Sha256* sha256)
{
wc_MXC_TPU_SHA_Free(&(sha256->mxcCtx));
return;
if (sha256 == NULL) {
return;
}
wc_MXC_TPU_SHA_Free(&sha256->msg, &sha256->used, &sha256->len,
sha256->heap);
}
#endif /* NO_SHA256 */
@@ -1092,9 +894,10 @@ WOLFSSL_API int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
if (sha384 == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return wc_MXC_TPU_SHA_Init(&(sha384->mxcCtx));
XMEMSET(sha384, 0, sizeof(*sha384));
sha384->heap = heap;
return 0;
}
WOLFSSL_API int wc_InitSha384(wc_Sha384* sha384)
@@ -1105,30 +908,57 @@ WOLFSSL_API int wc_InitSha384(wc_Sha384* sha384)
WOLFSSL_API int wc_Sha384Update(wc_Sha384* sha384, const unsigned char* data,
unsigned int len)
{
return wc_MXC_TPU_SHA_Update(&(sha384->mxcCtx), data, len);
if (sha384 == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
return _wc_Hash_Grow(&sha384->msg, &sha384->used, &sha384->len,
data, (int)len, sha384->heap);
}
WOLFSSL_API int wc_Sha384Final(wc_Sha384* sha384, unsigned char* hash)
{
return wc_MXC_TPU_SHA_Final(&(sha384->mxcCtx), hash,
if (sha384 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_Final(&sha384->msg, &sha384->used, &sha384->len,
sha384->heap, hash,
MXC_TPU_HASH_SHA384);
}
WOLFSSL_API int wc_Sha384GetHash(wc_Sha384* sha384, unsigned char* hash)
{
return wc_MXC_TPU_SHA_GetHash(&(sha384->mxcCtx), hash,
if (sha384 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_GetHash((const unsigned char*)sha384->msg,
sha384->used, hash,
MXC_TPU_HASH_SHA384);
}
WOLFSSL_API int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst)
{
return wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (src == NULL || dst == NULL) {
return BAD_FUNC_ARG;
}
XMEMCPY(dst, src, sizeof(*src));
if (src->msg != NULL) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
}
return 0;
}
WOLFSSL_API void wc_Sha384Free(wc_Sha384* sha384)
{
wc_MXC_TPU_SHA_Free(&(sha384->mxcCtx));
return;
if (sha384 == NULL) {
return;
}
wc_MXC_TPU_SHA_Free(&sha384->msg, &sha384->used, &sha384->len,
sha384->heap);
}
#endif /* WOLFSSL_SHA384 */
@@ -1140,9 +970,10 @@ WOLFSSL_API int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
if (sha512 == NULL) {
return BAD_FUNC_ARG;
}
(void)heap;
(void)devId;
return wc_MXC_TPU_SHA_Init(&(sha512->mxcCtx));
XMEMSET(sha512, 0, sizeof(*sha512));
sha512->heap = heap;
return 0;
}
WOLFSSL_API int wc_InitSha512(wc_Sha512* sha512)
@@ -1153,30 +984,57 @@ WOLFSSL_API int wc_InitSha512(wc_Sha512* sha512)
WOLFSSL_API int wc_Sha512Update(wc_Sha512* sha512, const unsigned char* data,
unsigned int len)
{
return wc_MXC_TPU_SHA_Update(&(sha512->mxcCtx), data, len);
if (sha512 == NULL || (data == NULL && len > 0)) {
return BAD_FUNC_ARG;
}
return _wc_Hash_Grow(&sha512->msg, &sha512->used, &sha512->len,
data, (int)len, sha512->heap);
}
WOLFSSL_API int wc_Sha512Final(wc_Sha512* sha512, unsigned char* hash)
{
return wc_MXC_TPU_SHA_Final(&(sha512->mxcCtx), hash,
if (sha512 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_Final(&sha512->msg, &sha512->used, &sha512->len,
sha512->heap, hash,
MXC_TPU_HASH_SHA512);
}
WOLFSSL_API int wc_Sha512GetHash(wc_Sha512* sha512, unsigned char* hash)
{
return wc_MXC_TPU_SHA_GetHash(&(sha512->mxcCtx), hash,
if (sha512 == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
return wc_MXC_TPU_SHA_GetHash((const unsigned char*)sha512->msg,
sha512->used, hash,
MXC_TPU_HASH_SHA512);
}
WOLFSSL_API int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst)
{
return wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (src == NULL || dst == NULL) {
return BAD_FUNC_ARG;
}
XMEMCPY(dst, src, sizeof(*src));
if (src->msg != NULL) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
}
return 0;
}
WOLFSSL_API void wc_Sha512Free(wc_Sha512* sha512)
{
wc_MXC_TPU_SHA_Free(&(sha512->mxcCtx));
return;
if (sha512 == NULL) {
return;
}
wc_MXC_TPU_SHA_Free(&sha512->msg, &sha512->used, &sha512->len,
sha512->heap);
}
#endif /* WOLFSSL_SHA512 */
+24 -15
View File
@@ -561,12 +561,10 @@ int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId)
sha->devId = devId;
sha->devCtx = NULL;
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Init(&(sha->mxcCtx));
if (ret != 0) {
return ret;
}
#ifdef WOLFSSL_HASH_KEEP
sha->msg = NULL;
sha->len = 0;
sha->used = 0;
#endif
#ifdef WOLFSSL_USE_ESP32_CRYPT_HASH_HW
@@ -1087,9 +1085,6 @@ void wc_ShaFree(wc_Sha* sha)
#ifdef WOLFSSL_PIC32MZ_HASH
wc_ShaPic32Free(sha);
#endif
#ifdef MAX3266X_SHA_CB
wc_MXC_TPU_SHA_Free(&(sha->mxcCtx));
#endif
#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_HASH)
se050_hash_free(&sha->se050Ctx);
#endif
@@ -1105,6 +1100,14 @@ void wc_ShaFree(wc_Sha* sha)
DCPShaFree(sha);
#endif
#ifdef WOLFSSL_HASH_KEEP
if (sha->msg != NULL) {
ForceZero(sha->msg, sha->len);
XFREE(sha->msg, sha->heap, DYNAMIC_TYPE_TMP_BUFFER);
sha->msg = NULL;
}
#endif
#if defined(PSOC6_HASH_SHA1)
wc_Psoc6_Sha_Free();
#endif
@@ -1198,12 +1201,6 @@ int wc_ShaCopy(wc_Sha* src, wc_Sha* dst)
esp_sha_ctx_copy(src, dst);
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#if defined(PSOC6_HASH_SHA1)
wc_Psoc6_Sha1_Sha2_Init(dst, WC_PSOC6_SHA1, 0);
@@ -1212,6 +1209,18 @@ int wc_ShaCopy(wc_Sha* src, wc_Sha* dst)
#ifdef WOLFSSL_HASH_FLAGS
dst->flags |= WC_HASH_FLAG_ISCOPY;
#endif
#if defined(WOLFSSL_HASH_KEEP)
if (src->msg != NULL) {
dst->msg = (byte*)XMALLOC(src->len, dst->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL) {
return MEMORY_E;
}
XMEMCPY(dst->msg, src->msg, src->used);
}
#endif
return ret;
}
#endif /* WOLFSSL_RENESAS_RX64_HASH */
-27
View File
@@ -1113,12 +1113,6 @@ int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId)
(void)devId;
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Init(&(sha256->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#ifdef WOLFSSL_SMALL_STACK_CACHE
sha256->W = NULL;
@@ -1171,12 +1165,6 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
sha256->devId = devId;
sha256->devCtx = NULL;
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Init(&(sha256->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#ifdef WOLFSSL_SMALL_STACK_CACHE
sha256->W = (word32*)XMALLOC(sizeof(word32) * WC_SHA256_BLOCK_SIZE,
sha256->heap, DYNAMIC_TYPE_DIGEST);
@@ -2150,12 +2138,6 @@ static WC_INLINE int Transform_Sha256_Len(wc_Sha256* sha256, const byte* data,
sha224->devId = devId;
sha224->devCtx = NULL;
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Init(&(sha224->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#if defined(WOLFSSL_USE_ESP32_CRYPT_HASH_HW)
#if defined(NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224)
/* We know this is a fresh, uninitialized item, so set to INIT */
@@ -2428,9 +2410,6 @@ void wc_Sha256Free(wc_Sha256* sha256)
}
#endif
#ifdef MAX3266X_SHA_CB
wc_MXC_TPU_SHA_Free(&(sha256->mxcCtx));
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA256)
wolfAsync_DevCtxFree(&sha256->asyncDev, WOLFSSL_ASYNC_MARKER_SHA256);
@@ -2758,12 +2737,6 @@ int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst)
wc_MAXQ10XX_Sha256Copy(src);
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#ifdef WOLFSSL_SMALL_STACK_CACHE
dst->W = (word32*)XMALLOC(sizeof(word32) * WC_SHA256_BLOCK_SIZE,
+2 -29
View File
@@ -887,6 +887,8 @@ static int InitSha512_Family(wc_Sha512* sha512, void* heap, int devId,
#ifdef WOLFSSL_HASH_KEEP
sha512->msg = NULL;
sha512->len = 0;
sha512->used = 0;
#endif
/* call the initialization function pointed to by initfp */
@@ -927,11 +929,6 @@ int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
sha512->ctx.mode = ESP32_SHA_INIT;
#endif
#ifdef MAX3266X_SHA_CB
if (wc_MXC_TPU_SHA_Init(&(sha512->mxcCtx)) != 0){
return BAD_FUNC_ARG;
}
#endif
return InitSha512_Family(sha512, heap, devId, InitSha512);
}
@@ -1676,9 +1673,6 @@ void wc_Sha512Free(wc_Sha512* sha512)
}
#endif
#ifdef MAX3266X_SHA_CB
wc_MXC_TPU_SHA_Free(&(sha512->mxcCtx));
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
wolfAsync_DevCtxFree(&sha512->asyncDev, WOLFSSL_ASYNC_MARKER_SHA512);
@@ -2062,12 +2056,6 @@ int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
sha384->ctx.mode = ESP32_SHA_INIT;
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Init(&(sha384->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
ret = InitSha384(sha384);
if (ret != 0) {
@@ -2172,9 +2160,6 @@ void wc_Sha384Free(wc_Sha384* sha384)
}
#endif
#ifdef MAX3266X_SHA_CB
wc_MXC_TPU_SHA_Free(&(sha384->mxcCtx));
#endif
ForceZero(sha384, sizeof(*sha384));
}
@@ -2313,12 +2298,6 @@ int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst)
}
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#if defined(PSOC6_HASH_SHA2)
wc_Psoc6_Sha1_Sha2_Init(dst, WC_PSOC6_SHA512, 0);
@@ -2756,12 +2735,6 @@ int wc_Sha384Copy(wc_Sha384* src, wc_Sha384* dst)
}
#endif
#ifdef MAX3266X_SHA_CB
ret = wc_MXC_TPU_SHA_Copy(&(src->mxcCtx), &(dst->mxcCtx));
if (ret != 0) {
return ret;
}
#endif
#if defined(PSOC6_HASH_SHA2)
wc_Psoc6_Sha1_Sha2_Init(dst, WC_PSOC6_SHA384, 0);
@@ -59,12 +59,6 @@
#endif /* HAVE_AES_DECRYPT */
WOLFSSL_LOCAL int wc_MXC_Sha256Update(wc_MXC_Sha* sha256,
const unsigned char* data,
unsigned int len);
WOLFSSL_LOCAL int wc_MXC_Sha256Final(wc_MXC_Sha* sha256,
unsigned char* hash);
#ifdef __cplusplus
} /* extern "C" */
#endif
+20 -19
View File
@@ -33,8 +33,6 @@
/* Some extra conditions when using callbacks */
#if defined(WOLF_CRYPTO_CB)
#define MAX3266X_CB
#define WOLF_CRYPTO_CB_COPY /* Enable copy callback for deep copy */
#define WOLF_CRYPTO_CB_FREE /* Enable free callback for proper cleanup */
#ifdef MAX3266X_MATH
#error Cannot have MAX3266X_MATH and MAX3266X_CB
#endif
@@ -238,14 +236,10 @@
#if defined(MAX3266X_SHA) || defined(MAX3266X_SHA_CB)
/* Need to update this struct accordingly if other SHA Structs change */
/* This is a generic struct to use so only this is needed */
typedef struct {
unsigned char *msg;
unsigned int used;
unsigned int size;
} wc_MXC_Sha;
/* Use HASH_KEEP to accumulate message data for one-shot TPU hardware */
#ifndef WOLFSSL_HASH_KEEP
#define WOLFSSL_HASH_KEEP
#endif
#if !defined(NO_SHA)
/* Define the SHA digest for an empty string */
@@ -313,19 +307,26 @@
#endif /* WOLFSSL_SHA512 */
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_Init(wc_MXC_Sha *hash);
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_Update(wc_MXC_Sha *hash,
const unsigned char* data,
unsigned int size);
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_Final(wc_MXC_Sha *hash,
/* Check for empty message and provide pre-computed digest if so */
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_GetDigest(const unsigned char* msg,
unsigned int msgSz,
unsigned char* digest,
MXC_TPU_HASH_TYPE algo);
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_GetHash(wc_MXC_Sha *hash,
/* Compute hash from accumulated message using TPU hardware */
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_GetHash(const unsigned char* msg,
unsigned int msgSz,
unsigned char* digest,
MXC_TPU_HASH_TYPE algo);
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_Copy(wc_MXC_Sha* src, wc_MXC_Sha* dst);
WOLFSSL_LOCAL void wc_MXC_TPU_SHA_Free(wc_MXC_Sha* hash);
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_GetDigest(wc_MXC_Sha *hash,
/* Free HASH_KEEP message buffer and reset fields */
WOLFSSL_LOCAL void wc_MXC_TPU_SHA_Free(unsigned char** msg,
unsigned int* used,
unsigned int* len,
void* heap);
/* Compute hash, free message buffer, and reset fields */
WOLFSSL_LOCAL int wc_MXC_TPU_SHA_Final(unsigned char** msg,
unsigned int* used,
unsigned int* len,
void* heap,
unsigned char* digest,
MXC_TPU_HASH_TYPE algo);
-3
View File
@@ -175,9 +175,6 @@ struct wc_Sha {
int devId;
void* devCtx; /* generic crypto callback context */
#endif
#if defined(MAX3266X_SHA_CB) || defined(MAX3266X_SHA)
wc_MXC_Sha mxcCtx;
#endif
#ifdef WOLFSSL_IMXRT1170_CAAM
caam_hash_ctx_t ctx;
caam_handle_t hndl;
-3
View File
@@ -209,9 +209,6 @@ struct wc_Sha256 {
#ifdef WOLFSSL_DEVCRYPTO_HASH
WC_CRYPTODEV ctx;
#endif
#if defined(MAX3266X_SHA_CB) || defined(MAX3266X_SHA)
wc_MXC_Sha mxcCtx;
#endif
#if defined(WOLFSSL_DEVCRYPTO_HASH) || defined(WOLFSSL_HASH_KEEP)
byte* msg;
word32 used;
-3
View File
@@ -189,9 +189,6 @@ struct wc_Sha512 {
int devId;
void* devCtx; /* generic crypto callback context */
#endif
#if defined(MAX3266X_SHA_CB) || defined(MAX3266X_SHA)
wc_MXC_Sha mxcCtx;
#endif
#ifdef WOLFSSL_HASH_FLAGS
word32 flags; /* enum wc_HashFlags in hash.h */
#endif