| 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 <string> | 8 #include <string> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "net/cert/ct_serialization.h" | 14 #include "net/cert/ct_serialization.h" |
| 14 #include "net/cert/signed_certificate_timestamp.h" | 15 #include "net/cert/signed_certificate_timestamp.h" |
| 15 #include "net/cert/signed_tree_head.h" | 16 #include "net/cert/signed_tree_head.h" |
| 16 #include "net/cert/x509_certificate.h" | 17 #include "net/cert/x509_certificate.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 198 |
| 198 void GetX509CertSCT(scoped_refptr<SignedCertificateTimestamp>* sct_ref) { | 199 void GetX509CertSCT(scoped_refptr<SignedCertificateTimestamp>* sct_ref) { |
| 199 CHECK(sct_ref != NULL); | 200 CHECK(sct_ref != NULL); |
| 200 *sct_ref = new SignedCertificateTimestamp(); | 201 *sct_ref = new SignedCertificateTimestamp(); |
| 201 SignedCertificateTimestamp *const sct(sct_ref->get()); | 202 SignedCertificateTimestamp *const sct(sct_ref->get()); |
| 202 sct->version = ct::SignedCertificateTimestamp::SCT_VERSION_1; | 203 sct->version = ct::SignedCertificateTimestamp::SCT_VERSION_1; |
| 203 sct->log_id = HexToBytes(kTestKeyId); | 204 sct->log_id = HexToBytes(kTestKeyId); |
| 204 // Time the log issued a SCT for this certificate, which is | 205 // Time the log issued a SCT for this certificate, which is |
| 205 // Fri Apr 5 10:04:16.089 2013 | 206 // Fri Apr 5 10:04:16.089 2013 |
| 206 sct->timestamp = base::Time::UnixEpoch() + | 207 sct->timestamp = base::Time::UnixEpoch() + |
| 207 base::TimeDelta::FromMilliseconds(GG_INT64_C(1365181456089)); | 208 base::TimeDelta::FromMilliseconds(INT64_C(1365181456089)); |
| 208 sct->extensions.clear(); | 209 sct->extensions.clear(); |
| 209 | 210 |
| 210 sct->signature.hash_algorithm = ct::DigitallySigned::HASH_ALGO_SHA256; | 211 sct->signature.hash_algorithm = ct::DigitallySigned::HASH_ALGO_SHA256; |
| 211 sct->signature.signature_algorithm = ct::DigitallySigned::SIG_ALGO_ECDSA; | 212 sct->signature.signature_algorithm = ct::DigitallySigned::SIG_ALGO_ECDSA; |
| 212 sct->signature.signature_data = HexToBytes(kTestSCTSignatureData); | 213 sct->signature.signature_data = HexToBytes(kTestSCTSignatureData); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void GetPrecertSCT(scoped_refptr<SignedCertificateTimestamp>* sct_ref) { | 216 void GetPrecertSCT(scoped_refptr<SignedCertificateTimestamp>* sct_ref) { |
| 216 CHECK(sct_ref != NULL); | 217 CHECK(sct_ref != NULL); |
| 217 *sct_ref = new SignedCertificateTimestamp(); | 218 *sct_ref = new SignedCertificateTimestamp(); |
| 218 SignedCertificateTimestamp *const sct(sct_ref->get()); | 219 SignedCertificateTimestamp *const sct(sct_ref->get()); |
| 219 sct->version = ct::SignedCertificateTimestamp::SCT_VERSION_1; | 220 sct->version = ct::SignedCertificateTimestamp::SCT_VERSION_1; |
| 220 sct->log_id = HexToBytes(kTestKeyId); | 221 sct->log_id = HexToBytes(kTestKeyId); |
| 221 // Time the log issued a SCT for this Precertificate, which is | 222 // Time the log issued a SCT for this Precertificate, which is |
| 222 // Fri Apr 5 10:04:16.275 2013 | 223 // Fri Apr 5 10:04:16.275 2013 |
| 223 sct->timestamp = base::Time::UnixEpoch() + | 224 sct->timestamp = base::Time::UnixEpoch() + |
| 224 base::TimeDelta::FromMilliseconds(GG_INT64_C(1365181456275)); | 225 base::TimeDelta::FromMilliseconds(INT64_C(1365181456275)); |
| 225 sct->extensions.clear(); | 226 sct->extensions.clear(); |
| 226 | 227 |
| 227 sct->signature.hash_algorithm = ct::DigitallySigned::HASH_ALGO_SHA256; | 228 sct->signature.hash_algorithm = ct::DigitallySigned::HASH_ALGO_SHA256; |
| 228 sct->signature.signature_algorithm = ct::DigitallySigned::SIG_ALGO_ECDSA; | 229 sct->signature.signature_algorithm = ct::DigitallySigned::SIG_ALGO_ECDSA; |
| 229 sct->signature.signature_data = HexToBytes(kTestSCTPrecertSignatureData); | 230 sct->signature.signature_data = HexToBytes(kTestSCTPrecertSignatureData); |
| 230 } | 231 } |
| 231 | 232 |
| 232 std::string GetDefaultIssuerKeyHash() { | 233 std::string GetDefaultIssuerKeyHash() { |
| 233 return HexToBytes(kDefaultIssuerKeyHash); | 234 return HexToBytes(kDefaultIssuerKeyHash); |
| 234 } | 235 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 263 memcpy(sth->sha256_root_hash, sha256_root_hash.c_str(), kSthRootHashLength); | 264 memcpy(sth->sha256_root_hash, sha256_root_hash.c_str(), kSthRootHashLength); |
| 264 | 265 |
| 265 std::string tree_head_signature = HexToBytes(kSampleSTHTreeHeadSignature); | 266 std::string tree_head_signature = HexToBytes(kSampleSTHTreeHeadSignature); |
| 266 base::StringPiece sp(tree_head_signature); | 267 base::StringPiece sp(tree_head_signature); |
| 267 DecodeDigitallySigned(&sp, &(sth->signature)); | 268 DecodeDigitallySigned(&sp, &(sth->signature)); |
| 268 } | 269 } |
| 269 | 270 |
| 270 } // namespace ct | 271 } // namespace ct |
| 271 | 272 |
| 272 } // namespace net | 273 } // namespace net |
| OLD | NEW |