org.bouncycastle.tsp.ers
Class ERSCachingData
java.lang.Object
org.bouncycastle.tsp.ers.ERSCachingData
- All Implemented Interfaces:
- ERSData
- Direct Known Subclasses:
- ERSByteData, ERSDataGroup, ERSFileData, ERSInputStreamData
- public abstract class ERSCachingData
- extends java.lang.Object
- implements ERSData
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[]).
|
Method Summary |
protected 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. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ERSCachingData
public ERSCachingData()
getHash
public 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.
- Specified by:
getHash in interface ERSData
- Parameters:
digestCalculator - the DigestCalculator to 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 by
getHash(DigestCalculator, byte[]).
- Parameters:
digestCalculator - the digest calculator to use.previousChainHash - hash from an earlier chain to fold in, or null.
- Returns:
- the calculated hash.