add sha224 cryptcb

This commit is contained in:
Hideki Miyazaki
2025-08-07 07:49:53 +09:00
parent 339f7efbf4
commit ccdef57e8e
3 changed files with 49 additions and 1 deletions

View File

@@ -1596,6 +1596,40 @@ int wc_CryptoCb_ShaHash(wc_Sha* sha, const byte* in,
}
#endif /* !NO_SHA */
#ifdef WOLFSSL_SHA224
int wc_CryptoCb_Sha224Hash(wc_Sha224* sha224, const byte* in,
word32 inSz, byte* digest)
{
int ret = WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE);
CryptoCb* dev;
/* locate registered callback */
if (sha224) {
dev = wc_CryptoCb_FindDevice(sha224->devId, WC_ALGO_TYPE_HASH);
}
else {
/* locate first callback and try using it */
dev = wc_CryptoCb_FindDeviceByIndex(0);
}
if (dev && dev->cb) {
wc_CryptoInfo cryptoInfo;
XMEMSET(&cryptoInfo, 0, sizeof(cryptoInfo));
cryptoInfo.algo_type = WC_ALGO_TYPE_HASH;
cryptoInfo.hash.type = WC_HASH_TYPE_SHA224;
cryptoInfo.hash.sha224 = sha224;
cryptoInfo.hash.in = in;
cryptoInfo.hash.inSz = inSz;
cryptoInfo.hash.digest = digest;
ret = dev->cb(dev->devId, &cryptoInfo, dev->ctx);
}
return wc_CryptoCb_TranslateErrorCode(ret);
}
#endif /* WOLFSSL_SHA224 */
#ifndef NO_SHA256
int wc_CryptoCb_Sha256Hash(wc_Sha256* sha256, const byte* in,
word32 inSz, byte* digest)

View File

@@ -2133,7 +2133,17 @@ static int Transform_Sha256(wc_Sha256* sha256, const byte* data)
if (data == NULL) {
return BAD_FUNC_ARG;
}
#ifdef WOLF_CRYPTO_CB
#ifndef WOLF_CRYPTO_CB_FIND
if (sha224->devId != INVALID_DEVID)
#endif
{
ret = wc_CryptoCb_Sha224Hash(sha224, data, len, NULL);
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
return ret;
/* fall-through when unavailable */
}
#endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA224)
if (sha224->asyncDev.marker == WOLFSSL_ASYNC_MARKER_SHA224) {
#if defined(HAVE_INTEL_QA)

View File

@@ -639,6 +639,10 @@ WOLFSSL_LOCAL int wc_CryptoCb_ShaHash(wc_Sha* sha, const byte* in,
word32 inSz, byte* digest);
#endif /* !NO_SHA */
#ifdef WOLFSSL_SHA224
WOLFSSL_LOCAL int wc_CryptoCb_Sha224Hash(wc_Sha224* sha224, const byte* in,
word32 inSz, byte* digest);
#endif /* WOLFSSL_SHA224 */
#ifndef NO_SHA256
WOLFSSL_LOCAL int wc_CryptoCb_Sha256Hash(wc_Sha256* sha256, const byte* in,
word32 inSz, byte* digest);