| 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 "net/cert/x509_util.h" | 5 #include "net/cert/x509_util.h" |
| 6 #include "net/cert/x509_util_nss.h" | 6 #include "net/cert/x509_util_nss.h" |
| 7 | 7 |
| 8 #include <cert.h> | 8 #include <cert.h> |
| 9 #include <secoid.h> | 9 #include <secoid.h> |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 PRBool result = SECITEM_ItemsAreEqual(expected, &actual); | 134 PRBool result = SECITEM_ItemsAreEqual(expected, &actual); |
| 135 ASSERT_TRUE(result); | 135 ASSERT_TRUE(result); |
| 136 | 136 |
| 137 // Do Cleanup. | 137 // Do Cleanup. |
| 138 SECITEM_FreeItem(&actual, PR_FALSE); | 138 SECITEM_FreeItem(&actual, PR_FALSE); |
| 139 PORT_FreeArena(arena, PR_FALSE); | 139 PORT_FreeArena(arena, PR_FALSE); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace | 142 } // namespace |
| 143 | 143 |
| 144 // This test creates a domain-bound cert from an EC private key and | 144 // This test creates a domain-bound cert and an EC private key and |
| 145 // then verifies the content of the certificate. | 145 // then verifies the content of the certificate. |
| 146 TEST(X509UtilNSSTest, CreateDomainBoundCertEC) { | 146 TEST(X509UtilNSSTest, CreateKeyAndDomainBoundCertEC) { |
| 147 // Create a sample ASCII weborigin. | 147 // Create a sample ASCII weborigin. |
| 148 std::string domain = "weborigin.com"; | 148 std::string domain = "weborigin.com"; |
| 149 base::Time now = base::Time::Now(); | 149 base::Time now = base::Time::Now(); |
| 150 | 150 |
| 151 scoped_ptr<crypto::ECPrivateKey> private_key( | 151 crypto::ECPrivateKey* raw_key; |
| 152 crypto::ECPrivateKey::Create()); | |
| 153 std::string der_cert; | 152 std::string der_cert; |
| 154 ASSERT_TRUE(x509_util::CreateDomainBoundCertEC( | 153 ASSERT_TRUE(x509_util::CreateKeyAndDomainBoundCertEC( |
| 155 private_key.get(), | |
| 156 domain, 1, | 154 domain, 1, |
| 157 now, | 155 now, |
| 158 now + base::TimeDelta::FromDays(1), | 156 now + base::TimeDelta::FromDays(1), |
| 157 &raw_key, |
| 159 &der_cert)); | 158 &der_cert)); |
| 160 | 159 |
| 160 scoped_ptr<crypto::ECPrivateKey> private_key(raw_key); |
| 161 |
| 161 VerifyDomainBoundCert(domain, der_cert); | 162 VerifyDomainBoundCert(domain, der_cert); |
| 162 | 163 |
| 163 #if !defined(OS_WIN) && !defined(OS_MACOSX) | 164 #if !defined(OS_WIN) && !defined(OS_MACOSX) |
| 164 // signature_verifier_win and signature_verifier_mac can't handle EC certs. | 165 // signature_verifier_win and signature_verifier_mac can't handle EC certs. |
| 165 std::vector<uint8> spki; | 166 std::vector<uint8> spki; |
| 166 ASSERT_TRUE(private_key->ExportPublicKey(&spki)); | 167 ASSERT_TRUE(private_key->ExportPublicKey(&spki)); |
| 167 VerifyCertificateSignature(der_cert, spki); | 168 VerifyCertificateSignature(der_cert, spki); |
| 168 #endif | 169 #endif |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace net | 172 } // namespace net |
| OLD | NEW |