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 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[]).
  • Constructor Details

    • ERSCachingData

      public ERSCachingData()
  • Method Details

    • 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.