Skip to content

Commit c450bdb

Browse files
authored
Merge pull request #10471 from JacobBarthelmeh/cavium_octeon
fix Octeon AES-GCM J0 derivation when ivSz is a non-12-byte non-zero …
2 parents 121387a + d184b79 commit c450bdb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

wolfcrypt/src/port/cavium/cavium_octeon_sync.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,12 @@ static NOOPT int Octeon_AesGcm_SetIV(Aes* aes, byte* iv, word32 ivSz)
514514
for (i = 0; i < blocks; i++, iv += WC_AES_BLOCK_SIZE)
515515
Octeon_GHASH_Update(iv);
516516

517-
XMEMSET(aesBlock, 0, sizeof(aesBlock));
518-
for (i = 0; i < remainder; i++)
519-
aesBlock[i] = iv[i];
520-
Octeon_GHASH_Update(aesBlock);
517+
if (remainder > 0) {
518+
XMEMSET(aesBlock, 0, sizeof(aesBlock));
519+
for (i = 0; i < remainder; i++)
520+
aesBlock[i] = iv[i];
521+
Octeon_GHASH_Update(aesBlock);
522+
}
521523

522524
Octeon_GHASH_Final((byte*)aes->reg, 0, ivSz);
523525
}

0 commit comments

Comments
 (0)