Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: net/test/ct_test_util.cc

Issue 37633002: CT: First step towards supporting Certificate Transparency in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exporting DigitallySigned Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« net/cert/ct_serialization.cc ('K') | « net/test/ct_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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 "net/test/ct_test_util.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_piece.h"
12 #include "base/strings/string_util.h"
13 #include "net/cert/ct_serialization.h"
14 #include "net/cert/signed_certificate_timestamp.h"
15 #include "net/cert/x509_certificate.h"
16
17 namespace net {
18
19 namespace ct {
20
21 namespace {
22
23 std::string HexToBytes(const char* hex_data) {
24 std::vector<uint8> output;
25 std::string result;
26 if (base::HexStringToBytes(hex_data, &output))
27 result.assign(reinterpret_cast<const char*>(&output[0]), output.size());
28 return result;
29 }
30
31 // The following test vectors are from
32 // http://code.google.com/p/certificate-transparency
33
34 const char kDefaultDerCert[] =
35 "308202ca30820233a003020102020106300d06092a864886f70d01010505003055310b3009"
36 "06035504061302474231243022060355040a131b4365727469666963617465205472616e73"
37 "706172656e6379204341310e300c0603550408130557616c65733110300e06035504071307"
38 "4572772057656e301e170d3132303630313030303030305a170d3232303630313030303030"
39 "305a3052310b30090603550406130247423121301f060355040a1318436572746966696361"
40 "7465205472616e73706172656e6379310e300c0603550408130557616c65733110300e0603"
41 "55040713074572772057656e30819f300d06092a864886f70d010101050003818d00308189"
42 "02818100b1fa37936111f8792da2081c3fe41925008531dc7f2c657bd9e1de4704160b4c9f"
43 "19d54ada4470404c1c51341b8f1f7538dddd28d9aca48369fc5646ddcc7617f8168aae5b41"
44 "d43331fca2dadfc804d57208949061f9eef902ca47ce88c644e000f06eeeccabdc9dd2f68a"
45 "22ccb09dc76e0dbc73527765b1a37a8c676253dcc10203010001a381ac3081a9301d060355"
46 "1d0e041604146a0d982a3b62c44b6d2ef4e9bb7a01aa9cb798e2307d0603551d2304763074"
47 "80145f9d880dc873e654d4f80dd8e6b0c124b447c355a159a4573055310b30090603550406"
48 "1302474231243022060355040a131b4365727469666963617465205472616e73706172656e"
49 "6379204341310e300c0603550408130557616c65733110300e060355040713074572772057"
50 "656e82010030090603551d1304023000300d06092a864886f70d010105050003818100171c"
51 "d84aac414a9a030f22aac8f688b081b2709b848b4e5511406cd707fed028597a9faefc2eee"
52 "2978d633aaac14ed3235197da87e0f71b8875f1ac9e78b281749ddedd007e3ecf50645f8cb"
53 "f667256cd6a1647b5e13203bb8582de7d6696f656d1c60b95f456b7fcf338571908f1c6972"
54 "7d24c4fccd249295795814d1dac0e6";
55
56 const char kDefaultKeyHash[] =
57 "2518ce9dcf869f18562d21cf7d040cbacc75371f019f8bea8cbe2f5f6619472d";
58
59 const char kDefaultDerTbsCert[] =
60 "30820233a003020102020107300d06092a864886f70d01010505003055310b300906035504"
61 "061302474231243022060355040a131b4365727469666963617465205472616e7370617265"
62 "6e6379204341310e300c0603550408130557616c65733110300e0603550407130745727720"
63 "57656e301e170d3132303630313030303030305a170d3232303630313030303030305a3052"
64 "310b30090603550406130247423121301f060355040a131843657274696669636174652054"
65 "72616e73706172656e6379310e300c0603550408130557616c65733110300e060355040713"
66 "074572772057656e30819f300d06092a864886f70d010101050003818d0030818902818100"
67 "bed8893cc8f177efc548df4961443f999aeda90471992f818bf8b61d0df19d6eec3d596c9b"
68 "43e60033a501c8cffcc438f49f5edb3662aaaecf180e7c9b59fc4bd465c18c406b3b70cdde"
69 "52d5dec42aaef913c2173592c76130f2399de6ccd6e75e04ccea7d7e4bdf4bacb16b5fe697"
70 "2974bca8bcb3e8468dec941e945fdf98310203010001a381ac3081a9301d0603551d0e0416"
71 "0414a4998f6b0abefd0e549bd56f221da976d0ce57d6307d0603551d230476307480143633"
72 "1299dbdc389d1cccfe31c08b8932501a8f7ca159a4573055310b3009060355040613024742"
73 "31243022060355040a131b4365727469666963617465205472616e73706172656e63792043"
74 "41310e300c0603550408130557616c65733110300e060355040713074572772057656e8201"
75 "0030090603551d1304023000";
76
77 const char kTestDigitallySigned[] =
78 "0403004730450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c208dfbfe9ef53"
79 "6cf7f2022100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc45689a2c0187ef5"
80 "a5";
81
82 const char kTestSignedCertificateTimestamp[] =
83 "00df1c2ec11500945247a96168325ddc5c7959e8f7c6d388fc002e0bbd3f74d7640000013d"
84 "db27ded900000403004730450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c2"
85 "08dfbfe9ef536cf7f2022100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc456"
86 "89a2c0187ef5a5";
87 } // namespace
Ryan Sleevi 2013/10/30 20:48:27 nit: linebreak between the var & } // namespace
Eran M. (Google) 2013/10/31 11:37:37 Done.
88
89 void GetX509CertLogEntry(LogEntry* entry) {
90 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_X509;
91 entry->leaf_certificate = HexToBytes(kDefaultDerCert);
92 }
93
94 void GetPrecertLogEntry(LogEntry* entry) {
95 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_PRECERT;
96 std::string issuer_hash(HexToBytes(kDefaultKeyHash));
97 memcpy(entry->issuer_key_hash.data, issuer_hash.data(), issuer_hash.size());
98 entry->tbs_certificate = HexToBytes(kDefaultDerTbsCert);
99 }
100
101 std::string GetTestDigitallySigned() {
102 return HexToBytes(kTestDigitallySigned);
103 }
104
105 std::string GetTestSignedCertificateTimestamp() {
106 return HexToBytes(kTestSignedCertificateTimestamp);
107 }
108
109 } // namespace ct
110
111 } // namespace net
OLDNEW
« net/cert/ct_serialization.cc ('K') | « net/test/ct_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698