Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Side by Side Diff: net/cert/x509_util_nss_unittest.cc

Issue 356713005: Rename ServerBoundCert => ChannelID to reflect the current name (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 ASSERT_TRUE(ok); 70 ASSERT_TRUE(ok);
71 verifier.VerifyUpdate(sd.data.data, 71 verifier.VerifyUpdate(sd.data.data,
72 sd.data.len); 72 sd.data.len);
73 73
74 ok = verifier.VerifyFinal(); 74 ok = verifier.VerifyFinal();
75 EXPECT_TRUE(ok); 75 EXPECT_TRUE(ok);
76 } 76 }
77 #endif // !defined(OS_WIN) && !defined(OS_MACOSX) 77 #endif // !defined(OS_WIN) && !defined(OS_MACOSX)
78 78
79 void VerifyDomainBoundCert(const std::string& domain, 79 void VerifyChannelID(const std::string& domain,
80 const std::string& der_cert) { 80 const std::string& der_cert) {
wtc 2014/07/01 19:50:52 Fix the indentation.
Ryan Hamilton 2014/07/21 19:12:08 Done.
81 // Origin Bound Cert OID. 81 // Origin Bound Cert OID.
82 static const char oid_string[] = "1.3.6.1.4.1.11129.2.1.6"; 82 static const char oid_string[] = "1.3.6.1.4.1.11129.2.1.6";
83 83
84 // Create object neccessary for extension lookup call. 84 // Create object neccessary for extension lookup call.
85 SECItem extension_object = { 85 SECItem extension_object = {
86 siAsciiString, 86 siAsciiString,
87 (unsigned char*)domain.data(), 87 (unsigned char*)domain.data(),
88 static_cast<unsigned int>(domain.size()) 88 static_cast<unsigned int>(domain.size())
89 }; 89 };
90 90
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 and 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, CreateKeyAndDomainBoundCertEC) { 146 TEST(X509UtilNSSTest, CreateKeyAndChannelIDEC) {
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 scoped_ptr<crypto::ECPrivateKey> private_key;
152 std::string der_cert; 152 std::string der_cert;
153 ASSERT_TRUE(x509_util::CreateKeyAndDomainBoundCertEC( 153 ASSERT_TRUE(x509_util::CreateKeyAndChannelIDEC(
154 domain, 1, 154 domain, 1,
155 now, 155 now,
156 now + base::TimeDelta::FromDays(1), 156 now + base::TimeDelta::FromDays(1),
157 &private_key, 157 &private_key,
158 &der_cert)); 158 &der_cert));
159 159
160 VerifyDomainBoundCert(domain, der_cert); 160 VerifyChannelID(domain, der_cert);
161 161
162 #if !defined(OS_WIN) && !defined(OS_MACOSX) 162 #if !defined(OS_WIN) && !defined(OS_MACOSX)
163 // signature_verifier_win and signature_verifier_mac can't handle EC certs. 163 // signature_verifier_win and signature_verifier_mac can't handle EC certs.
164 std::vector<uint8> spki; 164 std::vector<uint8> spki;
165 ASSERT_TRUE(private_key->ExportPublicKey(&spki)); 165 ASSERT_TRUE(private_key->ExportPublicKey(&spki));
166 VerifyCertificateSignature(der_cert, spki); 166 VerifyCertificateSignature(der_cert, spki);
167 #endif 167 #endif
168 } 168 }
169 169
170 } // namespace net 170 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698