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

pack-priv final Class P11SecureRandom

extends SecureRandomSpi
Class Inheritance
Imports
java.io.*, java.security.*, sun.security.pkcs11.wrapper.*

SecureRandom implementation class. Some tokens support only C_GenerateRandom() and not C_SeedRandom(). In order not to lose an application specified seed, we create a SHA1PRNG that we mix with in that case. Note that since SecureRandom is thread safe, we only need one instance per PKCS#11 token instance. It is created on demand and cached in the SunPKCS11 class. Also note that we obtain the PKCS#11 session on demand, no need to tie one up.
Author
Andreas Sterbenz
Since
1.5

Field Summary

Modifier and TypeField and Description
private int
private transient byte[]
private static final int
private transient int
private transient long
private static final long
private byte[]
private volatile SecureRandom
private static final long
private final Token

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected byte[]
engineGenerateSeed(int numBytes)

Implements abstract java.security.SecureRandomSpi.engineGenerateSeed.

Returns the given number of seed bytes.

protected void
engineNextBytes(byte[] bytes)

Implements abstract java.security.SecureRandomSpi.engineNextBytes.

Generates a user-specified number of random bytes.

protected synchronized void
engineSetSeed(byte[] seed)

Implements abstract java.security.SecureRandomSpi.engineSetSeed.

Reseeds this random object with the given seed.

private void
implNextBytes(byte[] bytes)

private void
mix(byte[] b)

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

Restores the state of this object from the stream.

Inherited from java.security.SecureRandomSpi:
engineGetParametersengineNextBytesengineReseedtoString

Field Detail

bufferedback to summary
private int buffered
iBufferback to summary
private transient byte[] iBuffer
IBUFFER_SIZEback to summary
private static final int IBUFFER_SIZE
ibufferedback to summary
private transient int ibuffered
lastReadback to summary
private transient long lastRead
MAX_IBUFFER_TIMEback to summary
private static final long MAX_IBUFFER_TIME
mixBufferback to summary
private byte[] mixBuffer
mixRandomback to summary
private volatile SecureRandom mixRandom
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.SecureRandomSpi.serialVersionUID.

Annotations
@Serial
tokenback to summary
private final Token token

Constructor Detail

P11SecureRandomback to summary
pack-priv P11SecureRandom(Token token)

Method Detail

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
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
engineSetSeedback to summary
protected synchronized 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
implNextBytesback to summary
private void implNextBytes(byte[] bytes)
mixback to summary
private void mix(byte[] b)
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Restores the state of this object from the stream.

Parameters
in: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