RFR: 8333364: Minor cleanup could be done in com.sun.crypto.provider [v4]

Mark Powers mpowers at openjdk.org
Tue Jul 2 17:22:26 UTC 2024


On Mon, 24 Jun 2024 18:15:21 GMT, Sean Mullan <mullan at openjdk.org> wrote:

>> Mark Powers has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   move variables to above try block
>
> src/java.base/share/classes/com/sun/crypto/provider/ChaCha20Poly1305Parameters.java line 210:
> 
>> 208:         HexDumpEncoder encoder = new HexDumpEncoder();
>> 209:         return LINE_SEP + "nonce:" +
>> 210:                 LINE_SEP + "[" + encoder.encodeBuffer(nonce) + "]";
> 
> This is probably not a performance sensitive method, but another fix would be to keep `StringBuilder` but call append() for each part of the String. Causes fewer objects to be created. I could accept either fix though unless there is an obvious performance issue.

I used JMH to benchmark both fixes and they measured the same. Then I remembered that the java compiler converts + operations to StringBuilder's append. I'll keep the proposed fix.

> src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java line 175:
> 
>> 173:      * Diffie-Hellman between 2 parties, this would be the other party's
>> 174:      * Diffie-Hellman public key.
>> 175:      * @param lastPhase flag which indicates whether this is the last
> 
> s/whether/if/

fixed

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19535#discussion_r1662902973
PR Review Comment: https://git.openjdk.org/jdk/pull/19535#discussion_r1662903402



More information about the security-dev mailing list