public class SignedCertificateTimestamp
extends java.lang.Object
Similarly, a certificate authority MAY submit a Pre certificate to
more than one log, and all obtained SCTs can be directly embedded in
the final certificate, by encoding the SignedCertificateTimestampList
structure as an ASN.1 OCTET STRING and inserting the resulting data
in the TBSCertificate as an X.509v3 certificate extension (OID
1.3.6.1.4.1.11129.2.4.2). Upon receiving the certificate, clients
can reconstruct the original TBSCertificate to verify the SCT
signature.
The contents of the ASN.1 OCTET STRING embedded in an OCSP extension
or X509v3 certificate extension are as follows:
opaque SerializedSCT<1..2^16-1>;
struct {
SerializedSCT sct_list <1..2^16-1>;
} SignedCertificateTimestampList;
Here, "SerializedSCT" is an opaque byte string that contains the
serialized TLS structure. This encoding ensures that TLS clients can
decode each SCT individually (i.e., if there is a version upgrade,
out-of-date clients can still parse old SCTs while skipping over new
SCTs whose versions they don't understand).
The format of the SCT is as follows:
struct {
Version sct_version;
LogID id;
uint64 timestamp;
CtExtensions extensions;
digitally-signed struct {
Version sct_version;
SignatureType signature_type = certificate_timestamp;
uint64 timestamp;
LogEntryType entry_type;
select(entry_type) {
case x509_entry: ASN.1Cert;
case precert_entry: PreCert;
} signed_entry;
CtExtensions extensions;
};
} SignedCertificateTimestamp;
A digitally-signed element is encoded as a struct DigitallySigned and is
defined in RFC 5246 as the following:
struct {
SignatureAndHashAlgorithm algorithm;
opaque signature<0..2^16-1>;
} DigitallySigned;
The encoding of the HashAlgorithm and Signature Algorithm come from section 7.4.1.4.1
of RFC 5246:
7.4.1.4.1. Signature Algorithms
The client uses the "signature_algorithms" extension to indicate to
the server which signature/hash algorithm pairs may be used in
digital signatures. The "extension_data" field of this extension
contains a "supported_signature_algorithms" value.
enum {
none(0), md5(1), sha1(2), sha224(3), sha256(4), sha384(5),
sha512(6), (255)
} HashAlgorithm;
enum { anonymous(0), rsa(1), dsa(2), ecdsa(3), (255) }
SignatureAlgorithm;
struct {
HashAlgorithm hash;
SignatureAlgorithm signature;
} SignatureAndHashAlgorithm;
SignatureAndHashAlgorithm
supported_signature_algorithms<2..2^16-2>;
| Modifier and Type | Field and Description |
|---|---|
static int |
HASH_ALG_LENGTH
The Hash algorithm length is 1 byte
|
static int |
KEYID_LENGTH
Number of bytes for the KEYID.
|
int |
LOG_ENTRY_TYPE |
static int |
LOG_ENTRY_TYPE_LENGTH
The LogEntryType - The Log Entry type length is two bytes
enum { x509_entry(0), precert_entry(1), (65535) } LogEntryType;
|
static int |
LOG_ENTRY_TYPE_PRE_CERT |
static int |
LOG_ENTRY_TYPE_X509
The LogEntryType - Defined in 6269 as
enum { x509_entry(0), precert_entry(1), (65535) } LogEntryType;
|
static int |
MAX_CERTIFICATE_LENGTH
The Maximum Certificate length
|
static int |
MAX_EXTENSION_LENGTH
The Maximum extension length is 2^16-1
|
static int |
MAX_SIGNATURE_LENGTH
The Maximum signature length is 2^16-1
|
static int |
SIGNATURE_ALG_LENGTH
The Signature algorithm length is 1 byte
|
static int |
SIGNATURE_TYPE
The SignatureType - We always use a certificate timestamp
so this is a fixed value of 0
enum { certificate_timestamp(0), tree_hash(1), (255) }
SignatureType;
|
static int |
SIGNATURE_TYPE_LENGTH
The SignatureType - The length is always 1
Defined AS
enum { certificate_timestamp(0), tree_hash(1), (255) }
SignatureType;
|
static int |
TIMESTAMP_LENGTH
The length of the Timestamp is always 8 bytes
|
static int |
VERSION_LENGTH
Number of bytes for the VERSION
|
| Constructor and Description |
|---|
SignedCertificateTimestamp(byte[] inputSCT)
Parse an SCT by reading it from the given ByteArray
|
SignedCertificateTimestamp(java.io.InputStream inputSCT)
Create an SCT by parsing from the the given InputStream
|
SignedCertificateTimestamp(int Version,
byte[] keyID,
long timestamp,
byte[] extensions,
byte[] signature)
Create a Signed Certificate Timestamp from the supplied data values.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getEncoded()
Encode an SCT as a stream of bytes.
|
byte[] |
getExtension() |
AlgorithmID |
getHashAlgorithm() |
byte[] |
getLogID() |
AlgorithmID |
getSignatureAlgorith() |
byte[] |
getSignatureByte() |
long |
getTimestamp() |
int |
getVersion() |
java.lang.String |
toString()
Return the String readable version of the Signed Certificate Timestamp
|
boolean |
verify(X509Certificate cert,
java.security.PublicKey key)
Verify this Signed Certificate Timestamp.
|
boolean |
verify(X509Certificate preCertorFinal,
java.security.PublicKey logkey,
java.security.PublicKey issuerKey)
Verify this Signed Certificate Timestamp.
|
public static final int VERSION_LENGTH
public static final int LOG_ENTRY_TYPE_LENGTH
public static final int LOG_ENTRY_TYPE_X509
public static final int LOG_ENTRY_TYPE_PRE_CERT
public int LOG_ENTRY_TYPE
public static final int SIGNATURE_TYPE_LENGTH
public static final int SIGNATURE_TYPE
public static final int KEYID_LENGTH
public static final int TIMESTAMP_LENGTH
public static final int MAX_EXTENSION_LENGTH
public static final int MAX_SIGNATURE_LENGTH
public static final int MAX_CERTIFICATE_LENGTH
public static final int HASH_ALG_LENGTH
public static final int SIGNATURE_ALG_LENGTH
public SignedCertificateTimestamp(int Version,
byte[] keyID,
long timestamp,
byte[] extensions,
byte[] signature)
throws java.io.IOException
Version - The version of the protocol to which the SCT conforms, this version
is v1 which iskeyID - The KeyID which is the SHA-256 hash of the logs's public key, calculated over
the DER encoding of the key represented as SubjectPublicKeyInfotimestamp - The timestamp is the NTP time when the SCT was createdextensions - Future extensions to the protocolsignature - The signature over the digitally signed structure.java.io.IOException - if the components could not be parsedpublic SignedCertificateTimestamp(java.io.InputStream inputSCT)
throws java.io.IOException
inputSCT - The SCT on the InputStreamjava.io.IOExceptionpublic SignedCertificateTimestamp(byte[] inputSCT)
throws java.io.IOException
inputSCT - the input Signed Certificate Timestampjava.io.IOException - if there is an error parsing the SignedCertificate Timestamppublic int getVersion()
public byte[] getLogID()
public long getTimestamp()
public byte[] getExtension()
public AlgorithmID getSignatureAlgorith()
public AlgorithmID getHashAlgorithm()
public byte[] getSignatureByte()
public byte[] getEncoded()
throws java.io.IOException
java.io.IOExceptionpublic boolean verify(X509Certificate preCertorFinal, java.security.PublicKey logkey, java.security.PublicKey issuerKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.SignatureException, java.security.InvalidAlgorithmParameterException, java.security.InvalidKeyException, java.io.IOException, java.security.cert.CertificateException, X509ExtensionException
SignedCertificateTimestampList object would not be extracted from the Certificate, but
could be constructed by passing in the list of SignedCertificateTimestamp objects.
Note: A pre-Certificate issued by a pre-Certificate Signing certificate and containing EKU 1.3.6.1.4.1.11129.2.4.4 cannot be validated by this API.
preCertorFinal - The X509Certificate containing the TBSCertificate structure used to create
the Signed Certificate Timestamp.logkey - The Public Key of the Certificate Transparency Log used to validate the signature in
this SignedCertificateTimestampissuerKey - The Public Key of the certificate that issued the certificate that contains the SignedCertificateTimestamp.java.security.NoSuchProviderException - when it can't find the indicated providerjava.security.NoSuchAlgorithmException - when the specified algorithm implementation cannot be foundjava.security.SignatureException - to indicate a Signature Failurejava.security.InvalidAlgorithmParameterException - if a problem occurs when reading the algorithm parametersjava.security.InvalidKeyException - to indicate an issue when decoding the keysjava.io.IOException - to indicate an issue when reading/writing the certificatesjava.security.cert.CertificateException - to indicate a problem when parsing the certificateX509ExtensionException - to indicate a problem with X509 extensionspublic boolean verify(X509Certificate cert, java.security.PublicKey key) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.SignatureException, java.security.InvalidAlgorithmParameterException, java.security.cert.CertificateException, X509ExtensionException, java.io.IOException
SignedCertificateTimestamp object would not be extracted from the Certificate, but
could be constructed by passing in the SignedCertificateTimestamp itself.cert - The certificate used to calculate the Signed Certificate Timestamp (SCT) signature as mentioned above.logkeys - The list of Public Log keys, used to validate the SCT signature(s).java.security.NoSuchProviderException - when it can't find the indicated providerjava.security.NoSuchAlgorithmException - when the specified algorithm implementation cannot be foundjava.security.SignatureException - to indicate a Signature Failurejava.security.InvalidAlgorithmParameterException - if a problem occurs when reading the algorithm parametersjava.security.InvalidKeyException - to indicate an issue when decoding the keysjava.io.IOException - to indicate an issue when reading/writing the certificatesjava.security.cert.CertificateException - to indicate a problem when parsing the certificateX509ExtensionException - to indicate a problem with X509 extensionspublic java.lang.String toString()
toString in class java.lang.Object