Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.security
Class VMSecureRandom  view VMSecureRandom download VMSecureRandom.java

java.lang.Object
  extended byjava.security.VMSecureRandom

final class VMSecureRandom
extends java.lang.Object

VM-specific methods for generating real (or almost real) random seeds. VM implementors should write a version of this class that reads random bytes from some system source.

The default implementation of this class runs eight threads that increment counters in a tight loop, and XORs each counter to produce one byte of seed data. This is not very efficient, and is not guaranteed to be random (the thread scheduler is probably deterministic, after all). If possible, VM implementors should reimplement this class so it obtains a random seed from a system facility, such as a system entropy gathering device or hardware random number generator.


Nested Class Summary
(package private) static class VMSecureRandom.Spinner
           
 
Constructor Summary
(package private) VMSecureRandom()
           
 
Method Summary
(package private) static int generateSeed(byte[] buffer, int offset, int length)
          Generate a random seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VMSecureRandom

VMSecureRandom()
Method Detail

generateSeed

static int generateSeed(byte[] buffer,
                        int offset,
                        int length)
Generate a random seed. Implementations are free to generate fewer random bytes than are requested, and leave the remaining bytes of the destination buffer as zeros. Implementations SHOULD, however, make a best-effort attempt to satisfy the request.