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

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

Issue 2050983002: Cast device revocation checking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (Rebase only) Created 4 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
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 cast_certificate { 17 namespace cast_certificate {
18 18
19 class CastCRL;
20
19 // Describes the policy for a Device certificate. 21 // Describes the policy for a Device certificate.
20 enum class CastDeviceCertPolicy { 22 enum class CastDeviceCertPolicy {
21 // The device certificate is unrestricted. 23 // The device certificate is unrestricted.
22 NONE, 24 NONE,
23 25
24 // The device certificate is for an audio-only device. 26 // The device certificate is for an audio-only device.
25 AUDIO_ONLY, 27 AUDIO_ONLY,
26 }; 28 };
27 29
30 struct CRLOptions {
31 // If set to false, then revocation is only checked if a CRL is provided.
32 // If set to true, then revocation is always checked. An empty CRL results
33 // in failure.
34 bool crl_required = true;
eroman 2016/07/12 21:22:00 Do you plan on adding other properties to this? If
ryanchung 2016/07/14 16:15:25 Done. Don't have other properties in mind right no
35 };
36
28 // An object of this type is returned by the VerifyDeviceCert function, and can 37 // An object of this type is returned by the VerifyDeviceCert function, and can
29 // be used for additional certificate-related operations, using the verified 38 // be used for additional certificate-related operations, using the verified
30 // certificate. 39 // certificate.
31 class CertVerificationContext { 40 class CertVerificationContext {
32 public: 41 public:
33 CertVerificationContext() {} 42 CertVerificationContext() {}
34 virtual ~CertVerificationContext() {} 43 virtual ~CertVerificationContext() {}
35 44
36 // Use the public key from the verified certificate to verify a 45 // Use the public key from the verified certificate to verify a
37 // sha1WithRSAEncryption |signature| over arbitrary |data|. Both |signature| 46 // sha1WithRSAEncryption |signature| over arbitrary |data|. Both |signature|
(...skipping 16 matching lines...) Expand all
54 // Inputs: 63 // Inputs:
55 // 64 //
56 // * |certs| is a chain of DER-encoded certificates: 65 // * |certs| is a chain of DER-encoded certificates:
57 // * |certs[0]| is the target certificate (i.e. the device certificate). 66 // * |certs[0]| is the target certificate (i.e. the device certificate).
58 // * |certs[1..n-1]| are intermediates certificates to use in path building. 67 // * |certs[1..n-1]| are intermediates certificates to use in path building.
59 // Their ordering does not matter. 68 // Their ordering does not matter.
60 // 69 //
61 // * |time| is the UTC time to use for determining if the certificate 70 // * |time| is the UTC time to use for determining if the certificate
62 // is expired. 71 // is expired.
63 // 72 //
73 // * |crl| is the CRL to check for certificate revocation status.
74 // If this is a nullptr, then revocation checking is currently disabled.
75 //
eroman 2016/07/12 21:22:00 nit: remove extra space.
ryanchung 2016/07/14 16:15:25 Done.
76 //
77 // * |crl_options| is for choosing how to handle the absence of a CRL.
78 // If crl_required is set to true, then an empty |crl| input would result
79 // in a failed verification. Otherwise, |crl| is ignored if it is absent.
80 //
64 // Outputs: 81 // Outputs:
65 // 82 //
66 // Returns true on success, false on failure. On success the output 83 // Returns true on success, false on failure. On success the output
67 // parameters are filled with more details: 84 // parameters are filled with more details:
68 // 85 //
69 // * |context| is filled with an object that can be used to verify signatures 86 // * |context| is filled with an object that can be used to verify signatures
70 // using the device certificate's public key, as well as to extract other 87 // using the device certificate's public key, as well as to extract other
71 // properties from the device certificate (Common Name). 88 // properties from the device certificate (Common Name).
72 // * |policy| is filled with an indication of the device certificate's policy 89 // * |policy| is filled with an indication of the device certificate's policy
73 // (i.e. is it for audio-only devices or is it unrestricted?) 90 // (i.e. is it for audio-only devices or is it unrestricted?)
74 bool VerifyDeviceCert(const std::vector<std::string>& certs, 91 bool VerifyDeviceCert(const std::vector<std::string>& certs,
75 const base::Time::Exploded& time, 92 const base::Time::Exploded& time,
76 std::unique_ptr<CertVerificationContext>* context, 93 std::unique_ptr<CertVerificationContext>* context,
77 CastDeviceCertPolicy* policy) WARN_UNUSED_RESULT; 94 CastDeviceCertPolicy* policy,
95 const CastCRL* crl,
96 CRLOptions& crl_options) WARN_UNUSED_RESULT;
78 97
79 // Exposed only for unit-tests, not for use in production code. 98 // Exposed only for unit-tests, not for use in production code.
80 // Production code would get a context from VerifyDeviceCert(). 99 // Production code would get a context from VerifyDeviceCert().
81 // 100 //
82 // Constructs a VerificationContext that uses the provided public key. 101 // Constructs a VerificationContext that uses the provided public key.
83 // The common name will be hardcoded to some test value. 102 // The common name will be hardcoded to some test value.
84 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( 103 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest(
85 const base::StringPiece& spki); 104 const base::StringPiece& spki);
86 105
87 // Exposed only for testing, not for use in production code. 106 // Exposed only for testing, not for use in production code.
88 // 107 //
89 // Injects trusted root certificates into the CastTrustStore. 108 // Injects trusted root certificates into the CastTrustStore.
eroman 2016/07/12 21:22:00 Injects --> Replaces And can then remove the comme
ryanchung 2016/07/14 16:15:25 Done.
90 // |data| must remain valid and not be mutated throughout the lifetime of 109 // |data| must remain valid and not be mutated throughout the lifetime of
91 // the program. 110 // the program.
111 // Any existing trust anchors are cleared.
92 // Warning: Using this function concurrently with VerifyDeviceCert() 112 // Warning: Using this function concurrently with VerifyDeviceCert()
93 // is not thread safe. 113 // is not thread safe.
94 bool AddTrustAnchorForTest(const uint8_t* data, 114 bool SetTrustAnchorForTest(const uint8_t* data,
95 size_t length) WARN_UNUSED_RESULT; 115 size_t length) WARN_UNUSED_RESULT;
96 116
97 } // namespace cast_certificate 117 } // namespace cast_certificate
98 118
99 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_ 119 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CERT_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698