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

Side by Side Diff: components/cast_certificate/cast_cert_validator.cc

Issue 2803513003: Remove ParsedCertificate::unparsed_extensions(). (Closed)
Patch Set: remove unused Created 3 years, 8 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
« no previous file with comments | « no previous file | net/cert/cert_verify_proc_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/cast_certificate/cast_cert_validator.h" 5 #include "components/cast_certificate/cast_cert_validator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Enforce pathlen constraints and policies defined on the root certificate. 76 // Enforce pathlen constraints and policies defined on the root certificate.
77 scoped_refptr<net::TrustAnchor> anchor = 77 scoped_refptr<net::TrustAnchor> anchor =
78 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); 78 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert));
79 store_.AddTrustAnchor(std::move(anchor)); 79 store_.AddTrustAnchor(std::move(anchor));
80 } 80 }
81 81
82 net::TrustStoreInMemory store_; 82 net::TrustStoreInMemory store_;
83 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); 83 DISALLOW_COPY_AND_ASSIGN(CastTrustStore);
84 }; 84 };
85 85
86 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>;
87
88 // Helper that looks up an extension by OID given a map of extensions.
89 bool GetExtensionValue(const ExtensionsMap& extensions,
90 const net::der::Input& oid,
91 net::der::Input* value) {
92 auto it = extensions.find(oid);
93 if (it == extensions.end())
94 return false;
95 *value = it->second.value;
96 return true;
97 }
98
99 // Returns the OID for the Audio-Only Cast policy 86 // Returns the OID for the Audio-Only Cast policy
100 // (1.3.6.1.4.1.11129.2.5.2) in DER form. 87 // (1.3.6.1.4.1.11129.2.5.2) in DER form.
101 net::der::Input AudioOnlyPolicyOid() { 88 net::der::Input AudioOnlyPolicyOid() {
102 static const uint8_t kAudioOnlyPolicy[] = {0x2B, 0x06, 0x01, 0x04, 0x01, 89 static const uint8_t kAudioOnlyPolicy[] = {0x2B, 0x06, 0x01, 0x04, 0x01,
103 0xD6, 0x79, 0x02, 0x05, 0x02}; 90 0xD6, 0x79, 0x02, 0x05, 0x02};
104 return net::der::Input(kAudioOnlyPolicy); 91 return net::der::Input(kAudioOnlyPolicy);
105 } 92 }
106 93
107 // Cast certificates rely on RSASSA-PKCS#1 v1.5 with SHA-1 for signatures. 94 // Cast certificates rely on RSASSA-PKCS#1 v1.5 with SHA-1 for signatures.
108 // 95 //
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 std::unique_ptr<CertVerificationContext>* context, 180 std::unique_ptr<CertVerificationContext>* context,
194 CastDeviceCertPolicy* policy) { 181 CastDeviceCertPolicy* policy) {
195 // Get the Key Usage extension. 182 // Get the Key Usage extension.
196 if (!cert->has_key_usage()) 183 if (!cert->has_key_usage())
197 return false; 184 return false;
198 185
199 // Ensure Key Usage contains digitalSignature. 186 // Ensure Key Usage contains digitalSignature.
200 if (!cert->key_usage().AssertsBit(net::KEY_USAGE_BIT_DIGITAL_SIGNATURE)) 187 if (!cert->key_usage().AssertsBit(net::KEY_USAGE_BIT_DIGITAL_SIGNATURE))
201 return false; 188 return false;
202 189
203 // Get the Extended Key Usage extension.
204 net::der::Input extension_value;
205 if (!GetExtensionValue(cert->unparsed_extensions(), net::ExtKeyUsageOid(),
206 &extension_value)) {
207 return false;
208 }
209 std::vector<net::der::Input> ekus;
210 if (!net::ParseEKUExtension(extension_value, &ekus))
211 return false;
212
213 // Ensure Extended Key Usage contains client auth. 190 // Ensure Extended Key Usage contains client auth.
214 if (!HasClientAuth(ekus)) 191 if (!cert->has_extended_key_usage() ||
192 !HasClientAuth(cert->extended_key_usage()))
215 return false; 193 return false;
216 194
217 // Check for an optional audio-only policy extension. 195 // Check for an optional audio-only policy extension.
218 *policy = CastDeviceCertPolicy::NONE; 196 *policy = CastDeviceCertPolicy::NONE;
219 if (GetExtensionValue(cert->unparsed_extensions(), 197 if (cert->has_policy_oids()) {
220 net::CertificatePoliciesOid(), &extension_value)) { 198 const std::vector<net::der::Input>& policies = cert->policy_oids();
221 std::vector<net::der::Input> policies;
222 if (!net::ParseCertificatePoliciesExtension(extension_value, &policies))
223 return false;
224
225 // Look for an audio-only policy. Disregard any other policy found. 199 // Look for an audio-only policy. Disregard any other policy found.
226 if (std::find(policies.begin(), policies.end(), AudioOnlyPolicyOid()) != 200 if (std::find(policies.begin(), policies.end(), AudioOnlyPolicyOid()) !=
227 policies.end()) { 201 policies.end()) {
228 *policy = CastDeviceCertPolicy::AUDIO_ONLY; 202 *policy = CastDeviceCertPolicy::AUDIO_ONLY;
229 } 203 }
230 } 204 }
231 205
232 // Get the Common Name for the certificate. 206 // Get the Common Name for the certificate.
233 std::string common_name; 207 std::string common_name;
234 if (!GetCommonNameFromSubject(cert->tbs().subject_tlv, &common_name)) 208 if (!GetCommonNameFromSubject(cert->tbs().subject_tlv, &common_name))
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 311
338 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( 312 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest(
339 const base::StringPiece& spki) { 313 const base::StringPiece& spki) {
340 // Use a bogus CommonName, since this is just exposed for testing signature 314 // Use a bogus CommonName, since this is just exposed for testing signature
341 // verification by unittests. 315 // verification by unittests.
342 return base::MakeUnique<CertVerificationContextImpl>(net::der::Input(spki), 316 return base::MakeUnique<CertVerificationContextImpl>(net::der::Input(spki),
343 "CommonName"); 317 "CommonName");
344 } 318 }
345 319
346 } // namespace cast_certificate 320 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « no previous file | net/cert/cert_verify_proc_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698