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/test/ct_test_util.h" | 5 #include "net/test/ct_test_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 "1d0e041604146a0d982a3b62c44b6d2ef4e9bb7a01aa9cb798e2307d0603551d2304763074" | 46 "1d0e041604146a0d982a3b62c44b6d2ef4e9bb7a01aa9cb798e2307d0603551d2304763074" |
| 47 "80145f9d880dc873e654d4f80dd8e6b0c124b447c355a159a4573055310b30090603550406" | 47 "80145f9d880dc873e654d4f80dd8e6b0c124b447c355a159a4573055310b30090603550406" |
| 48 "1302474231243022060355040a131b4365727469666963617465205472616e73706172656e" | 48 "1302474231243022060355040a131b4365727469666963617465205472616e73706172656e" |
| 49 "6379204341310e300c0603550408130557616c65733110300e060355040713074572772057" | 49 "6379204341310e300c0603550408130557616c65733110300e060355040713074572772057" |
| 50 "656e82010030090603551d1304023000300d06092a864886f70d010105050003818100171c" | 50 "656e82010030090603551d1304023000300d06092a864886f70d010105050003818100171c" |
| 51 "d84aac414a9a030f22aac8f688b081b2709b848b4e5511406cd707fed028597a9faefc2eee" | 51 "d84aac414a9a030f22aac8f688b081b2709b848b4e5511406cd707fed028597a9faefc2eee" |
| 52 "2978d633aaac14ed3235197da87e0f71b8875f1ac9e78b281749ddedd007e3ecf50645f8cb" | 52 "2978d633aaac14ed3235197da87e0f71b8875f1ac9e78b281749ddedd007e3ecf50645f8cb" |
| 53 "f667256cd6a1647b5e13203bb8582de7d6696f656d1c60b95f456b7fcf338571908f1c6972" | 53 "f667256cd6a1647b5e13203bb8582de7d6696f656d1c60b95f456b7fcf338571908f1c6972" |
| 54 "7d24c4fccd249295795814d1dac0e6"; | 54 "7d24c4fccd249295795814d1dac0e6"; |
| 55 | 55 |
| 56 const char kDefaultKeyHash[] = | 56 const char kDefaultIssuerKeyHash[] = |
| 57 "2518ce9dcf869f18562d21cf7d040cbacc75371f019f8bea8cbe2f5f6619472d"; | 57 "02adddca08b8bf9861f035940c940156d8350fdff899a6239c6bd77255b8f8fc"; |
| 58 | 58 |
| 59 const char kDefaultDerTbsCert[] = | 59 const char kDefaultDerTbsCert[] = |
| 60 "30820233a003020102020107300d06092a864886f70d01010505003055310b300906035504" | 60 "30820233a003020102020107300d06092a864886f70d01010505003055310b300906035504" |
| 61 "061302474231243022060355040a131b4365727469666963617465205472616e7370617265" | 61 "061302474231243022060355040a131b4365727469666963617465205472616e7370617265" |
| 62 "6e6379204341310e300c0603550408130557616c65733110300e0603550407130745727720" | 62 "6e6379204341310e300c0603550408130557616c65733110300e0603550407130745727720" |
| 63 "57656e301e170d3132303630313030303030305a170d3232303630313030303030305a3052" | 63 "57656e301e170d3132303630313030303030305a170d3232303630313030303030305a3052" |
| 64 "310b30090603550406130247423121301f060355040a131843657274696669636174652054" | 64 "310b30090603550406130247423121301f060355040a131843657274696669636174652054" |
| 65 "72616e73706172656e6379310e300c0603550408130557616c65733110300e060355040713" | 65 "72616e73706172656e6379310e300c0603550408130557616c65733110300e060355040713" |
| 66 "074572772057656e30819f300d06092a864886f70d010101050003818d0030818902818100" | 66 "074572772057656e30819f300d06092a864886f70d010101050003818d0030818902818100" |
| 67 "bed8893cc8f177efc548df4961443f999aeda90471992f818bf8b61d0df19d6eec3d596c9b" | 67 "beef98e7c26877ae385f75325a0c1d329bedf18faaf4d796bf047eb7e1ce15c95ba2f80ee4" |
| 68 "43e60033a501c8cffcc438f49f5edb3662aaaecf180e7c9b59fc4bd465c18c406b3b70cdde" | 68 "58bd7db86f8a4b252191a79bd700c38e9c0389b45cd4dc9a120ab21e0cb41cd0e72805a410" |
| 69 "52d5dec42aaef913c2173592c76130f2399de6ccd6e75e04ccea7d7e4bdf4bacb16b5fe697" | 69 "cd9c5bdb5d4927726daf1710f60187377ea25b1a1e39eed0b88119dc154dc68f7da8e30caf" |
| 70 "2974bca8bcb3e8468dec941e945fdf98310203010001a381ac3081a9301d0603551d0e0416" | 70 "158a33e6c9509f4a05b01409ff5dd87eb50203010001a381ac3081a9301d0603551d0e0416" |
| 71 "0414a4998f6b0abefd0e549bd56f221da976d0ce57d6307d0603551d230476307480143633" | 71 "04142031541af25c05ffd8658b6843794f5e9036f7b4307d0603551d230476307480145f9d" |
| 72 "1299dbdc389d1cccfe31c08b8932501a8f7ca159a4573055310b3009060355040613024742" | 72 "880dc873e654d4f80dd8e6b0c124b447c355a159a4573055310b3009060355040613024742" |
| 73 "31243022060355040a131b4365727469666963617465205472616e73706172656e63792043" | 73 "31243022060355040a131b4365727469666963617465205472616e73706172656e63792043" |
| 74 "41310e300c0603550408130557616c65733110300e060355040713074572772057656e8201" | 74 "41310e300c0603550408130557616c65733110300e060355040713074572772057656e8201" |
| 75 "0030090603551d1304023000"; | 75 "0030090603551d1304023000"; |
| 76 | 76 |
| 77 const char kTestDigitallySigned[] = | 77 const char kTestDigitallySigned[] = |
| 78 "0403004730450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c208dfbfe9ef53" | 78 "0403004730450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c208dfbfe9ef53" |
| 79 "6cf7f2022100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc45689a2c0187ef5" | 79 "6cf7f2022100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc45689a2c0187ef5" |
| 80 "a5"; | 80 "a5"; |
| 81 | 81 |
| 82 const char kTestSignedCertificateTimestamp[] = | 82 const char kTestSignedCertificateTimestamp[] = |
| 83 "00df1c2ec11500945247a96168325ddc5c7959e8f7c6d388fc002e0bbd3f74d7640000013d" | 83 "00df1c2ec11500945247a96168325ddc5c7959e8f7c6d388fc002e0bbd3f74d7640000013d" |
| 84 "db27ded900000403004730450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c2" | 84 "db27ded900000403004730450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c2" |
| 85 "08dfbfe9ef536cf7f2022100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc456" | 85 "08dfbfe9ef536cf7f2022100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc456" |
| 86 "89a2c0187ef5a5"; | 86 "89a2c0187ef5a5"; |
| 87 | 87 |
| 88 const char kEcP256PublicKey[] = | |
| 89 "3059301306072a8648ce3d020106082a8648ce3d0301070342000499783cb14533c0161a5a" | |
| 90 "b45bf95d08a29cd0ea8dd4c84274e2be59ad15c676960cf0afa1074a57ac644b23479e5b3f" | |
| 91 "b7b245eb4b420ef370210371a944beaceb"; | |
| 92 | |
| 93 const char kTestKeyId[] = | |
| 94 "df1c2ec11500945247a96168325ddc5c7959e8f7c6d388fc002e0bbd3f74d764"; | |
| 95 | |
| 96 const uint64_t kTestSCTTimestamp = GG_UINT64_C(1365181456089); | |
|
wtc
2013/11/14 18:46:30
Just curious: why did you decide to delete this co
Eran M. (Google)
2013/11/16 22:59:16
A rather lame reason: The Windows trybot did not l
wtc
2013/11/19 21:58:10
That's strange. I wonder if the problem is as simp
| |
| 97 | |
| 98 const char kTestSCTSignatureData[] = | |
| 99 "30450220606e10ae5c2d5a1b0aed49dc4937f48de71a4e9784e9c208dfbfe9ef536cf7f202" | |
| 100 "2100beb29c72d7d06d61d06bdb38a069469aa86fe12e18bb7cc45689a2c0187ef5a5"; | |
| 101 | |
| 102 const char kTestSCTPrecertSignatureData[] = | |
| 103 "30450220482f6751af35dba65436be1fd6640f3dbf9a41429495924530288fa3e5e23e0602" | |
| 104 "2100e4edc0db3ac572b1e2f5e8ab6a680653987dcf41027dfeffa105519d89edbf08"; | |
| 105 | |
| 88 } // namespace | 106 } // namespace |
| 89 | 107 |
| 90 void GetX509CertLogEntry(LogEntry* entry) { | 108 void GetX509CertLogEntry(LogEntry* entry) { |
| 91 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_X509; | 109 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_X509; |
| 92 entry->leaf_certificate = HexToBytes(kDefaultDerCert); | 110 entry->leaf_certificate = HexToBytes(kDefaultDerCert); |
| 93 } | 111 } |
| 94 | 112 |
| 95 void GetPrecertLogEntry(LogEntry* entry) { | 113 void GetPrecertLogEntry(LogEntry* entry) { |
| 96 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_PRECERT; | 114 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_PRECERT; |
| 97 std::string issuer_hash(HexToBytes(kDefaultKeyHash)); | 115 std::string issuer_hash(HexToBytes(kDefaultIssuerKeyHash)); |
| 98 memcpy(entry->issuer_key_hash.data, issuer_hash.data(), issuer_hash.size()); | 116 memcpy(entry->issuer_key_hash.data, issuer_hash.data(), issuer_hash.size()); |
| 99 entry->tbs_certificate = HexToBytes(kDefaultDerTbsCert); | 117 entry->tbs_certificate = HexToBytes(kDefaultDerTbsCert); |
| 100 } | 118 } |
| 101 | 119 |
| 102 std::string GetTestDigitallySigned() { | 120 std::string GetTestDigitallySigned() { |
| 103 return HexToBytes(kTestDigitallySigned); | 121 return HexToBytes(kTestDigitallySigned); |
| 104 } | 122 } |
| 105 | 123 |
| 106 std::string GetTestSignedCertificateTimestamp() { | 124 std::string GetTestSignedCertificateTimestamp() { |
| 107 return HexToBytes(kTestSignedCertificateTimestamp); | 125 return HexToBytes(kTestSignedCertificateTimestamp); |
| 108 } | 126 } |
| 109 | 127 |
| 128 std::string GetTestPublicKey() { | |
| 129 return HexToBytes(kEcP256PublicKey); | |
| 130 } | |
| 131 | |
| 132 std::string GetTestPublicKeyId() { | |
| 133 return HexToBytes(kTestKeyId); | |
| 134 } | |
| 135 | |
| 136 void GetX509CertSCT(SignedCertificateTimestamp* sct) { | |
| 137 sct->log_id = HexToBytes(kTestKeyId); | |
| 138 sct->timestamp = base::Time::UnixEpoch() + | |
| 139 base::TimeDelta::FromMilliseconds(kTestSCTTimestamp); | |
| 140 sct->extensions.clear(); | |
| 141 | |
| 142 sct->signature.hash_algorithm = ct::DigitallySigned::HASH_ALGO_SHA256; | |
| 143 sct->signature.signature_algorithm = ct::DigitallySigned::SIG_ALGO_ECDSA; | |
| 144 sct->signature.signature_data = HexToBytes(kTestSCTSignatureData); | |
| 145 } | |
| 146 | |
| 147 void GetPrecertSCT(SignedCertificateTimestamp* sct) { | |
| 148 sct->log_id = HexToBytes(kTestKeyId); | |
| 149 sct->timestamp = base::Time::UnixEpoch() + | |
| 150 base::TimeDelta::FromMilliseconds(GG_UINT64_C(1365181456275)); | |
|
wtc
2013/11/19 21:58:10
Nit: since FromMilliseconds takes an int64 argumen
| |
| 151 sct->extensions.clear(); | |
| 152 | |
| 153 sct->signature.hash_algorithm = ct::DigitallySigned::HASH_ALGO_SHA256; | |
| 154 sct->signature.signature_algorithm = ct::DigitallySigned::SIG_ALGO_ECDSA; | |
| 155 sct->signature.signature_data = HexToBytes(kTestSCTPrecertSignatureData); | |
| 156 } | |
| 157 | |
| 110 } // namespace ct | 158 } // namespace ct |
| 111 | 159 |
| 112 } // namespace net | 160 } // namespace net |
| OLD | NEW |