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 #include "net/cert/cert_policy_enforcer.h" | 5 #include "net/cert/cert_policy_enforcer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/build_time.h" | 10 #include "base/build_time.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 // TODO(eranm): Move to base or net/base | 35 // TODO(eranm): Move to base or net/base |
36 bool IsBuildTimely() { | 36 bool IsBuildTimely() { |
37 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) | 37 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) |
38 return true; | 38 return true; |
39 #else | 39 #else |
40 const base::Time build_time = base::GetBuildTime(); | 40 const base::Time build_time = base::GetBuildTime(); |
41 // We consider built-in information to be timely for 10 weeks. | 41 // We consider built-in information to be timely for 10 weeks. |
42 return (base::Time::Now() - build_time).InDays() < 70 /* 10 weeks */; | 42 return (base::Time::Now() - build_time).InDays() < 70 /* 10 weeks */; |
43 #endif | 43 #endif |
44 } | 44 } |
45 | 45 |
davidben
2015/03/25 15:00:54
Maybe add a comment here that this is the number o
Eran Messeri
2015/03/25 18:27:28
Done.
| |
46 uint32_t ApproximateMonthDifference(const base::Time& start, | 46 uint32_t ApproximateMonthDifference(const base::Time& start, |
47 const base::Time& end) { | 47 const base::Time& end) { |
48 base::Time::Exploded exploded_start; | 48 base::Time::Exploded exploded_start; |
49 base::Time::Exploded exploded_expiry; | 49 base::Time::Exploded exploded_expiry; |
50 start.UTCExplode(&exploded_start); | 50 start.UTCExplode(&exploded_start); |
51 end.UTCExplode(&exploded_expiry); | 51 end.UTCExplode(&exploded_expiry); |
52 uint32_t month_diff = (exploded_expiry.year - exploded_start.year) * 12 + | 52 uint32_t month_diff = (exploded_expiry.year - exploded_start.year) * 12 + |
53 (exploded_expiry.month - exploded_start.month); | 53 (exploded_expiry.month - exploded_start.month); |
davidben
2015/03/25 15:00:54
This still isn't quite right, is it? A certificate
Eran Messeri
2015/03/25 18:27:28
This is trickier than it seems, since the policy,
| |
54 | 54 |
55 // Add any remainder as a full month. | |
56 if (exploded_expiry.day_of_month > exploded_start.day_of_month) | |
57 ++month_diff; | |
58 | |
59 return month_diff; | 55 return month_diff; |
60 } | 56 } |
61 | 57 |
62 bool HasRequiredNumberOfSCTs(const X509Certificate& cert, | 58 bool HasRequiredNumberOfSCTs(const X509Certificate& cert, |
63 const ct::CTVerifyResult& ct_result) { | 59 const ct::CTVerifyResult& ct_result) { |
64 // TODO(eranm): Count the number of *independent* SCTs once the information | 60 // TODO(eranm): Count the number of *independent* SCTs once the information |
65 // about log operators is available, crbug.com/425174 | 61 // about log operators is available, crbug.com/425174 |
66 size_t num_valid_scts = ct_result.verified_scts.size(); | 62 size_t num_valid_scts = ct_result.verified_scts.size(); |
67 size_t num_embedded_scts = | 63 size_t num_embedded_scts = |
68 std::count_if(ct_result.verified_scts.begin(), | 64 std::count_if(ct_result.verified_scts.begin(), |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 | 262 |
267 LogCTComplianceStatusToUMA(details.status, ev_whitelist); | 263 LogCTComplianceStatusToUMA(details.status, ev_whitelist); |
268 | 264 |
269 if (details.status == CT_IN_WHITELIST || details.status == CT_ENOUGH_SCTS) | 265 if (details.status == CT_IN_WHITELIST || details.status == CT_ENOUGH_SCTS) |
270 return true; | 266 return true; |
271 | 267 |
272 return false; | 268 return false; |
273 } | 269 } |
274 | 270 |
275 } // namespace net | 271 } // namespace net |
OLD | NEW |