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

Side by Side Diff: net/cert/internal/verify_certificate_chain.h

Issue 2800993002: Add a key purpose parameter to Certificate PathBuilder. (Closed)
Patch Set: More cast comments 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ 5 #ifndef NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_
6 #define NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ 6 #define NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 #include "net/cert/internal/cert_errors.h" 13 #include "net/cert/internal/cert_errors.h"
14 #include "net/cert/internal/parsed_certificate.h" 14 #include "net/cert/internal/parsed_certificate.h"
15 #include "net/der/input.h" 15 #include "net/der/input.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace der { 19 namespace der {
20 struct GeneralizedTime; 20 struct GeneralizedTime;
21 } 21 }
22 22
23 class SignaturePolicy; 23 class SignaturePolicy;
24 class TrustAnchor; 24 class TrustAnchor;
25 25
26 // The key purpose (extended key usage) to check for during verification.
27 enum class KeyPurpose {
28 KEY_PURPOSE_ANY,
mattm 2017/04/06 22:16:03 nit: With enum class I think it's fine to leave of
eroman 2017/04/07 00:39:40 I ran into a couple of problems with macro conflic
mattm 2017/04/07 02:56:36 Ugh, macro conflicts. Don't worry about it too muc
eroman 2017/04/07 22:13:08 Checking with trybots now, I can definitely settle
29 KEY_PURPOSE_SERVER_AUTH,
30 KEY_PURPOSE_CLIENT_AUTH,
31 };
32
26 // VerifyCertificateChain() verifies a certificate path (chain) based on the 33 // VerifyCertificateChain() verifies a certificate path (chain) based on the
27 // rules in RFC 5280. The caller is responsible for building the path and 34 // rules in RFC 5280. The caller is responsible for building the path and
28 // finding the trust anchor. 35 // finding the trust anchor.
29 // 36 //
30 // WARNING: This implementation is in progress, and is currently incomplete. 37 // WARNING: This implementation is in progress, and is currently incomplete.
31 // Consult an OWNER before using it. 38 // Consult an OWNER before using it.
32 // 39 //
33 // TODO(eroman): Take a CertPath instead of ParsedCertificateList + 40 // TODO(eroman): Take a CertPath instead of ParsedCertificateList +
34 // TrustAnchor. 41 // TrustAnchor.
35 // 42 //
(...skipping 13 matching lines...) Expand all
49 // Contains the trust anchor (root) used to verify the chain. Must be 56 // Contains the trust anchor (root) used to verify the chain. Must be
50 // non-null. 57 // non-null.
51 // 58 //
52 // signature_policy: 59 // signature_policy:
53 // The policy to use when verifying signatures (what hash algorithms are 60 // The policy to use when verifying signatures (what hash algorithms are
54 // allowed, what length keys, what named curves, etc). 61 // allowed, what length keys, what named curves, etc).
55 // 62 //
56 // time: 63 // time:
57 // The UTC time to use for expiration checks. 64 // The UTC time to use for expiration checks.
58 // 65 //
66 // key_purpose:
67 // The key purpose that the target certificate needs to be valid for.
68 //
59 // --------- 69 // ---------
60 // Outputs 70 // Outputs
61 // --------- 71 // ---------
62 // 72 //
63 // Returns true if the target certificate can be verified. 73 // Returns true if the target certificate can be verified.
64 // TODO(eroman): This return value is redundant with the |errors| parameter. 74 // TODO(eroman): This return value is redundant with the |errors| parameter.
65 // 75 //
66 // errors: 76 // errors:
67 // Must be non-null. The set of errors/warnings encountered while 77 // Must be non-null. The set of errors/warnings encountered while
68 // validating the path are appended to this structure. If verification 78 // validating the path are appended to this structure. If verification
69 // failed, then there is guaranteed to be at least 1 error written to 79 // failed, then there is guaranteed to be at least 1 error written to
70 // |errors|. 80 // |errors|.
71 NET_EXPORT bool VerifyCertificateChain(const ParsedCertificateList& certs, 81 NET_EXPORT bool VerifyCertificateChain(const ParsedCertificateList& certs,
72 const TrustAnchor* trust_anchor, 82 const TrustAnchor* trust_anchor,
73 const SignaturePolicy* signature_policy, 83 const SignaturePolicy* signature_policy,
74 const der::GeneralizedTime& time, 84 const der::GeneralizedTime& time,
85 KeyPurpose required_key_purpose,
75 CertPathErrors* errors); 86 CertPathErrors* errors);
76 87
77 // TODO(crbug.com/634443): Move exported errors to a central location? 88 // TODO(crbug.com/634443): Move exported errors to a central location?
78 extern CertErrorId kValidityFailedNotAfter; 89 extern CertErrorId kValidityFailedNotAfter;
79 extern CertErrorId kValidityFailedNotBefore; 90 extern CertErrorId kValidityFailedNotBefore;
80 91
81 } // namespace net 92 } // namespace net
82 93
83 #endif // NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_ 94 #endif // NET_CERT_INTERNAL_VERIFY_CERTIFICATE_CHAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698