Skip to content

Commit 5ed33c7

Browse files
authored
Merge pull request #17 from wolfSSL/asyncfsanitize
Fixes for a couple of async fsanitize reports
2 parents 2c4b751 + 2bb9069 commit 5ed33c7

4 files changed

Lines changed: 34 additions & 11 deletions

File tree

wolfcrypt/src/port/cavium/cavium_nitrox.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,12 +815,22 @@ int NitroxAesGcmEncrypt(Aes* aes,
815815
byte* authTag, word32 authTagSz,
816816
const byte* authIn, word32 authInSz)
817817
{
818+
const byte* ivTmp = iv;
819+
byte ivLcl[AES_BLOCK_SIZE];
820+
818821
(void)keySz;
819-
(void)ivSz;
820822
(void)authTagSz;
821-
return NitroxAesEncrypt(aes, AES_GCM, key, iv, out, in, sz,
823+
824+
/* Nitrox HW requires IV buffer to be 16-bytes */
825+
if (ivSz < AES_BLOCK_SIZE) {
826+
ivTmp = ivLcl;
827+
XMEMCPY(ivLcl, iv, ivSz);
828+
}
829+
830+
return NitroxAesEncrypt(aes, AES_GCM, key, ivTmp, out, in, sz,
822831
authInSz, authIn, authTag);
823832
}
833+
824834
#ifdef HAVE_AES_DECRYPT
825835
int NitroxAesGcmDecrypt(Aes* aes,
826836
byte* out, const byte* in, word32 sz,
@@ -829,10 +839,19 @@ int NitroxAesGcmDecrypt(Aes* aes,
829839
const byte* authTag, word32 authTagSz,
830840
const byte* authIn, word32 authInSz)
831841
{
842+
const byte* ivTmp = iv;
843+
byte ivLcl[AES_BLOCK_SIZE];
844+
832845
(void)keySz;
833-
(void)ivSz;
834846
(void)authTagSz;
835-
return NitroxAesDecrypt(aes, AES_GCM, key, iv, out, in, sz,
847+
848+
/* Nitrox HW requires IV buffer to be 16-bytes */
849+
if (ivSz < AES_BLOCK_SIZE) {
850+
ivTmp = ivLcl;
851+
XMEMCPY(ivLcl, iv, ivSz);
852+
}
853+
854+
return NitroxAesDecrypt(aes, AES_GCM, key, ivTmp, out, in, sz,
836855
authInSz, authIn, authTag);
837856
}
838857
#endif /* HAVE_AES_DECRYPT */

wolfcrypt/src/port/intel/quickassist.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,10 +3404,15 @@ int IntelQaDrbg(WC_ASYNC_DEV* dev, byte* rngBuf, word32 rngSz)
34043404
gen = 0xFFFF;
34053405

34063406
pOut->dataLenInBytes = gen;
3407-
pOut->pData = XREALLOC(&rngBuf[idx], gen, dev->heap,
3408-
DYNAMIC_TYPE_ASYNC_NUMA);
3409-
if (pOut->pData == NULL) {
3410-
ret = MEMORY_E; goto exit;
3407+
if (idx == 0 && pOut->pData == NULL) {
3408+
pOut->pData = XREALLOC(rngBuf, gen, dev->heap,
3409+
DYNAMIC_TYPE_ASYNC_NUMA);
3410+
if (pOut->pData == NULL) {
3411+
ret = MEMORY_E; goto exit;
3412+
}
3413+
}
3414+
else {
3415+
XMEMCPY(pOut->pData, &rngBuf[idx], gen);
34113416
}
34123417

34133418
opData->sessionHandle = dev->qat.op.drbg.handle;

wolfcrypt/src/port/intel/quickassist_mem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ static void* _qaeMemAlloc(size_t size, void* heap, int type
374374
/* allocate type */
375375
if (isNuma) {
376376
/* Node is typically 0 */
377-
ptr = qaeMemAllocNUMA(size + sizeof(qaeMemHeader), 0, alignment,
378-
&page_offset);
377+
ptr = qaeMemAllocNUMA((Cpa32U)(size + sizeof(qaeMemHeader)), 0,
378+
alignment, &page_offset);
379379
}
380380
if (ptr == NULL) {
381381
isNuma = 0;

wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#define AES_CBC 0x3
5252
#define AES_GCM 0x7
5353
#else
54-
typedef int CspHandle;
5554
typedef word64 CavReqId;
5655
#define CAVIUM_DEV_ID 0
5756
#define CAVIUM_BLOCKING BLOCKING

0 commit comments

Comments
 (0)