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. 4 5#ifndef NET_CERT_CT_TEST_UTIL_H_ 6#define NET_CERT_CT_TEST_UTIL_H_ 7 8#include <string> 9 10#include "base/memory/ref_counted.h" 11 12namespace net { 13 14namespace ct { 15 16struct LogEntry; 17struct SignedCertificateTimestamp; 18struct SignedTreeHead; 19 20// Note: unless specified otherwise, all test data is taken from Certificate 21// Transparency test data repository. 22 23// Fills |entry| with test data for an X.509 entry. 24void GetX509CertLogEntry(LogEntry* entry); 25 26// Returns a DER-encoded X509 cert. The SCT provided by 27// GetX509CertSCT is signed over this certificate. 28std::string GetDerEncodedX509Cert(); 29 30// Fills |entry| with test data for a Precertificate entry. 31void GetPrecertLogEntry(LogEntry* entry); 32 33// Returns the binary representation of a test DigitallySigned 34std::string GetTestDigitallySigned(); 35 36// Returns the binary representation of a test serialized SCT. 37std::string GetTestSignedCertificateTimestamp(); 38 39// Test log key 40std::string GetTestPublicKey(); 41 42// ID of test log key 43std::string GetTestPublicKeyId(); 44 45// SCT for the X509Certificate provided above. 46void GetX509CertSCT(scoped_refptr<SignedCertificateTimestamp>* sct); 47 48// SCT for the Precertificate log entry provided above. 49void GetPrecertSCT(scoped_refptr<SignedCertificateTimestamp>* sct); 50 51// Issuer key hash 52std::string GetDefaultIssuerKeyHash(); 53 54// Fake OCSP response with an embedded SCT list. 55std::string GetDerEncodedFakeOCSPResponse(); 56 57// The SCT list embedded in the response above. 58std::string GetFakeOCSPExtensionValue(); 59 60// The cert the OCSP response is for. 61std::string GetDerEncodedFakeOCSPResponseCert(); 62 63// The issuer of the previous cert. 64std::string GetDerEncodedFakeOCSPResponseIssuerCert(); 65 66// A sample, valid STH 67void GetSignedTreeHead(SignedTreeHead* sth); 68 69// The SHA256 root hash for the sample STH 70std::string GetSampleSTHSHA256RootHash(); 71 72} // namespace ct 73 74} // namespace net 75 76#endif // NET_CERT_CT_TEST_UTIL_H_ 77