JDK-4210047 : SecureRandom Initialization VERY slow
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_98
  • CPU: x86
  • Submitted: 1999-02-09
  • Updated: 1999-03-02
  • Resolved: 1999-03-02
Description

Name: jn10789			Date: 02/09/99


SecureRandom takes an inordinate amount of time to initialize in Windows 98. I am running on a 300 MHz Pentium II with Windows 98, 192 MB RAM, and 8 GB HD space. Nothing else is running at the time the following program runs. I tried with and without optimization.

import java.security.*;
import java.util.*;

public final class RandomTest {
  private SecureRandom random = new SecureRandom();
	
  public RandomTest() {
    Date start = new Date();
    System.out.println("Random int: " + random.nextInt());
    Date end = new Date();
    System.out.println("Start: " + start);
    System.out.println("End: " + end);
  }
	
  public static void main(String[] args) {
    new RandomTest();
  }
}

And the output:

Random int: -1035658255
Start: Sat Feb 06 12:19:10 EST 1999
End: Sat Feb 06 12:19:44 EST 1999

Note that it took 34 seconds to initialize!

I have run SecureRandom (1.1.6) on a Windows NT machine (150 MHz Pentium) and it only took about 5 seconds to start up.

Any ideas?

Thanks, Ralph
(###@###.###)
(Review ID: 53841)
======================================================================

Comments
EVALUATION charlie.lai@Eng 1999-03-02 the slowness is due to the Win95/Win98 OS and the fact that our SecureRandom implementation needed to be done in pure java. for better performance (without compromising the quality of random numbers generated), you can use JDK 1.2's SecureRandom provider-based implementation to plug in your own SecureRandom provider (which can be native).
2004-06-11