forked from wolfSSL/wolfssl
Added QAT DRBG support.
This commit is contained in:
@ -530,14 +530,13 @@ int wc_InitRng_ex(WC_RNG* rng, void* heap, int devId)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* configure async RNG source if available */
|
/* configure async RNG source if available */
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_CAVIUM)
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
ret = wolfAsync_DevCtxInit(&rng->asyncDev, WOLFSSL_ASYNC_MARKER_RNG,
|
ret = wolfAsync_DevCtxInit(&rng->asyncDev, WOLFSSL_ASYNC_MARKER_RNG,
|
||||||
rng->heap, rng->devId);
|
rng->heap, rng->devId);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_INTEL_RDRAND
|
#ifdef HAVE_INTEL_RDRAND
|
||||||
/* if CPU supports RDRAND, use it directly and by-pass DRBG init */
|
/* if CPU supports RDRAND, use it directly and by-pass DRBG init */
|
||||||
if (IS_INTEL_RDRAND)
|
if (IS_INTEL_RDRAND)
|
||||||
@ -610,9 +609,16 @@ int wc_RNG_GenerateBlock(WC_RNG* rng, byte* output, word32 sz)
|
|||||||
return wc_GenerateRand_IntelRD(NULL, output, sz);
|
return wc_GenerateRand_IntelRD(NULL, output, sz);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_CAVIUM)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
if (rng->asyncDev.marker == WOLFSSL_ASYNC_MARKER_RNG) {
|
if (rng->asyncDev.marker == WOLFSSL_ASYNC_MARKER_RNG) {
|
||||||
|
/* these are blocking */
|
||||||
|
#ifdef HAVE_CAVIUM
|
||||||
return NitroxRngGenerateBlock(rng, output, sz);
|
return NitroxRngGenerateBlock(rng, output, sz);
|
||||||
|
#elif defined(HAVE_INTEL_QA)
|
||||||
|
return IntelQaDrbg(&rng->asyncDev, output, sz);
|
||||||
|
#else
|
||||||
|
/* simulator not supported */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -685,7 +691,7 @@ int wc_FreeRng(WC_RNG* rng)
|
|||||||
if (rng == NULL)
|
if (rng == NULL)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_CAVIUM)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
wolfAsync_DevCtxFree(&rng->asyncDev, WOLFSSL_ASYNC_MARKER_RNG);
|
wolfAsync_DevCtxFree(&rng->asyncDev, WOLFSSL_ASYNC_MARKER_RNG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -37,7 +37,11 @@
|
|||||||
|
|
||||||
/* Maximum generate block length */
|
/* Maximum generate block length */
|
||||||
#ifndef RNG_MAX_BLOCK_LEN
|
#ifndef RNG_MAX_BLOCK_LEN
|
||||||
#define RNG_MAX_BLOCK_LEN (0x10000)
|
#ifdef HAVE_INTEL_QA
|
||||||
|
#define RNG_MAX_BLOCK_LEN (0xFFFF)
|
||||||
|
#else
|
||||||
|
#define RNG_MAX_BLOCK_LEN (0x10000)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Size of the BRBG seed */
|
/* Size of the BRBG seed */
|
||||||
|
Reference in New Issue
Block a user