RFR 8226543 : Reduce GC pressure during message digest calculations in password-based encryption

Ivan Gerasimov ivan.gerasimov at oracle.com
Wed Jun 26 00:29:20 UTC 2019


Thank you Sean for review!


On 6/25/19 10:55 AM, Sean Mullan wrote:
> Hi Ivan,
>
> This fix looks good.
>
> --Sean
>
> On 6/20/19 10:22 PM, Ivan Gerasimov wrote:
>> Hello!
>>
>> In PBES1Core.deriveCipherKey() there are loops that look like following:
>>
>>              for (int i = 0; i < iCount; i++) {
>>                  md.update(toBeHashed);
>>                  toBeHashed = md.digest(); // this resets the digest
>>              }
>>
>> Calling md.digest() each time allocates a new byte[] array.
>> It would be more GC friendly, if the same array were reused.
>>
>> In the fix, a first call to md.digest() allocates a properly sized 
>> array.
>> Subsequent iterations reuse this array.
>>
>> Would you please help review?
>>
>> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8226543
>> WEBREV: http://cr.openjdk.java.net/~igerasim/8226543/00/webrev/
>>
>> No new regression test, as the behavior was not changed.
>> Mach5 control job is green (tiers 1-4 on all supported platforms).
>>
>

-- 
With kind regards,
Ivan Gerasimov



More information about the security-dev mailing list