APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.provider

public final Class DRBG

extends SecureRandomSpi
Class Inheritance
Imports
java.io.IOException, .InvalidObjectException, java.security.DrbgParameters, .SecureRandomParameters, .SecureRandomSpi, .Security, java.util.Locale

Implement the "SecureRandom.DRBG" algorithm. About the default "securerandom.drbg.config" value: The default value in java.security is set to "". This is because the default values of different aspects are dependent (For example, strength depends on algorithm) and if we write a full string there it will be difficult to modify one and keep all others legal. When changing default values, touch all places including: 1. comments of the security property in java.security 2. Default mech, cap, usedf set in this class 3. Default algorithm set in final implementation of each mech 4. Default strength set in AbstractDrbg, but the effective value can be smaller if an algorithm does not support it. The default value is also mentioned in the @implNote part of DrbgParameters class.

Field Summary

Modifier and TypeField and Description
private transient AbstractDrbg
private final MoreDrbgParameters
private static final String
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
checkTwice(boolean
true if set more than once
flag
,
String
the name of aspect shown in IAE
name
)

Ensures an aspect is not set more than once.

private void
protected byte[]
engineGenerateSeed(int numBytes)

Implements abstract java.security.SecureRandomSpi.engineGenerateSeed.

Returns the given number of seed bytes.

protected SecureRandomParameters
engineGetParameters()

Overrides java.security.SecureRandomSpi.engineGetParameters.

Returns the effective SecureRandomParameters for this SecureRandom instance.

protected void
engineNextBytes(byte[] bytes)

Implements abstract java.security.SecureRandomSpi.engineNextBytes.

Generates a user-specified number of random bytes.

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

Overrides java.security.SecureRandomSpi.engineNextBytes.

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

protected void
engineReseed(SecureRandomParameters params)

Overrides java.security.SecureRandomSpi.engineReseed.

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

protected void
engineSetSeed(byte[] seed)

Implements abstract java.security.SecureRandomSpi.engineSetSeed.

Reseeds this random object with the given seed.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Restores the state of this object from the stream.

public String
toString()

Overrides java.security.SecureRandomSpi.toString.

Returns a Human-readable string representation of this SecureRandom.

Field Detail

implback to summary
private transient AbstractDrbg impl
mdpback to summary
private final MoreDrbgParameters mdp
PROP_NAMEback to summary
private static final String PROP_NAME
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.SecureRandomSpi.serialVersionUID.

Annotations
@Serial

Constructor Detail

DRBGback to summary
public DRBG(SecureRandomParameters params)

Method Detail

checkTwiceback to summary
private static void checkTwice(boolean flag, String name)

Ensures an aspect is not set more than once.

Parameters
flag:boolean

true if set more than once

name:String

the name of aspect shown in IAE

Exceptions
IllegalArgumentException:
if it happens
createImplback to summary
private void createImpl()
engineGenerateSeedback to summary
protected byte[] engineGenerateSeed(int numBytes)

Implements abstract java.security.SecureRandomSpi.engineGenerateSeed.

Doc from java.security.SecureRandomSpi.engineGenerateSeed.

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

Annotations
@Override
engineGetParametersback to summary
protected SecureRandomParameters engineGetParameters()

Overrides java.security.SecureRandomSpi.engineGetParameters.

Doc from java.security.SecureRandomSpi.engineGetParameters.

Returns the effective SecureRandomParameters for this SecureRandom instance.

Annotations
@Override
engineNextBytesback to summary
protected void engineNextBytes(byte[] bytes)

Implements abstract java.security.SecureRandomSpi.engineNextBytes.

Doc from java.security.SecureRandomSpi.engineNextBytes.

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.

Annotations
@Override
engineNextBytesback to summary
protected void engineNextBytes(byte[] bytes, SecureRandomParameters params)

Overrides java.security.SecureRandomSpi.engineNextBytes.

Doc from java.security.SecureRandomSpi.engineNextBytes.

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.

Annotations
@Override
engineReseedback to summary
protected void engineReseed(SecureRandomParameters params)

Overrides java.security.SecureRandomSpi.engineReseed.

Doc from java.security.SecureRandomSpi.engineReseed.

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.

Annotations
@Override
engineSetSeedback to summary
protected void engineSetSeed(byte[] seed)

Implements abstract java.security.SecureRandomSpi.engineSetSeed.

Doc from java.security.SecureRandomSpi.engineSetSeed.

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.

Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
s:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
toStringback to summary
public String toString()

Overrides java.security.SecureRandomSpi.toString.

Doc from java.security.SecureRandomSpi.toString.

Returns a Human-readable string representation of this SecureRandom.

Annotations
@Override