RFR: 8253821: Improve ByteBuffer performance with GCM [v4]

Valerie Peng valeriep at openjdk.java.net
Fri Nov 13 21:04:05 UTC 2020


On Thu, 12 Nov 2020 16:34:30 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:

>> 8253821: Improve ByteBuffer performance with GCM
>
> Anthony Scarpino has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Code review comment update
>   Major change to test to detect corruption with incremental buffers test

src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 560:

> 558:             System.arraycopy(buffer, 0, block, 0, blockSize);
> 559:             buflen -= block.length;
> 560:             return 0;

Will bufLen > blockSize? Judging from the context of this method, buffer.length should always <= blockSize and  never be larger? If bufLen == blockSize, perhaps we can just use buffer directly and no need to copy.

src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 559:

> 557:         if (buflen >= blockSize) {
> 558:             System.arraycopy(buffer, 0, block, 0, blockSize);
> 559:             buflen -= block.length;

bufLen isn't used, why bother updating its value?

-------------

PR: https://git.openjdk.java.net/jdk/pull/411



More information about the security-dev mailing list