Class ERSCachingData
java.lang.Object
org.bouncycastle.tsp.ers.ERSCachingData
- All Implemented Interfaces:
ERSData
- Direct Known Subclasses:
ERSByteData, ERSDataGroup, ERSFileData, ERSInputStreamData
Base
ERSData implementation that caches calculated hashes, keyed by
digest algorithm and previous-chain hash, so the (potentially expensive) hash
of a data object is computed only once per combination. Subclasses supply the
actual hash in calculateHash(DigestCalculator, byte[]).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]calculateHash(DigestCalculator digestCalculator, byte[] previousChainHash) Compute the hash for this data object.byte[]getHash(DigestCalculator digestCalculator, byte[] previousChainHash) Return the hash for this data object, computing it (via the subclass) on first request and returning the cached value thereafter.
-
Constructor Details
-
ERSCachingData
public ERSCachingData()
-
-
Method Details
-
getHash
Return the hash for this data object, computing it (via the subclass) on first request and returning the cached value thereafter.- Specified by:
getHashin interfaceERSData- Parameters:
digestCalculator- theDigestCalculatorto use for computing the hash.previousChainHash- hash from an earlier chain to fold in, or null.- Returns:
- the calculated hash for this data object.
-
calculateHash
protected abstract byte[] calculateHash(DigestCalculator digestCalculator, byte[] previousChainHash) Compute the hash for this data object. Implemented by subclasses; the result is cached bygetHash(DigestCalculator, byte[]).- Parameters:
digestCalculator- the digest calculator to use.previousChainHash- hash from an earlier chain to fold in, or null.- Returns:
- the calculated hash.
-