Skip to content

Commit 9ce0432

Browse files
committed
Fix GCMSIVBlockCipher processing
1 parent 2030214 commit 9ce0432

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

core/src/main/java/org/bouncycastle/crypto/modes/GCMSIVBlockCipher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ void updateHash(final byte[] pBuffer,
935935
gHASH(theReverse);
936936

937937
/* Adjust counters */
938-
numProcessed += mySpace;
939-
myRemaining -= mySpace;
938+
numProcessed += BUFLEN;
939+
myRemaining -= BUFLEN;
940940
}
941941

942942
/* If we have remaining data */

core/src/test/java/org/bouncycastle/crypto/test/GCMSIVTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ void testSIVCipher(final GCMSIVBlockCipher pCipher,
8080
pCipher.doFinal(myOutput, 0);
8181
isTrue("Encryption mismatch", Arrays.areEqual(myExpected, myOutput));
8282

83+
if (myData.length >= 2)
84+
{
85+
/* Repeat processing checking processBytes with non-empty internal buffer */
86+
pCipher.processByte(myData[0], null, 0);
87+
pCipher.processBytes(myData, 1, myData.length - 1, null, 0);
88+
pCipher.doFinal(myOutput, 0);
89+
isTrue("Encryption mismatch", Arrays.areEqual(myExpected, myOutput));
90+
}
91+
8392
/* Re-initialise the cipher */
8493
pCipher.init(false, myParams);
8594
pCipher.processBytes(myOutput, 0, myOutput.length, null, 0);

0 commit comments

Comments
 (0)