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 #include "net/cert/x509_util.h" | 5 #include "net/cert/x509_util.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "crypto/ec_private_key.h" | 10 #include "crypto/ec_private_key.h" |
11 #include "crypto/rsa_private_key.h" | 11 #include "crypto/rsa_private_key.h" |
12 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 namespace x509_util { | 16 namespace x509_util { |
17 | 17 |
18 // RSA keys created by CreateKeyAndSelfSignedCert will be of this length. | 18 // RSA keys created by CreateKeyAndSelfSignedCert will be of this length. |
19 static const uint16 kRSAKeyLength = 1024; | 19 static const uint16 kRSAKeyLength = 1024; |
20 | 20 |
21 // Certificates made by CreateKeyAndSelfSignedCert and | 21 // Certificates made by CreateKeyAndSelfSignedCert and |
22 // CreateKeyAndDomainBoundCertEC will be signed using this digest algorithm. | 22 // CreateKeyAndDomainBoundCertEC will be signed using this digest algorithm. |
23 static const DigestAlgorithm kSignatureDigestAlgorithm = DIGEST_SHA256; | 23 static const DigestAlgorithm kSignatureDigestAlgorithm = DIGEST_SHA256; |
24 | 24 |
25 ClientCertSorter::ClientCertSorter() : now_(base::Time::Now()) {} | 25 ClientCertSorter::ClientCertSorter() : now_(base::Time::Now()) { |
| 26 } |
26 | 27 |
27 bool ClientCertSorter::operator()( | 28 bool ClientCertSorter::operator()( |
28 const scoped_refptr<X509Certificate>& a, | 29 const scoped_refptr<X509Certificate>& a, |
29 const scoped_refptr<X509Certificate>& b) const { | 30 const scoped_refptr<X509Certificate>& b) const { |
30 // Certificates that are null are sorted last. | 31 // Certificates that are null are sorted last. |
31 if (!a.get() || !b.get()) | 32 if (!a.get() || !b.get()) |
32 return a.get() && !b.get(); | 33 return a.get() && !b.get(); |
33 | 34 |
34 // Certificates that are expired/not-yet-valid are sorted last. | 35 // Certificates that are expired/not-yet-valid are sorted last. |
35 bool a_is_valid = now_ >= a->valid_start() && now_ <= a->valid_expiry(); | 36 bool a_is_valid = now_ >= a->valid_start() && now_ <= a->valid_expiry(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 der_cert); | 99 der_cert); |
99 if (success) | 100 if (success) |
100 key->reset(new_key.release()); | 101 key->reset(new_key.release()); |
101 | 102 |
102 return success; | 103 return success; |
103 } | 104 } |
104 | 105 |
105 } // namespace x509_util | 106 } // namespace x509_util |
106 | 107 |
107 } // namespace net | 108 } // namespace net |
OLD | NEW |