On Wed, 14 Jul 2021 21:02:01 GMT, Smita Kamath <svkam...@openjdk.org> wrote:
>> I would like to submit AES-GCM optimization for x86_64 architectures >> supporting AVX3+VAES (Evex encoded AES). This optimization interleaves AES >> and GHASH operations. >> Performance gain of ~1.5x - 2x for message sizes 8k and above. > > Smita Kamath has updated the pull request incrementally with one additional > commit since the last revision: > > Updated AES-GCM intrinsic to match latest Java Code src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 629: > 627: GCTR gctr; > 628: GHASH ghash; > 629: GCMOperation op; It seems clearer to initialize "op" in GCMEngine ctor since it's declared here. There is already logic in its method checking whether we are doing encryption or decryption. src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 650: > 648: int originalOutOfs = 0; > 649: byte[] in; > 650: byte[] out; The name "in", "out" are almost used in all calls, it's hard to tell when these two are actually used. Can we rename them to make them more unique? src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 724: > 722: } else { > 723: ct = in; > 724: } This can just be: byte[] ct = (encryption? out : in); Since you only use this 'ct' variable inside the else block on line 746, move this down to that block. src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 743: > 741: dst.array(), dst.arrayOffset() + > dst.position(), > 742: gctr, ghash); > 743: } Can we use another ByteBuffer variable to avoid almost-duplicate calls? ByteBuffer ct = (encryption? dst : src); rlen -= GaloisCounterMode.implGCMCrypt(src.array(), src.arrayOffset() + src.position(), src.remaining(), ct.array(), ct.arrayOffset() + ct.position(), dst.array(), dst.arrayOffset() + dst.position(), gctr, ghash); ------------- PR: https://git.openjdk.java.net/jdk/pull/4019