Class MTCContentSigner
- java.lang.Object
-
- org.bouncycastle.cert.plants.MTCContentSigner
-
- All Implemented Interfaces:
ContentSigner
public class MTCContentSigner extends java.lang.Object implements ContentSigner
Issuer-sideContentSignerthat emits an MTCsignatureValue(an encodedMTCProof) for an EE Merkle Tree certificate per Section 6.2 of draft-ietf-plants-merkle-tree-certs.The signer is plugged into the standard
X509v3CertificateBuilder.build(ContentSigner)flow. As the TBSCertificate DER bytes stream out of the builder intogetOutputStream(), this class captures them; whengetSignature()is invoked it:- Takes the entry's index from the serial number the builder wrote
(
serial = (log_number << 48) | index, Section 6.2), checking the log number is that of the suppliedMTCLog. - Derives the
MerkleTreeCertEntryleaf hash viaMerkleTreeCertificateValidator.computeEntryHash(byte[], MerkleTreeHash)and evaluates the supplied inclusion proof for that index within the log's subtree[start, end)(Section 4.3.2) to obtain the subtree hash. - Delegates to
MTCCosigner.cosignSubtree(org.bouncycastle.cert.plants.MTCLog, byte[])to produce the cosigner'sMTCSignature. - Wraps the inclusion proof and the cosigner signature in an
MTCProofand returns its TLS wire encoding.
This is the single-cosigner binding used by the worked examples: a standalone certificate (Section 6.3 of the draft) carrying one cosigner signature and no log-entry extensions. Issuers with multiple cosigners or extensions should compose the
MTCCosigner,MTCProofandMerkleTreeHashprimitives directly; landmark-relative certificates (Section 6.4, no signatures) are built viaLandmarkCertificateManager.buildLandmarkCertificate(long, long, org.bouncycastle.asn1.x509.TBSCertificateLogEntry, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo, org.bouncycastle.cert.plants.MerkleTreePrimitives.SubtreeInfo, java.util.List<byte[]>, org.bouncycastle.cert.plants.MerkleTreeHash).
-
-
Constructor Summary
Constructors Constructor Description MTCContentSigner(MTCLog log, byte[] inclusionProof, MTCCosigner cosigner)The cosigner's identity is taken fromMTCCosigner.getCosignerId()— the CA-as-cosigner case is just aMTCCosignerconstructed withlog.getCa().getCaId()as its cosigner ID (Section 5.3 of the draft).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.bouncycastle.asn1.x509.AlgorithmIdentifiergetAlgorithmIdentifier()Return the algorithm identifier describing the signature algorithm and parameters this signer generates.java.io.OutputStreamgetOutputStream()Returns a stream that will accept data for the purpose of calculating a signature.byte[]getSignature()Returns a signature based on the current data written to the stream, since the start or the last call to getSignature().
-
-
-
Constructor Detail
-
MTCContentSigner
public MTCContentSigner(MTCLog log, byte[] inclusionProof, MTCCosigner cosigner)
The cosigner's identity is taken fromMTCCosigner.getCosignerId()— the CA-as-cosigner case is just aMTCCosignerconstructed withlog.getCa().getCaId()as its cosigner ID (Section 5.3 of the draft). Witnesses, regulators, federated peers or any other entity with a distinct trust anchor ID work via the same constructor by constructing the cosigner with their own ID.- Parameters:
log- issuance log + subtree window[log.getStart(), log.getEnd())— also supplies the CA (viaMTCLog.getCa()) and therefore the hash function and log IDinclusionProof- the subtree inclusion proof (Section 4.3) for the EE's entry, as the concatenated sibling hashes from the leaf up to the subtree root — the same bytes that land in the resulting MTCProof (a single sibling hash for a two-entry subtree)cosigner- cosigner driver bound to its trust anchor ID, signature algorithm and key
-
-
Method Detail
-
getAlgorithmIdentifier
public org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifier()
Description copied from interface:ContentSignerReturn the algorithm identifier describing the signature algorithm and parameters this signer generates.- Specified by:
getAlgorithmIdentifierin interfaceContentSigner- Returns:
- algorithm oid and parameters.
-
getOutputStream
public java.io.OutputStream getOutputStream()
Description copied from interface:ContentSignerReturns a stream that will accept data for the purpose of calculating a signature. Use org.bouncycastle.util.io.TeeOutputStream if you want to accumulate the data on the fly as well.- Specified by:
getOutputStreamin interfaceContentSigner- Returns:
- an OutputStream
-
getSignature
public byte[] getSignature()
Description copied from interface:ContentSignerReturns a signature based on the current data written to the stream, since the start or the last call to getSignature().- Specified by:
getSignaturein interfaceContentSigner- Returns:
- bytes representing the signature.
-
-