Package org.bouncycastle.cert.plants
Class MTCProof
- java.lang.Object
-
- org.bouncycastle.cert.plants.MTCProof
-
public class MTCProof extends java.lang.ObjectThe MTCProof structure encoded in the X.509 certificate signatureValue per draft-ietf-plants-merkle-tree-certs, Section 6.1.opaque HashValue[HASH_SIZE]; struct { TrustAnchorID cosigner_id; opaque signature<0..2^16-1>; } MTCSignature; struct { MerkleTreeCertEntryExtension extensions<0..2^16-1>; uint48 start; uint48 end; HashValue inclusion_proof<0..2^16-1>; MTCSignature signatures<0..2^16-1>; } MTCProof;extensionscarries the log entry's extension list, ordered byextension_typeascending with no duplicates.startandendare 6-byte unsigned big-endian integers (the draft shrank these fromuint64). Entries ofsignaturesMUST have uniquecosigner_ids and MUST be ordered first by length (shorter byte strings before longer) and then lexicographically.
-
-
Field Summary
Fields Modifier and Type Field Description static longUINT48_MAXMaximum value of a uint48 (2^48 - 1).
-
Constructor Summary
Constructors Constructor Description MTCProof(byte[] data)Parses an MTCProof from its TLS wire encoding (the contents of the certificate'ssignatureValueBIT STRING, byte-aligned, with no unused-bits prefix).MTCProof(long start, long end, byte[] inclusionProof, java.util.List<MTCSignature> signatures)Constructs an MTCProof with an empty extensions list.MTCProof(long start, long end, byte[] inclusionProof, MTCSignature... signatures)Varargs convenience for the common case of constructing an MTCProof from a small fixed set of cosigner signatures (typically just one).MTCProof(java.util.List<MerkleTreeCertEntryExtension> extensions, long start, long end, byte[] inclusionProof, java.util.List<MTCSignature> signatures)Constructs an MTCProof, validating uint48 range, ordering of the extensions list (ascending by extension_type, no duplicates) and canonical ordering of the signatures list.MTCProof(MTCLog log, byte[] inclusionProof, MTCSignature... signatures)Convenience overload taking anMTCLog— equivalent toMTCProof(long, long, byte[], MTCSignature...)withstart = log.getStart()andend = log.getEnd().
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcompareCosignerIds(byte[] a, byte[] b)The canonical comparator on cosigner_id byte strings, per Section 6.1: shorter byte strings come first, ties are broken lexicographically (unsigned).byte[]encode()longgetEnd()java.util.List<MerkleTreeCertEntryExtension>getExtensions()byte[]getExtensionsWire()java.util.List<byte[]>getHashList(int hashSize)Splits the concatenatedinclusion proofinto individual hash values of the given size.byte[]getInclusionProof()java.util.List<MTCSignature>getSignatures()longgetStart()
-
-
-
Field Detail
-
UINT48_MAX
public static final long UINT48_MAX
Maximum value of a uint48 (2^48 - 1).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MTCProof
public MTCProof(long start, long end, byte[] inclusionProof, java.util.List<MTCSignature> signatures)Constructs an MTCProof with an empty extensions list.- See Also:
MTCProof(List, long, long, byte[], List)
-
MTCProof
public MTCProof(long start, long end, byte[] inclusionProof, MTCSignature... signatures)Varargs convenience for the common case of constructing an MTCProof from a small fixed set of cosigner signatures (typically just one). Equivalent toMTCProof(long, long, byte[], List)with the signatures wrapped in a list; the same ordering rules in Section 6.1 apply.
-
MTCProof
public MTCProof(MTCLog log, byte[] inclusionProof, MTCSignature... signatures)
Convenience overload taking anMTCLog— equivalent toMTCProof(long, long, byte[], MTCSignature...)withstart = log.getStart()andend = log.getEnd().
-
MTCProof
public MTCProof(java.util.List<MerkleTreeCertEntryExtension> extensions, long start, long end, byte[] inclusionProof, java.util.List<MTCSignature> signatures)
Constructs an MTCProof, validating uint48 range, ordering of the extensions list (ascending by extension_type, no duplicates) and canonical ordering of the signatures list.- Throws:
java.lang.IllegalArgumentException- if start or end exceeds 2^48-1, if the extensions are unordered or duplicate, or if the signatures contain a duplicate cosigner_id or are not in canonical order
-
MTCProof
public MTCProof(byte[] data) throws java.io.IOExceptionParses an MTCProof from its TLS wire encoding (the contents of the certificate'ssignatureValueBIT STRING, byte-aligned, with no unused-bits prefix).- Throws:
java.io.IOException- if parsing fails or if the extensions / signatures lists violate the ordering rules in Section 6.1
-
-
Method Detail
-
encode
public byte[] encode() throws java.io.IOException- Returns:
- the TLS wire encoding of this MTCProof
- Throws:
java.io.IOException- if a length constraint is violated
-
getStart
public long getStart()
-
getEnd
public long getEnd()
-
getInclusionProof
public byte[] getInclusionProof()
-
getSignatures
public java.util.List<MTCSignature> getSignatures()
-
getExtensions
public java.util.List<MerkleTreeCertEntryExtension> getExtensions()
-
getExtensionsWire
public byte[] getExtensionsWire()
- Returns:
- the on-wire encoding of the
extensionsfield, including the 2-byte length prefix; equal to the leading bytes ofencode(). Section 7.2 step (5.2) requires these bytes to be written into the leaf-entry hash unchanged.
-
getHashList
public java.util.List<byte[]> getHashList(int hashSize)
Splits the concatenatedinclusion proofinto individual hash values of the given size.
-
compareCosignerIds
public static int compareCosignerIds(byte[] a, byte[] b)The canonical comparator on cosigner_id byte strings, per Section 6.1: shorter byte strings come first, ties are broken lexicographically (unsigned).
-
-