1 // Copyright 2013 The Chromium Authors 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_OBJECTS_EXTRACTOR_H_ 6 #define NET_CERT_CT_OBJECTS_EXTRACTOR_H_ 7 8 #include <string> 9 #include <string_view> 10 11 #include "net/base/net_export.h" 12 #include "net/cert/x509_certificate.h" 13 14 namespace net::ct { 15 16 // The wire form of the OID 1.3.6.1.4.1.11129.2.4.2. See Section 3.3 of 17 // RFC6962. 18 inline constexpr uint8_t kEmbeddedSCTOid[] = {0x2B, 0x06, 0x01, 0x04, 0x01, 19 0xD6, 0x79, 0x02, 0x04, 0x02}; 20 21 struct SignedEntryData; 22 23 // Extracts a SignedCertificateTimestampList that has been embedded within a 24 // leaf cert as an X.509v3 extension with the OID 1.3.6.1.4.1.11129.2.4.2. 25 // If the extension is present, returns true, updating |*sct_list| to contain 26 // the encoded list, minus the DER encoding necessary for the extension. 27 // |*sct_list| can then be further decoded with ct::DecodeSCTList 28 NET_EXPORT_PRIVATE bool ExtractEmbeddedSCTList(const CRYPTO_BUFFER* cert, 29 std::string* sct_list); 30 31 // Obtains a PrecertChain log entry for |leaf|, an X.509v3 certificate that 32 // contains an X.509v3 extension with the OID 1.3.6.1.4.1.11129.2.4.2. On 33 // success, fills |*result| with the data for a PrecertChain log entry and 34 // returns true. 35 // The filled |*result| should be verified using ct::CTLogVerifier::Verify 36 // Note: If |leaf| does not contain the required extension, it is treated as 37 // a failure. 38 NET_EXPORT_PRIVATE bool GetPrecertSignedEntry(const CRYPTO_BUFFER* leaf, 39 const CRYPTO_BUFFER* issuer, 40 SignedEntryData* result); 41 42 // Obtains an X509Chain log entry for |leaf|, an X.509v3 certificate that 43 // is not expected to contain an X.509v3 extension with the OID 44 // 1.3.6.1.4.1.11129.2.4.2 (meaning a certificate without an embedded SCT). 45 // On success, fills |result| with the data for an X509Chain log entry and 46 // returns true. 47 // The filled |*result| should be verified using ct::CTLogVerifier::Verify 48 NET_EXPORT_PRIVATE bool GetX509SignedEntry(const CRYPTO_BUFFER* leaf, 49 SignedEntryData* result); 50 51 // Extracts a SignedCertificateTimestampList that has been embedded within 52 // an OCSP response as an extension with the OID 1.3.6.1.4.1.11129.2.4.5. 53 // If the extension is present, and the response matches the issuer and 54 // serial number, returns true, updating |*sct_list| to contain 55 // the encoded list, minus the DER encoding necessary for the extension. 56 // |*sct_list| can then be further decoded with ct::DecodeSCTList. 57 NET_EXPORT_PRIVATE bool ExtractSCTListFromOCSPResponse( 58 const CRYPTO_BUFFER* issuer, 59 const std::string& cert_serial_number, 60 std::string_view ocsp_response, 61 std::string* sct_list); 62 63 } // namespace net::ct 64 65 #endif // NET_CERT_CT_OBJECTS_EXTRACTOR_H_ 66