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
3 // found in the LICENSE file.
4 
5 #include "components/certificate_transparency/ct_known_logs.h"
6 
7 #include <stddef.h>
8 #include <string.h>
9 
10 #include <algorithm>
11 #include <iterator>
12 
13 #include "base/macros.h"
14 #include "base/stl_util.h"
15 #include "base/time/time.h"
16 #include "crypto/sha2.h"
17 
18 namespace certificate_transparency {
19 
20 namespace {
21 #include "components/certificate_transparency/data/log_list-inc.cc"
22 }  // namespace
23 
GetKnownLogs()24 std::vector<CTLogInfo> GetKnownLogs() {
25   // Add all qualified logs.
26   std::vector<CTLogInfo> logs(std::begin(kCTLogList), std::end(kCTLogList));
27 
28   // Add all disqualified logs. Callers are expected to filter verified SCTs
29   // via IsLogDisqualified().
30   for (const auto& disqualified_log : kDisqualifiedCTLogList) {
31     logs.push_back(disqualified_log.log_info);
32   }
33 
34   return logs;
35 }
36 
GetLogsOperatedByGoogle()37 std::vector<std::string> GetLogsOperatedByGoogle() {
38   std::vector<std::string> result;
39   for (const auto& log_id : kGoogleLogIDs) {
40     result.push_back(std::string(log_id, crypto::kSHA256Length));
41   }
42   return result;
43 }
44 
GetDisqualifiedLogs()45 std::vector<std::pair<std::string, base::TimeDelta>> GetDisqualifiedLogs() {
46   std::vector<std::pair<std::string, base::TimeDelta>> result;
47   for (const auto& log : kDisqualifiedCTLogList) {
48     result.push_back(
49         std::make_pair(std::string(log.log_id, crypto::kSHA256Length),
50                        log.disqualification_date));
51   }
52   return result;
53 }
54 
55 }  // namespace certificate_transparency
56