SecureRandomSpi  |  API reference  |  Android Developers

public abstract class SecureRandomSpi
extends Object implements Serializable



This class defines the Service Provider Interface (SPI) for the SecureRandom class.

All the abstract methods in this class must be implemented by each service provider who wishes to supply the implementation of a cryptographically strong pseudo-random number generator.

Summary

Public constructors

SecureRandomSpi()

Constructor without a parameter.

Protected constructors

SecureRandomSpi(SecureRandomParameters params)

Constructor with a parameter.

Public methods

String toString()

Returns a Human-readable string representation of this SecureRandom.

Protected methods

abstract byte[] engineGenerateSeed(int numBytes)

Returns the given number of seed bytes.

SecureRandomParameters engineGetParameters()

Returns the effective SecureRandomParameters for this SecureRandom instance.

void engineNextBytes(byte[] bytes, SecureRandomParameters params)

Generates a user-specified number of random bytes with additional parameters.

abstract void engineNextBytes(byte[] bytes)

Generates a user-specified number of random bytes.

void engineReseed(SecureRandomParameters params)

Reseeds this random object with entropy input read from its entropy source with additional parameters.

abstract void engineSetSeed(byte[] seed)

Reseeds this random object with the given seed.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

SecureRandomSpi

public SecureRandomSpi ()

Constructor without a parameter.

Protected constructors

Public methods

toString

public String toString ()

Returns a Human-readable string representation of this SecureRandom.

Returns
String the string representation

Protected methods

engineGenerateSeed

protected abstract byte[] engineGenerateSeed (int numBytes)

Returns the given number of seed bytes. This call may be used to seed other random number generators.

Parameters
numBytes int: the number of seed bytes to generate.
Returns
byte[] the seed bytes.

engineNextBytes

protected void engineNextBytes (byte[] bytes, 
                SecureRandomParameters params)

Generates a user-specified number of random bytes with additional parameters.

Some random number generators can only generate a limited amount of random bytes per invocation. If the size of bytes is greater than this limit, the implementation should invoke its generation process multiple times to completely fill the buffer before returning from this method.

Parameters
bytes byte: the array to be filled in with random bytes
params SecureRandomParameters: additional parameters
Throws
IllegalArgumentException if params is null, illegal or unsupported by this SecureRandom
UnsupportedOperationException if the implementation has not overridden this method

engineNextBytes

protected abstract void engineNextBytes (byte[] bytes)

Generates a user-specified number of random bytes.

Some random number generators can only generate a limited amount of random bytes per invocation. If the size of bytes is greater than this limit, the implementation should invoke its generation process multiple times to completely fill the buffer before returning from this method.

Parameters
bytes byte: the array to be filled in with random bytes.

engineReseed

protected void engineReseed (SecureRandomParameters params)

Reseeds this random object with entropy input read from its entropy source with additional parameters.

If this method is called by SecureRandom.reseed(), params will be null.

Do not override this method if the implementation does not support reseeding.

Parameters
params SecureRandomParameters: extra parameters, can be null.
Throws
IllegalArgumentException if params is illegal or unsupported by this SecureRandom
UnsupportedOperationException if the implementation has not overridden this method

engineSetSeed

protected abstract void engineSetSeed (byte[] seed)

Reseeds this random object with the given seed. The seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.

Parameters
seed byte: the seed.