- java.lang.Object
-
- java.security.SecureRandomSpi
-
- All Implemented Interfaces:
Serializable
public abstract class SecureRandomSpi extends Object implements Serializable
This class defines the Service Provider Interface (SPI) for theSecureRandomclass.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.
- Since:
- 1.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description SecureRandomSpi()Constructor without a parameter.protectedSecureRandomSpi(SecureRandomParameters params)Constructor with a parameter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract byte[]engineGenerateSeed(int numBytes)Returns the given number of seed bytes.protected SecureRandomParametersengineGetParameters()Returns the effectiveSecureRandomParametersfor thisSecureRandominstance.protected abstract voidengineNextBytes(byte[] bytes)Generates a user-specified number of random bytes.protected voidengineNextBytes(byte[] bytes, SecureRandomParameters params)Generates a user-specified number of random bytes with additional parameters.protected voidengineReseed(SecureRandomParameters params)Reseeds this random object with entropy input read from its entropy source with additional parameters.protected abstract voidengineSetSeed(byte[] seed)Reseeds this random object with the given seed.StringtoString()Returns a Human-readable string representation of thisSecureRandom.
-
-
-
Constructor Detail
-
SecureRandomSpi
public SecureRandomSpi()
Constructor without a parameter.
-
SecureRandomSpi
protected SecureRandomSpi(SecureRandomParameters params)
Constructor with a parameter.- Parameters:
params- theSecureRandomParametersobject. This argument can benull.- Throws:
IllegalArgumentException- ifparamsis unrecognizable or unsupported by thisSecureRandom- Since:
- 9
-
-
Method Detail
-
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- the seed.
-
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
bytesis 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- the array to be filled in with random 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
bytesis 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- the array to be filled in with random bytesparams- additional parameters- Throws:
UnsupportedOperationException- if the implementation has not overridden this methodIllegalArgumentException- ifparamsisnull, illegal or unsupported by thisSecureRandom- Since:
- 9
-
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- the number of seed bytes to generate.- Returns:
- the seed 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(),paramswill benull.Do not override this method if the implementation does not support reseeding.
- Parameters:
params- extra parameters, can benull.- Throws:
UnsupportedOperationException- if the implementation has not overridden this methodIllegalArgumentException- ifparamsis illegal or unsupported by thisSecureRandom- Since:
- 9
-
engineGetParameters
protected SecureRandomParameters engineGetParameters()
Returns the effectiveSecureRandomParametersfor thisSecureRandominstance.- Returns:
- the effective
SecureRandomParametersparameters, ornullif no parameters were used. - Since:
- 9
-
-