Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_known_logs.h" | 5 #include "net/cert/ct_known_logs.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 CHECK_EQ(log_id.size(), crypto::kSHA256Length); | 62 CHECK_EQ(log_id.size(), crypto::kSHA256Length); |
| 63 | 63 |
| 64 return std::binary_search(std::begin(kGoogleLogIDs), std::end(kGoogleLogIDs), | 64 return std::binary_search(std::begin(kGoogleLogIDs), std::end(kGoogleLogIDs), |
| 65 log_id.data(), [](const char* a, const char* b) { | 65 log_id.data(), [](const char* a, const char* b) { |
| 66 return memcmp(a, b, crypto::kSHA256Length) < 0; | 66 return memcmp(a, b, crypto::kSHA256Length) < 0; |
| 67 }); | 67 }); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool IsLogDisqualified(base::StringPiece log_id, | 70 bool IsLogDisqualified(base::StringPiece log_id, |
| 71 base::Time* disqualification_date) { | 71 base::Time* disqualification_date) { |
| 72 CHECK_EQ(log_id.size(), arraysize(kDisqualifiedCTLogList[0].log_id) - 1); | 72 CHECK_EQ(log_id.size(), arraysize(kDisqualifiedCTLogList[0].log_id) - 1); |
|
eroman
2016/05/26 00:47:40
If we don't already have it somewhere, would be pr
| |
| 73 | 73 |
| 74 auto p = std::lower_bound( | 74 auto p = std::lower_bound( |
| 75 std::begin(kDisqualifiedCTLogList), std::end(kDisqualifiedCTLogList), | 75 std::begin(kDisqualifiedCTLogList), std::end(kDisqualifiedCTLogList), |
| 76 log_id.data(), | 76 log_id.data(), |
| 77 [](const DisqualifiedCTLogInfo& disqualified_log, const char* log_id) { | 77 [](const DisqualifiedCTLogInfo& disqualified_log, const char* log_id) { |
| 78 return memcmp(disqualified_log.log_id, log_id, crypto::kSHA256Length) < | 78 return memcmp(disqualified_log.log_id, log_id, crypto::kSHA256Length) < |
| 79 0; | 79 0; |
| 80 }); | 80 }); |
| 81 if (p == std::end(kDisqualifiedCTLogList) || | 81 if (p == std::end(kDisqualifiedCTLogList) || |
| 82 memcmp(p->log_id, log_id.data(), crypto::kSHA256Length) != 0) { | 82 memcmp(p->log_id, log_id.data(), crypto::kSHA256Length) != 0) { |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 | 85 |
| 86 *disqualification_date = | 86 *disqualification_date = base::Time::UnixEpoch() + p->disqualification_date; |
| 87 base::Time::FromInternalValue(p->disqualification_date); | |
| 88 return true; | 87 return true; |
| 89 } | 88 } |
| 90 | 89 |
| 91 } // namespace ct | 90 } // namespace ct |
| 92 | 91 |
| 93 } // namespace net | 92 } // namespace net |
| 94 | 93 |
| OLD | NEW |