mirror of https://github.com/wolfSSL/wolfssl.git
Added QAT SHA3 support. Fix for SHA512/SHA384 with QAT and Intel ASM enabled.
parent
c23489e6ed
commit
cbbe63ec62
|
@ -692,7 +692,7 @@ static int wc_InitSha3(wc_Sha3* sha3, void* heap, int devId)
|
|||
*/
|
||||
static int wc_Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
if (sha3 == NULL || (data == NULL && len > 0)) {
|
||||
return BAD_FUNC_ARG;
|
||||
|
@ -700,13 +700,18 @@ static int wc_Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
|
|||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
|
||||
if (sha3->asyncDev.marker == WOLFSSL_ASYNC_MARKER_SHA3) {
|
||||
#if defined(HAVE_INTEL_QA)
|
||||
return IntelQaSymSha3(&sha3->asyncDev, NULL, data, len);
|
||||
#if defined(HAVE_INTEL_QA) && defined(QAT_V2)
|
||||
/* QAT only supports SHA3_256 */
|
||||
if (p == WC_SHA3_256_COUNT) {
|
||||
ret = IntelQaSymSha3(&sha3->asyncDev, NULL, data, len);
|
||||
if (ret != NOT_COMPILED_IN)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
||||
Sha3Update(sha3, data, len, p);
|
||||
ret = Sha3Update(sha3, data, len, p);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -729,9 +734,14 @@ static int wc_Sha3Final(wc_Sha3* sha3, byte* hash, byte p, byte len)
|
|||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA3)
|
||||
if (sha3->asyncDev.marker == WOLFSSL_ASYNC_MARKER_SHA3) {
|
||||
#if defined(HAVE_INTEL_QA)
|
||||
return IntelQaSymSha3(&sha3->asyncDev, hash, NULL,
|
||||
SHA3_DIGEST_SIZE);
|
||||
#if defined(HAVE_INTEL_QA) && defined(QAT_V2)
|
||||
/* QAT only supports SHA3_256 */
|
||||
/* QAT SHA-3 only supported on v2 (8970 or later cards) */
|
||||
if (len == WC_SHA3_256_DIGEST_SIZE) {
|
||||
ret = IntelQaSymSha3(&sha3->asyncDev, hash, NULL, len);
|
||||
if (ret != NOT_COMPILED_IN)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
|
|
@ -352,28 +352,17 @@ static int InitSha512(wc_Sha512* sha512)
|
|||
|
||||
transform_check = 1;
|
||||
}
|
||||
|
||||
int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
|
||||
{
|
||||
int ret = InitSha512(sha512);
|
||||
|
||||
(void)heap;
|
||||
(void)devId;
|
||||
|
||||
Sha512_SetTransform();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
|
||||
#else
|
||||
#define Transform_Sha512(sha512) _Transform_Sha512(sha512)
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
#endif
|
||||
|
||||
int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
|
||||
{
|
||||
#ifdef WOLFSSL_SHA512
|
||||
|
||||
int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (sha512 == NULL)
|
||||
|
@ -385,23 +374,26 @@ static int InitSha512(wc_Sha512* sha512)
|
|||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha512->W = NULL;
|
||||
#endif
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
Sha512_SetTransform();
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha512->W = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
|
||||
ret = wolfAsync_DevCtxInit(&sha512->asyncDev,
|
||||
WOLFSSL_ASYNC_MARKER_SHA512, sha512->heap, devId);
|
||||
#else
|
||||
#else
|
||||
(void)devId;
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
|
||||
#endif /* Hardware Acceleration */
|
||||
|
||||
static const word64 K512[80] = {
|
||||
W64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd),
|
||||
|
@ -2713,21 +2705,6 @@ int wc_Sha384Final(wc_Sha384* sha384, byte* hash)
|
|||
return InitSha384(sha384); /* reset state */
|
||||
}
|
||||
|
||||
|
||||
/* Hardware Acceleration */
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
|
||||
{
|
||||
int ret = InitSha384(sha384);
|
||||
|
||||
(void)heap;
|
||||
(void)devId;
|
||||
|
||||
Sha512_SetTransform();
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
|
||||
{
|
||||
int ret;
|
||||
|
@ -2741,6 +2718,9 @@ int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
|
|||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
Sha512_SetTransform();
|
||||
#endif
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha384->W = NULL;
|
||||
#endif
|
||||
|
@ -2754,7 +2734,7 @@ int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_IMX6_CAAM */
|
||||
|
||||
int wc_InitSha384(wc_Sha384* sha384)
|
||||
|
|
Loading…
Reference in New Issue