Package org.bouncycastle.cert.plants.bc
Class BcSha256MerkleTreeHash
- java.lang.Object
-
- org.bouncycastle.cert.plants.bc.BcSha256MerkleTreeHash
-
- All Implemented Interfaces:
MerkleTreeHash
public class BcSha256MerkleTreeHash extends java.lang.Object implements MerkleTreeHash
Lightweight SHA-256 implementation ofMerkleTreeHash.A fresh digest is created per call, so a single instance is thread-safe and can be shared (e.g. inside an
MTCCertAuthor aMerkleTreeCertificateValidator.ValidationParamsused by concurrent validations).
-
-
Constructor Summary
Constructors Constructor Description BcSha256MerkleTreeHash()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.bouncycastle.asn1.x509.AlgorithmIdentifiergetAlgorithmIdentifier()intgetHashSize()byte[]hashLeaf(byte[] entry)Hash of a leaf entry: HASH(0x00 || entry).byte[]hashNode(byte[] left, byte[] right)Hash of an internal node: HASH(0x01 || left || right).byte[]hashRaw(byte[] data)Raw hash with no domain separation prefix: HASH(data).
-
-
-
Method Detail
-
getAlgorithmIdentifier
public org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifier()
- Specified by:
getAlgorithmIdentifierin interfaceMerkleTreeHash- Returns:
- the X.509
AlgorithmIdentifierthat names this hash function. Used byMerkleTreeCertificateValidatorto cross-check the supplied hash against thelogHashfield of the CA'sid-pe-mtcCertificationAuthorityextension.
-
getHashSize
public int getHashSize()
- Specified by:
getHashSizein interfaceMerkleTreeHash- Returns:
- the hash output size in bytes
-
hashLeaf
public byte[] hashLeaf(byte[] entry)
Description copied from interface:MerkleTreeHashHash of a leaf entry: HASH(0x00 || entry).- Specified by:
hashLeafin interfaceMerkleTreeHash- Parameters:
entry- the raw entry bytes- Returns:
- leaf hash
-
hashNode
public byte[] hashNode(byte[] left, byte[] right)Description copied from interface:MerkleTreeHashHash of an internal node: HASH(0x01 || left || right).- Specified by:
hashNodein interfaceMerkleTreeHash- Parameters:
left- left child hashright- right child hash- Returns:
- node hash
-
hashRaw
public byte[] hashRaw(byte[] data)
Description copied from interface:MerkleTreeHashRaw 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:
hashRawin interfaceMerkleTreeHash- Parameters:
data- the input bytes- Returns:
- the hash output
-
-