RFR: 8258915: Temporary buffer cleanup [v8]

Valerie Peng valeriep at openjdk.java.net
Thu Feb 18 11:07:45 UTC 2021


On Sat, 6 Feb 2021 14:40:04 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Clean up temporary byte array, char array, and keyspec around keys and passwords.
>> 
>> No new regression test.
>
> Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   materials

src/java.base/share/classes/com/sun/crypto/provider/TlsKeyMaterialGenerator.java line 220:

> 218:                     System.arraycopy(keyBlock, ofs, tmp, 0, ivLength);
> 219:                     ofs += ivLength;
> 220:                     serverIv = new IvParameterSpec(tmp);

Seems easier to just use the IvParameterSpec(byte[], int, int) constructor?

src/java.base/share/classes/com/sun/crypto/provider/TlsKeyMaterialGenerator.java line 251:

> 249:                         clientIv = new IvParameterSpec(tmp);
> 250:                         System.arraycopy(block, ivLength, tmp, 0, ivLength);
> 251:                         serverIv = new IvParameterSpec(tmp);

Again, consider using IvParameterSpec(byte[], int, int) and get rid of tmp?

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

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


More information about the security-dev mailing list