Top Description Inners Fields Constructors Methods
org.bouncycastle.crypto.util

public Class JournalingSecureRandom

extends SecureRandom
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, java.security.SecureRandom, org.bouncycastle.crypto.CryptoServicesRegistrar, org.bouncycastle.util.Arrays

A SecureRandom that maintains a journal of its output. This can be used to recreate an output that was based on randomness For the transcript to be reusable, the order of the requests for randomness during recreation must be consistent with the initial requests and no other sources of randomness may be used.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final SecureRandom
private static byte[]
private int
private JournalingSecureRandom.TranscriptStream
private byte[]

Constructor Summary

AccessConstructor and Description
public
JournalingSecureRandom()

Default constructor that takes an arbitrary SecureRandom as initial random

public
JournalingSecureRandom(SecureRandom
source of randomness we will be journaling.
random
)

Base constructor - no prior transcript.

public
JournalingSecureRandom(byte[]
initial transcript of randomness.
transcript
,
SecureRandom
source of randomness we will be journaling when the transcript runs out.
random
)

Constructor with a prior transcript.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clear the internals

public byte[]

Returns:

a copy of the original transcript on construction, plus any randomness added since.
getFullTranscript
()

Return the full transcript, such as would be needed to create a copy of this JournalingSecureRandom,

public byte[]

Returns:

a copy of the randomness produced so far.
getTranscript
()

Return the transcript so far,

public final void
nextBytes(byte[]
a block of bytes to be filled with random data.
bytes
)

Overrides java.security.SecureRandom.nextBytes.

Overrides default java.util.random.RandomGenerator.nextBytes.

Fill bytes with random data, journaling the random data before returning or re-use previously used random data, depending on the state of the transcript.
public void
reset()

Resets the index to zero such that the randomness will now be reused

Inherited from java.security.SecureRandom:
generateSeedgetAlgorithmgetInstancegetInstancegetInstancegetInstancegetInstancegetInstancegetInstanceStronggetParametersgetProvidergetSeednextnextBytesreseedreseedsetSeedsetSeedtoString

Field Detail

baseback to summary
private final SecureRandom base
EMPTY_TRANSCRIPTback to summary
private static byte[] EMPTY_TRANSCRIPT
indexback to summary
private int index
tOutback to summary
private JournalingSecureRandom.TranscriptStream tOut
transcriptback to summary
private byte[] transcript

Constructor Detail

JournalingSecureRandomback to summary
public JournalingSecureRandom()

Default constructor that takes an arbitrary SecureRandom as initial random

JournalingSecureRandomback to summary
public JournalingSecureRandom(SecureRandom random)

Base constructor - no prior transcript.

Parameters
random:SecureRandom

source of randomness we will be journaling.

JournalingSecureRandomback to summary
public JournalingSecureRandom(byte[] transcript, SecureRandom random)

Constructor with a prior transcript. Both the transcript used and any new randomness are journaled.

Parameters
transcript:byte[]

initial transcript of randomness.

random:SecureRandom

source of randomness we will be journaling when the transcript runs out.

Method Detail

clearback to summary
public void clear()

Clear the internals

getFullTranscriptback to summary
public byte[] getFullTranscript()

Return the full transcript, such as would be needed to create a copy of this JournalingSecureRandom,

Returns:byte[]

a copy of the original transcript on construction, plus any randomness added since.

getTranscriptback to summary
public byte[] getTranscript()

Return the transcript so far,

Returns:byte[]

a copy of the randomness produced so far.

nextBytesback to summary
public final void nextBytes(byte[] bytes)

Overrides java.security.SecureRandom.nextBytes.

Overrides default java.util.random.RandomGenerator.nextBytes.

Fill bytes with random data, journaling the random data before returning or re-use previously used random data, depending on the state of the transcript.

Parameters
bytes:byte[]

a block of bytes to be filled with random data.

resetback to summary
public void reset()

Resets the index to zero such that the randomness will now be reused

org.bouncycastle.crypto.util back to summary

private Class JournalingSecureRandom.TranscriptStream

extends ByteArrayOutputStream
Class Inheritance

Field Summary

Inherited from java.io.ByteArrayOutputStream:
bufcount

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.io.ByteArrayOutputStream:
closeresetsizetoByteArraytoStringtoStringtoStringtoStringwritewritewriteByteswriteTo

Constructor Detail

TranscriptStreamback to summary
private TranscriptStream()

Method Detail

clearback to summary
public void clear()