@@ -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
825835int 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 */
0 commit comments