RFR: JDK-8338587 - Internal XOF Methods for SHAKE128 and SHAKE256

Weijun Wang weijun at openjdk.org
Mon Aug 26 13:48:03 UTC 2024


On Mon, 26 Aug 2024 13:37:42 GMT, Ferenc Rakoczi <duke at openjdk.org> wrote:

>> src/java.base/share/classes/sun/security/provider/SHA3.java line 123:
>> 
>>> 121:      */
>>> 122:     void implDigest(byte[] out, int ofs) {
>>> 123:         byte[] byteState = new byte[8];
>> 
>> `byteState` can be moved to line 150.
>
> If I do that, the performance drops a little. So I rather keep it here.

I see. In fact, what if `byteState` is an instance variable outside the method? If a previous squeeze has left some bytes there, there is no need to call `asLittleEndian.set` again next time they are needed. Does it help in any performance gain? especially if the caller only squeeze a few bytes each time?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20631#discussion_r1731271264



More information about the security-dev mailing list