OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_X509_UTIL_H_ | 5 #ifndef NET_CERT_X509_UTIL_H_ |
6 #define NET_CERT_X509_UTIL_H_ | 6 #define NET_CERT_X509_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
14 | 14 |
15 namespace crypto { | 15 namespace crypto { |
16 class ECPrivateKey; | 16 class ECPrivateKey; |
17 class RSAPrivateKey; | 17 class RSAPrivateKey; |
18 } | 18 } |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 class X509Certificate; | 22 class X509Certificate; |
23 | 23 |
24 namespace x509_util { | 24 namespace x509_util { |
25 | 25 |
26 // Supported digest algorithms for signing certificates. | 26 // Supported digest algorithms for signing certificates. |
27 enum DigestAlgorithm { | 27 enum DigestAlgorithm { DIGEST_SHA1, DIGEST_SHA256 }; |
28 DIGEST_SHA1, | |
29 DIGEST_SHA256 | |
30 }; | |
31 | 28 |
32 // Returns true if the times can be used to create an X.509 certificate. | 29 // Returns true if the times can be used to create an X.509 certificate. |
33 // Certificates can accept dates from Jan 1st, 1 to Dec 31, 9999. A bug in NSS | 30 // Certificates can accept dates from Jan 1st, 1 to Dec 31, 9999. A bug in NSS |
34 // limited the range to 1950-9999 | 31 // limited the range to 1950-9999 |
35 // (https://bugzilla.mozilla.org/show_bug.cgi?id=786531). This function will | 32 // (https://bugzilla.mozilla.org/show_bug.cgi?id=786531). This function will |
36 // return whether it is supported by the currently used crypto library. | 33 // return whether it is supported by the currently used crypto library. |
37 NET_EXPORT_PRIVATE bool IsSupportedValidityRange(base::Time not_valid_before, | 34 NET_EXPORT_PRIVATE bool IsSupportedValidityRange(base::Time not_valid_before, |
38 base::Time not_valid_after); | 35 base::Time not_valid_after); |
39 | 36 |
40 // Creates a private keypair and server bound certificate. | 37 // Creates a private keypair and server bound certificate. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // | 101 // |
105 // Criteria include: | 102 // Criteria include: |
106 // - Prefer certificates that have a longer validity period (later | 103 // - Prefer certificates that have a longer validity period (later |
107 // expiration dates) | 104 // expiration dates) |
108 // - If equal, prefer certificates that were issued more recently | 105 // - If equal, prefer certificates that were issued more recently |
109 // - If equal, prefer shorter chains (if available) | 106 // - If equal, prefer shorter chains (if available) |
110 class NET_EXPORT_PRIVATE ClientCertSorter { | 107 class NET_EXPORT_PRIVATE ClientCertSorter { |
111 public: | 108 public: |
112 ClientCertSorter(); | 109 ClientCertSorter(); |
113 | 110 |
114 bool operator()( | 111 bool operator()(const scoped_refptr<X509Certificate>& a, |
115 const scoped_refptr<X509Certificate>& a, | 112 const scoped_refptr<X509Certificate>& b) const; |
116 const scoped_refptr<X509Certificate>& b) const; | |
117 | 113 |
118 private: | 114 private: |
119 base::Time now_; | 115 base::Time now_; |
120 }; | 116 }; |
121 | 117 |
122 } // namespace x509_util | 118 } // namespace x509_util |
123 | 119 |
124 } // namespace net | 120 } // namespace net |
125 | 121 |
126 #endif // NET_CERT_X509_UTIL_H_ | 122 #endif // NET_CERT_X509_UTIL_H_ |
OLD | NEW |