Skip to content

Commit 2bb9069

Browse files
committed
Fixes for fsantize tests with Cavium Nitrox V. Removed typedef for CspHandle since its already defined.
1 parent 9e532c2 commit 2bb9069

2 files changed

Lines changed: 23 additions & 5 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 */

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)