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 <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 size_t kSampleSTHTreeSize = 21u; | 172 size_t kSampleSTHTreeSize = 21u; |
173 | 173 |
174 } // namespace | 174 } // namespace |
175 | 175 |
176 void GetX509CertLogEntry(LogEntry* entry) { | 176 void GetX509CertLogEntry(LogEntry* entry) { |
177 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_X509; | 177 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_X509; |
178 entry->leaf_certificate = HexToBytes(kDefaultDerCert); | 178 entry->leaf_certificate = HexToBytes(kDefaultDerCert); |
179 } | 179 } |
180 | 180 |
181 void GetX509CertTreeLeaf(MerkleTreeLeaf* tree_leaf) { | 181 void GetX509CertTreeLeaf(MerkleTreeLeaf* tree_leaf) { |
182 tree_leaf->log_id = HexToBytes(kTestKeyId); | |
183 tree_leaf->timestamp = base::Time::FromJsTime(kTestTimestamp); | 182 tree_leaf->timestamp = base::Time::FromJsTime(kTestTimestamp); |
184 GetX509CertLogEntry(&tree_leaf->log_entry); | 183 GetX509CertLogEntry(&tree_leaf->log_entry); |
185 tree_leaf->extensions = HexToBytes(kDefaultExtensions); | 184 tree_leaf->extensions = HexToBytes(kDefaultExtensions); |
186 } | 185 } |
187 | 186 |
188 std::string GetDerEncodedX509Cert() { return HexToBytes(kDefaultDerCert); } | 187 std::string GetDerEncodedX509Cert() { return HexToBytes(kDefaultDerCert); } |
189 | 188 |
190 void GetPrecertLogEntry(LogEntry* entry) { | 189 void GetPrecertLogEntry(LogEntry* entry) { |
191 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_PRECERT; | 190 entry->type = ct::LogEntry::LOG_ENTRY_TYPE_PRECERT; |
192 std::string issuer_hash(HexToBytes(kDefaultIssuerKeyHash)); | 191 std::string issuer_hash(HexToBytes(kDefaultIssuerKeyHash)); |
193 memcpy(entry->issuer_key_hash.data, issuer_hash.data(), issuer_hash.size()); | 192 memcpy(entry->issuer_key_hash.data, issuer_hash.data(), issuer_hash.size()); |
194 entry->tbs_certificate = HexToBytes(kDefaultDerTbsCert); | 193 entry->tbs_certificate = HexToBytes(kDefaultDerTbsCert); |
195 } | 194 } |
196 | 195 |
197 void GetPrecertTreeLeaf(MerkleTreeLeaf* tree_leaf) { | 196 void GetPrecertTreeLeaf(MerkleTreeLeaf* tree_leaf) { |
198 tree_leaf->log_id = HexToBytes(kTestKeyId); | |
199 tree_leaf->timestamp = base::Time::FromJsTime(kTestTimestamp); | 197 tree_leaf->timestamp = base::Time::FromJsTime(kTestTimestamp); |
200 GetPrecertLogEntry(&tree_leaf->log_entry); | 198 GetPrecertLogEntry(&tree_leaf->log_entry); |
201 tree_leaf->extensions = HexToBytes(kDefaultExtensions); | 199 tree_leaf->extensions = HexToBytes(kDefaultExtensions); |
202 } | 200 } |
203 | 201 |
204 std::string GetTestDigitallySigned() { | 202 std::string GetTestDigitallySigned() { |
205 return HexToBytes(kTestDigitallySigned); | 203 return HexToBytes(kTestDigitallySigned); |
206 } | 204 } |
207 | 205 |
208 std::string GetTestSignedCertificateTimestamp() { | 206 std::string GetTestSignedCertificateTimestamp() { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 406 |
409 bool CheckForSCTOrigin(const ct::CTVerifyResult& result, | 407 bool CheckForSCTOrigin(const ct::CTVerifyResult& result, |
410 ct::SignedCertificateTimestamp::Origin origin) { | 408 ct::SignedCertificateTimestamp::Origin origin) { |
411 return (result.verified_scts.size() > 0) && | 409 return (result.verified_scts.size() > 0) && |
412 (result.verified_scts[0]->origin == origin); | 410 (result.verified_scts[0]->origin == origin); |
413 } | 411 } |
414 | 412 |
415 } // namespace ct | 413 } // namespace ct |
416 | 414 |
417 } // namespace net | 415 } // namespace net |
OLD | NEW |