OLD | NEW |
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> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // * |certs[0]| is the target certificate (i.e. the device certificate). | 71 // * |certs[0]| is the target certificate (i.e. the device certificate). |
72 // * |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. |
73 // Their ordering does not matter. | 73 // Their ordering does not matter. |
74 // | 74 // |
75 // * |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 |
76 // is expired. | 76 // is expired. |
77 // | 77 // |
78 // * |crl| is the CRL to check for certificate revocation status. | 78 // * |crl| is the CRL to check for certificate revocation status. |
79 // If this is a nullptr, then revocation checking is currently disabled. | 79 // If this is a nullptr, then revocation checking is currently disabled. |
80 // | 80 // |
81 // * |crl_options| is for choosing how to handle the absence of a CRL. | 81 // * |crl_policy| is for choosing how to handle the absence of a CRL. |
82 // If crl_required is set to true, then an empty |crl| input would result | 82 // If CRL_REQUIRED is passed, then an empty |crl| input would result |
83 // in a failed verification. Otherwise, |crl| is ignored if it is absent. | 83 // in a failed verification. Otherwise, |crl| is ignored if it is absent. |
84 // | 84 // |
85 // Outputs: | 85 // Outputs: |
86 // | 86 // |
87 // Returns true on success, false on failure. On success the output | 87 // Returns true on success, false on failure. On success the output |
88 // parameters are filled with more details: | 88 // parameters are filled with more details: |
89 // | 89 // |
90 // * |context| is filled with an object that can be used to verify signatures | 90 // * |context| is filled with an object that can be used to verify signatures |
91 // using the device certificate's public key, as well as to extract other | 91 // using the device certificate's public key, as well as to extract other |
92 // properties from the device certificate (Common Name). | 92 // properties from the device certificate (Common Name). |
93 // * |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 |
94 // (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?) |
95 bool VerifyDeviceCert(const std::vector<std::string>& certs, | 95 bool VerifyDeviceCert(const std::vector<std::string>& certs, |
96 const base::Time& time, | 96 const base::Time& time, |
97 std::unique_ptr<CertVerificationContext>* context, | 97 std::unique_ptr<CertVerificationContext>* context, |
98 CastDeviceCertPolicy* policy, | 98 CastDeviceCertPolicy* policy, |
99 const CastCRL* crl, | 99 const CastCRL* crl, |
100 CRLPolicy crl_policy) WARN_UNUSED_RESULT; | 100 CRLPolicy crl_policy) WARN_UNUSED_RESULT; |
101 | 101 |
102 // Exposed only for testing, not for use in production code. | |
103 // | |
104 // This is an overloaded version of VerifyDeviceCert that allows | 102 // This is an overloaded version of VerifyDeviceCert that allows |
105 // the input of a custom TrustStore. | 103 // the input of a custom TrustStore. |
106 bool VerifyDeviceCertForTest(const std::vector<std::string>& certs, | 104 // |
107 const base::Time& time, | 105 // For production use pass |trust_store| as nullptr to use the production trust |
108 std::unique_ptr<CertVerificationContext>* context, | 106 // store. |
109 CastDeviceCertPolicy* policy, | 107 bool VerifyDeviceCertUsingCustomTrustStore( |
110 const CastCRL* crl, | 108 const std::vector<std::string>& certs, |
111 CRLPolicy crl_policy, | 109 const base::Time& time, |
112 net::TrustStore* trust_store) WARN_UNUSED_RESULT; | 110 std::unique_ptr<CertVerificationContext>* context, |
| 111 CastDeviceCertPolicy* policy, |
| 112 const CastCRL* crl, |
| 113 CRLPolicy crl_policy, |
| 114 net::TrustStore* trust_store) WARN_UNUSED_RESULT; |
113 | 115 |
114 // Exposed only for unit-tests, not for use in production code. | 116 // Exposed only for unit-tests, not for use in production code. |
115 // Production code would get a context from VerifyDeviceCert(). | 117 // Production code would get a context from VerifyDeviceCert(). |
116 // | 118 // |
117 // Constructs a VerificationContext that uses the provided public key. | 119 // Constructs a VerificationContext that uses the provided public key. |
118 // The common name will be hardcoded to some test value. | 120 // The common name will be hardcoded to some test value. |
119 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( | 121 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( |
120 const base::StringPiece& spki); | 122 const base::StringPiece& spki); |
121 | 123 |
122 } // namespace cast_certificate | 124 } // namespace cast_certificate |
123 | 125 |
124 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_ | 126 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_ |
OLD | NEW |