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

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

Issue 2205403002: Add production Cast CRL certificate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses comments Created 4 years, 4 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 | components/cast_certificate/cast_cert_validator.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 #ifndef COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_ 5 #ifndef COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_
6 #define COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_ 6 #define COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 16
17 namespace net {
18 class TrustStore;
19 }
17 namespace cast_certificate { 20 namespace cast_certificate {
18 21
19 class CastCRL; 22 class CastCRL;
20 23
21 // Describes the policy for a Device certificate. 24 // Describes the policy for a Device certificate.
22 enum class CastDeviceCertPolicy { 25 enum class CastDeviceCertPolicy {
23 // The device certificate is unrestricted. 26 // The device certificate is unrestricted.
24 NONE, 27 NONE,
25 28
26 // The device certificate is for an audio-only device. 29 // The device certificate is for an audio-only device.
(...skipping 25 matching lines...) Expand all
52 55
53 // Retrieve the Common Name attribute of the subject's distinguished name from 56 // Retrieve the Common Name attribute of the subject's distinguished name from
54 // the verified certificate, if present. Returns an empty string if no Common 57 // the verified certificate, if present. Returns an empty string if no Common
55 // Name is found. 58 // Name is found.
56 virtual std::string GetCommonName() const = 0; 59 virtual std::string GetCommonName() const = 0;
57 60
58 private: 61 private:
59 DISALLOW_COPY_AND_ASSIGN(CertVerificationContext); 62 DISALLOW_COPY_AND_ASSIGN(CertVerificationContext);
60 }; 63 };
61 64
62 // Verifies a cast device certficate given a chain of DER-encoded certificates. 65 // Verifies a cast device certficate given a chain of DER-encoded certificates,
66 // using the built-in Cast trust anchors.
63 // 67 //
64 // Inputs: 68 // Inputs:
65 // 69 //
66 // * |certs| is a chain of DER-encoded certificates: 70 // * |certs| is a chain of DER-encoded certificates:
67 // * |certs[0]| is the target certificate (i.e. the device certificate). 71 // * |certs[0]| is the target certificate (i.e. the device certificate).
68 // * |certs[1..n-1]| are intermediates certificates to use in path building. 72 // * |certs[1..n-1]| are intermediates certificates to use in path building.
69 // Their ordering does not matter. 73 // Their ordering does not matter.
70 // 74 //
71 // * |time| is the unix timestamp to use for determining if the certificate 75 // * |time| is the unix timestamp to use for determining if the certificate
72 // is expired. 76 // is expired.
(...skipping 15 matching lines...) Expand all
88 // properties from the device certificate (Common Name). 92 // properties from the device certificate (Common Name).
89 // * |policy| is filled with an indication of the device certificate's policy 93 // * |policy| is filled with an indication of the device certificate's policy
90 // (i.e. is it for audio-only devices or is it unrestricted?) 94 // (i.e. is it for audio-only devices or is it unrestricted?)
91 bool VerifyDeviceCert(const std::vector<std::string>& certs, 95 bool VerifyDeviceCert(const std::vector<std::string>& certs,
92 const base::Time& time, 96 const base::Time& time,
93 std::unique_ptr<CertVerificationContext>* context, 97 std::unique_ptr<CertVerificationContext>* context,
94 CastDeviceCertPolicy* policy, 98 CastDeviceCertPolicy* policy,
95 const CastCRL* crl, 99 const CastCRL* crl,
96 CRLPolicy crl_policy) WARN_UNUSED_RESULT; 100 CRLPolicy crl_policy) WARN_UNUSED_RESULT;
97 101
102 // Exposed only for testing, not for use in production code.
103 //
104 // This is an overloaded version of VerifyDeviceCert that allows
105 // the input of a custom TrustStore.
106 bool VerifyDeviceCertForTest(const std::vector<std::string>& certs,
107 const base::Time& time,
108 std::unique_ptr<CertVerificationContext>* context,
109 CastDeviceCertPolicy* policy,
110 const CastCRL* crl,
111 CRLPolicy crl_policy,
112 net::TrustStore* trust_store) WARN_UNUSED_RESULT;
113
98 // Exposed only for unit-tests, not for use in production code. 114 // Exposed only for unit-tests, not for use in production code.
99 // Production code would get a context from VerifyDeviceCert(). 115 // Production code would get a context from VerifyDeviceCert().
100 // 116 //
101 // Constructs a VerificationContext that uses the provided public key. 117 // Constructs a VerificationContext that uses the provided public key.
102 // The common name will be hardcoded to some test value. 118 // The common name will be hardcoded to some test value.
103 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( 119 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest(
104 const base::StringPiece& spki); 120 const base::StringPiece& spki);
105 121
106 // Exposed only for testing, not for use in production code.
107 //
108 // Replaces trusted root certificates in the CastTrustStore.
109 // Returns true if successful, false if nothing is changed.
110 bool SetTrustAnchorForTest(const std::string& cert) WARN_UNUSED_RESULT;
111
112 } // namespace cast_certificate 122 } // namespace cast_certificate
113 123
114 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_ 124 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_
OLDNEW
« no previous file with comments | « no previous file | components/cast_certificate/cast_cert_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698