RFR 8210476: sun/security/mscapi/PrngSlow.java fails with Still too slow

Weijun Wang weijun.wang at oracle.com
Tue Nov 27 01:33:33 UTC 2018


Ping again

> On Nov 20, 2018, at 5:33 PM, Weijun Wang <weijun.wang at oracle.com> wrote:
> 
> Webrev updated at
> 
>   https://cr.openjdk.java.net/~weijun/8210476/webrev.01/
> 
> The only change is that there is a single Cleaner now for the whole PRNG class. Otherwise, each will maintain its own thread.
> 
> Thanks
> Max
> 
>> On Nov 11, 2018, at 11:30 PM, Weijun Wang <weijun.wang at oracle.com> wrote:
>> 
>> Please take a review at
>> 
>>  https://cr.openjdk.java.net/~weijun/8210476/webrev.00/
>> 
>> Before this fix, every PRNG::nextBytes calls all of CryptAcquireContext, CryptGenRandom, and CryptReleaseContext. Now, CryptAcquireContext is called once in PRNG::new, and CryptReleaseContext is called by a Cleaner, and nextBytes only calls CryptGenRandom.
>> 
>> I haven't read about thread-safety in any MS document, the current Windows-PRNG service is marked ThreadSafe=true (in SunMSCAPI.java). If we cannot be really sure, we can change it to false.
>> 
>> I've downloaded nearly 1000 Mach5 runs of this test, the enhancement is so good that I adjusted the test to be stricter.
>> 
>> 	Before	After
>> 	------	-----
>> Count	897	74
>> Min	0.38	0.008
>> Ave	0.97	0.011
>> Max	5.81	0.021
>> 
>> Please advise me if the following usage of Cleaner is correct because I really haven't observed the releaseContext method being called.
>> 
>> +        Cleaner.create().register(this,
>> +                () -> releaseContext(ctxt));
>> 
>> Thanks
>> Max
>> 
> 



More information about the security-dev mailing list