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

public Class JournaledAlgorithm

extends Object
implements Encodable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.bouncycastle.util.Encodable
Imports
java.io.BufferedInputStream, .File, .FileInputStream, .FileOutputStream, .IOException, .InputStream, .ObjectInputStream, .ObjectOutputStream, .OutputStream, .Serializable, java.security.SecureRandom, org.bouncycastle.asn1.ASN1EncodableVector, .ASN1OctetString, .ASN1Sequence, .DEROctetString, .DERSequence, org.bouncycastle.asn1.x509.AlgorithmIdentifier, org.bouncycastle.crypto.CryptoServicesRegistrar, org.bouncycastle.util.Encodable, org.bouncycastle.util.io.Streams

JournaledAlgorithm keeps state of the JournalingSecureRandom and the AlgorithmIdentifier necessary to fully resume an encryption session. This class can be used to retrieve a session even if a process is completely stopped.

Note

This should be used with a shutdown hook to save the state of the journaling and the algorithm identifier even in the case of a forced shutdown.

The raw encoding is in ASN.1 format.

Details: Use serialization of critical parameters of the the JournalingSecureRandom and AlgorithmIdentifier. Because these two classes are not serializable, create interior class to serialize only the critical parameters in the form of byte[] arrays

Field Summary

Modifier and TypeField and Description
private transient AlgorithmIdentifier
private transient JournalingSecureRandom

Constructor Summary

AccessConstructor and Description
public
public
JournaledAlgorithm(byte[]
raw encoding of a previous JournaledAlgorithm.
encoding
)

Construct from a previous encoding, using CryptoServicesRegistrar.getSecureRandom() as the backup source of entropy.

public
JournaledAlgorithm(byte[]
raw encoding of a previous JournaledAlgorithm.
encoding
,
SecureRandom
back up source of entropy.
random
)

Construct from a previous encoding, using the passed in random as a source for when the existing entropy runs out.

Method Summary

Modifier and TypeMethod and Description
public AlgorithmIdentifier
public byte[]
getEncoded()

Implements org.bouncycastle.util.Encodable.getEncoded.

Return a byte array representing the implementing object.
public JournalingSecureRandom
public static JournaledAlgorithm
public static JournaledAlgorithm
getState(File
temporary file containing serialized state
tempfile
,
SecureRandom random)

Reconstructs JournaledAlgorithm session from file containing it's raw encoding.

private void
initFromEncoding(byte[] encoding, SecureRandom random)

private void
public void
storeState(File tempfile)

Store state of JournalingSecureRandom and AlgorithmIdentifier in temporary file

public void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algIDback to summary
private transient AlgorithmIdentifier algID
journalingback to summary
private transient JournalingSecureRandom journaling

Constructor Detail

JournaledAlgorithmback to summary
public JournaledAlgorithm(AlgorithmIdentifier aid, JournalingSecureRandom journaling)
JournaledAlgorithmback to summary
public JournaledAlgorithm(byte[] encoding)

Construct from a previous encoding, using CryptoServicesRegistrar.getSecureRandom() as the backup source of entropy.

Parameters
encoding:byte[]

raw encoding of a previous JournaledAlgorithm.

JournaledAlgorithmback to summary
public JournaledAlgorithm(byte[] encoding, SecureRandom random)

Construct from a previous encoding, using the passed in random as a source for when the existing entropy runs out.

Parameters
encoding:byte[]

raw encoding of a previous JournaledAlgorithm.

random:SecureRandom

back up source of entropy.

Method Detail

getAlgorithmIdentifierback to summary
public AlgorithmIdentifier getAlgorithmIdentifier()
getEncodedback to summary
public byte[] getEncoded() throws IOException

Implements org.bouncycastle.util.Encodable.getEncoded.

Doc from org.bouncycastle.util.Encodable.getEncoded.

Return a byte array representing the implementing object.

Returns:byte[]

a byte array representing the encoding.

Exceptions
IOException:
if an issue arises generation the encoding.
getJournalingSecureRandomback to summary
public JournalingSecureRandom getJournalingSecureRandom()
getStateback to summary
public static JournaledAlgorithm getState(InputStream stateIn, SecureRandom random) throws IOException, ClassNotFoundException
getStateback to summary
public static JournaledAlgorithm getState(File tempfile, SecureRandom random) throws IOException, ClassNotFoundException

Reconstructs JournaledAlgorithm session from file containing it's raw encoding.

Parameters
tempfile:File

temporary file containing serialized state

initFromEncodingback to summary
private void initFromEncoding(byte[] encoding, SecureRandom random)
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
storeStateback to summary
public void storeState(File tempfile) throws IOException

Store state of JournalingSecureRandom and AlgorithmIdentifier in temporary file

storeStateback to summary
public void storeState(OutputStream out) throws IOException
writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException