Package org.bouncycastle.crypto.util
Class JournaledAlgorithm
java.lang.Object
org.bouncycastle.crypto.util.JournaledAlgorithm
- All Implemented Interfaces:
Serializable
,Encodable
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
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJournaledAlgorithm
(byte[] encoding) Construct from a previous encoding, using CryptoServicesRegistrar.getSecureRandom() as the backup source of entropy.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.JournaledAlgorithm
(AlgorithmIdentifier aid, JournalingSecureRandom journaling) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Return a byte array representing the implementing object.static JournaledAlgorithm
getState
(File tempfile, SecureRandom random) Reconstructs JournaledAlgorithm session from file containing it's raw encoding.static JournaledAlgorithm
getState
(InputStream stateIn, SecureRandom random) void
storeState
(File tempfile) Store state of JournalingSecureRandom and AlgorithmIdentifier in temporary filevoid
storeState
(OutputStream out)
-
Constructor Details
-
JournaledAlgorithm
-
JournaledAlgorithm
public JournaledAlgorithm(byte[] encoding) Construct from a previous encoding, using CryptoServicesRegistrar.getSecureRandom() as the backup source of entropy.- Parameters:
encoding
- raw encoding of a previous JournaledAlgorithm.
-
JournaledAlgorithm
Construct from a previous encoding, using the passed in random as a source for when the existing entropy runs out.- Parameters:
encoding
- raw encoding of a previous JournaledAlgorithm.random
- back up source of entropy.
-
-
Method Details
-
getJournalingSecureRandom
-
getAlgorithmIdentifier
-
storeState
Store state of JournalingSecureRandom and AlgorithmIdentifier in temporary file- Parameters:
tempfile
-- Throws:
IOException
-
storeState
- Throws:
IOException
-
getState
public static JournaledAlgorithm getState(InputStream stateIn, SecureRandom random) throws IOException, ClassNotFoundException - Throws:
IOException
ClassNotFoundException
-
getState
public static JournaledAlgorithm getState(File tempfile, SecureRandom random) throws IOException, ClassNotFoundException Reconstructs JournaledAlgorithm session from file containing it's raw encoding.- Parameters:
tempfile
- temporary file containing serialized state- Returns:
- Throws:
IOException
ClassNotFoundException
-
getEncoded
Description copied from interface:Encodable
Return a byte array representing the implementing object.- Specified by:
getEncoded
in interfaceEncodable
- Returns:
- a byte array representing the encoding.
- Throws:
IOException
- if an issue arises generation the encoding.
-