1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_CERT_CT_TEST_UTIL_H_
6 #define NET_CERT_CT_TEST_UTIL_H_
10 #include "base/memory/ref_counted.h"
16 struct DigitallySigned
;
18 struct SignedCertificateTimestamp
;
19 struct SignedTreeHead
;
21 // Note: unless specified otherwise, all test data is taken from Certificate
22 // Transparency test data repository.
24 // Fills |entry| with test data for an X.509 entry.
25 void GetX509CertLogEntry(LogEntry
* entry
);
27 // Returns a DER-encoded X509 cert. The SCT provided by
28 // GetX509CertSCT is signed over this certificate.
29 std::string
GetDerEncodedX509Cert();
31 // Fills |entry| with test data for a Precertificate entry.
32 void GetPrecertLogEntry(LogEntry
* entry
);
34 // Returns the binary representation of a test DigitallySigned
35 std::string
GetTestDigitallySigned();
37 // Returns the binary representation of a test serialized SCT.
38 std::string
GetTestSignedCertificateTimestamp();
41 std::string
GetTestPublicKey();
44 std::string
GetTestPublicKeyId();
46 // SCT for the X509Certificate provided above.
47 void GetX509CertSCT(scoped_refptr
<SignedCertificateTimestamp
>* sct
);
49 // SCT for the Precertificate log entry provided above.
50 void GetPrecertSCT(scoped_refptr
<SignedCertificateTimestamp
>* sct
);
53 std::string
GetDefaultIssuerKeyHash();
55 // Fake OCSP response with an embedded SCT list.
56 std::string
GetDerEncodedFakeOCSPResponse();
58 // The SCT list embedded in the response above.
59 std::string
GetFakeOCSPExtensionValue();
61 // The cert the OCSP response is for.
62 std::string
GetDerEncodedFakeOCSPResponseCert();
64 // The issuer of the previous cert.
65 std::string
GetDerEncodedFakeOCSPResponseIssuerCert();
67 // A sample, valid STH.
68 void GetSampleSignedTreeHead(SignedTreeHead
* sth
);
70 // The SHA256 root hash for the sample STH.
71 std::string
GetSampleSTHSHA256RootHash();
73 // The tree head signature for the sample STH.
74 std::string
GetSampleSTHTreeHeadSignature();
76 // The same signature as GetSampleSTHTreeHeadSignature, decoded.
77 void GetSampleSTHTreeHeadDecodedSignature(DigitallySigned
* signature
);
79 // The sample STH in JSON form.
80 std::string
GetSampleSTHAsJson();
82 // Assembles, and returns, a sample STH in JSON format using
83 // the provided parameters.
84 std::string
CreateSignedTreeHeadJsonString(size_t tree_size
,
86 std::string sha256_root_hash
,
87 std::string tree_head_signature
);
93 #endif // NET_CERT_CT_TEST_UTIL_H_