OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "crypto/ec_private_key.h" | 6 #include "crypto/ec_private_key.h" |
7 #include "crypto/openssl_util.h" | 7 #include "crypto/openssl_util.h" |
8 #include "crypto/scoped_openssl_types.h" | 8 #include "crypto/scoped_openssl_types.h" |
9 #include "net/cert/x509_util.h" | 9 #include "net/cert/x509_util.h" |
10 #include "net/cert/x509_util_openssl.h" | 10 #include "net/cert/x509_util_openssl.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 EXPECT_EQ(1, X509_verify(cert.get(), pub_key.get())); | 39 EXPECT_EQ(1, X509_verify(cert.get(), pub_key.get())); |
40 } | 40 } |
41 | 41 |
42 // Verify the attributes of a domain-bound certificate. | 42 // Verify the attributes of a domain-bound certificate. |
43 // |domain| is the bound domain name. | 43 // |domain| is the bound domain name. |
44 // |der_cert| is the DER-encoded X.509 certificate. | 44 // |der_cert| is the DER-encoded X.509 certificate. |
45 void VerifyChannelID(const std::string& domain, | 45 void VerifyChannelID(const std::string& domain, |
46 const std::string& der_cert) { | 46 const std::string& der_cert) { |
47 // Origin Bound Cert OID. | 47 // Origin Bound Cert OID. |
48 static const char oid_string[] = "1.3.6.1.4.1.11129.2.1.6"; | 48 static const char oid_string[] = "1.3.6.1.4.1.11129.2.1.6"; |
49 crypto::ScopedOpenSSL<ASN1_OBJECT, ASN1_OBJECT_free>::Type oid_obj( | 49 crypto::ScopedOpenSSL<ASN1_OBJECT, ASN1_OBJECT_free> oid_obj( |
50 OBJ_txt2obj(oid_string, 0)); | 50 OBJ_txt2obj(oid_string, 0)); |
51 ASSERT_TRUE(oid_obj.get()); | 51 ASSERT_TRUE(oid_obj.get()); |
52 | 52 |
53 const unsigned char* cert_data = | 53 const unsigned char* cert_data = |
54 reinterpret_cast<const unsigned char*>(der_cert.data()); | 54 reinterpret_cast<const unsigned char*>(der_cert.data()); |
55 int cert_data_len = static_cast<int>(der_cert.size()); | 55 int cert_data_len = static_cast<int>(der_cert.size()); |
56 ScopedX509 cert(d2i_X509(NULL, &cert_data, cert_data_len)); | 56 ScopedX509 cert(d2i_X509(NULL, &cert_data, cert_data_len)); |
57 ASSERT_TRUE(cert.get()); | 57 ASSERT_TRUE(cert.get()); |
58 | 58 |
59 // Find the extension. | 59 // Find the extension. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 VerifyChannelID(domain, der_cert); | 131 VerifyChannelID(domain, der_cert); |
132 | 132 |
133 // signature_verifier_win and signature_verifier_mac can't handle EC certs. | 133 // signature_verifier_win and signature_verifier_mac can't handle EC certs. |
134 std::vector<uint8> spki; | 134 std::vector<uint8> spki; |
135 ASSERT_TRUE(private_key->ExportPublicKey(&spki)); | 135 ASSERT_TRUE(private_key->ExportPublicKey(&spki)); |
136 VerifyCertificateSignature(der_cert, spki); | 136 VerifyCertificateSignature(der_cert, spki); |
137 } | 137 } |
138 | 138 |
139 } // namespace net | 139 } // namespace net |
OLD | NEW |