| 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/ct_policy_enforcer.h" | 5 #include "net/cert/ct_policy_enforcer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 bool IsEmbeddedSCT(const scoped_refptr<ct::SignedCertificateTimestamp>& sct) { | 32 bool IsEmbeddedSCT(const scoped_refptr<ct::SignedCertificateTimestamp>& sct) { |
| 33 return sct->origin == ct::SignedCertificateTimestamp::SCT_EMBEDDED; | 33 return sct->origin == ct::SignedCertificateTimestamp::SCT_EMBEDDED; |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Returns true if the current build is recent enough to ensure that | 36 // Returns true if the current build is recent enough to ensure that |
| 37 // built-in security information (e.g. CT Logs) is fresh enough. | 37 // built-in security information (e.g. CT Logs) is fresh enough. |
| 38 // TODO(eranm): Move to base or net/base | 38 // TODO(eranm): Move to base or net/base |
| 39 bool IsBuildTimely() { | 39 bool IsBuildTimely() { |
| 40 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) | |
| 41 return true; | |
| 42 #else | |
| 43 const base::Time build_time = base::GetBuildTime(); | 40 const base::Time build_time = base::GetBuildTime(); |
| 44 // We consider built-in information to be timely for 10 weeks. | 41 // We consider built-in information to be timely for 10 weeks. |
| 45 return (base::Time::Now() - build_time).InDays() < 70 /* 10 weeks */; | 42 return (base::Time::Now() - build_time).InDays() < 70 /* 10 weeks */; |
| 46 #endif | |
| 47 } | 43 } |
| 48 | 44 |
| 49 bool IsGoogleIssuedSCT( | 45 bool IsGoogleIssuedSCT( |
| 50 const scoped_refptr<ct::SignedCertificateTimestamp>& sct) { | 46 const scoped_refptr<ct::SignedCertificateTimestamp>& sct) { |
| 51 return ct::IsLogOperatedByGoogle(sct->log_id); | 47 return ct::IsLogOperatedByGoogle(sct->log_id); |
| 52 } | 48 } |
| 53 | 49 |
| 54 // Returns a rounded-down months difference of |start| and |end|, | 50 // Returns a rounded-down months difference of |start| and |end|, |
| 55 // together with an indication of whether the last month was | 51 // together with an indication of whether the last month was |
| 56 // a full month, because the range starts specified in the policy | 52 // a full month, because the range starts specified in the policy |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 316 |
| 321 LogCTComplianceStatusToUMA(details.status, ev_whitelist); | 317 LogCTComplianceStatusToUMA(details.status, ev_whitelist); |
| 322 | 318 |
| 323 if (details.status == CT_IN_WHITELIST || details.status == CT_ENOUGH_SCTS) | 319 if (details.status == CT_IN_WHITELIST || details.status == CT_ENOUGH_SCTS) |
| 324 return true; | 320 return true; |
| 325 | 321 |
| 326 return false; | 322 return false; |
| 327 } | 323 } |
| 328 | 324 |
| 329 } // namespace net | 325 } // namespace net |
| OLD | NEW |