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

Valerie Peng valeriep at openjdk.java.net
Mon Oct 12 19:24:16 UTC 2020


On Thu, 8 Oct 2020 06:51:08 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:
> 
>   Xuelei comments

src/java.base/share/classes/com/sun/crypto/provider/GCTR.java line 165:

> 163:     }
> 164:
> 165:     int update(ByteBuffer src, ByteBuffer dst) {

Based on the impl in GaloisCounterMode, this is only called when src.remaining() >= 128. Perhaps documenting the
conditions here as there are no checks on the src/dst sizes as in the byte[] case.

src/java.base/share/classes/com/sun/crypto/provider/GCTR.java line 237:

> 235:             encrypt(in, offset, processed, out, 0);
> 236:             dst.get(out, 0, processed);
> 237:             return len;

This block of code looks strange?
len = inLen % AES_BLOCK_SIZE => len must be between 0...AES_BLOCK_SIZE-1, I think you meant to use len = (inLen -
inLen% AES_BLOCK_SIZE) dst.get(...) should be dst.put(...)

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

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



More information about the security-dev mailing list