Class BcSha256MerkleTreeHash

java.lang.Object
org.bouncycastle.cert.plants.bc.BcSha256MerkleTreeHash
All Implemented Interfaces:
MerkleTreeHash

public class BcSha256MerkleTreeHash extends Object implements MerkleTreeHash
Lightweight SHA-256 implementation of MerkleTreeHash.

A fresh digest is created per call, so a single instance is thread-safe and can be shared (e.g. inside an MTCCertAuth or a MerkleTreeCertificateValidator.ValidationParams used by concurrent validations).

  • Constructor Details

    • BcSha256MerkleTreeHash

      public BcSha256MerkleTreeHash()
  • Method Details

    • getAlgorithmIdentifier

      public org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifier()
      Specified by:
      getAlgorithmIdentifier in interface MerkleTreeHash
      Returns:
      the X.509 AlgorithmIdentifier that names this hash function. Used by MerkleTreeCertificateValidator to cross-check the supplied hash against the logHash field of the CA's id-pe-mtcCertificationAuthority extension.
    • getHashSize

      public int getHashSize()
      Specified by:
      getHashSize in interface MerkleTreeHash
      Returns:
      the hash output size in bytes
    • hashLeaf

      public byte[] hashLeaf(byte[] entry)
      Description copied from interface: MerkleTreeHash
      Hash of a leaf entry: HASH(0x00 || entry).
      Specified by:
      hashLeaf in interface MerkleTreeHash
      Parameters:
      entry - the raw entry bytes
      Returns:
      leaf hash
    • hashNode

      public byte[] hashNode(byte[] left, byte[] right)
      Description copied from interface: MerkleTreeHash
      Hash of an internal node: HASH(0x01 || left || right).
      Specified by:
      hashNode in interface MerkleTreeHash
      Parameters:
      left - left child hash
      right - right child hash
      Returns:
      node hash
    • hashRaw

      public byte[] hashRaw(byte[] data)
      Description copied from interface: MerkleTreeHash
      Raw hash with no domain separation prefix: HASH(data). Used for the subjectPublicKeyInfoHash in a TBSCertificateLogEntry (Section 5.3), which is computed with the log's hash function but without the leaf-node prefix.
      Specified by:
      hashRaw in interface MerkleTreeHash
      Parameters:
      data - the input bytes
      Returns:
      the hash output