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/cert/signed_certificate_timestamp.h" | 5 #include "net/cert/signed_certificate_timestamp.h" |
6 | 6 |
7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 return lhs->log_id < rhs->log_id; | 21 return lhs->log_id < rhs->log_id; |
22 if (lhs->timestamp != rhs->timestamp) | 22 if (lhs->timestamp != rhs->timestamp) |
23 return lhs->timestamp < rhs->timestamp; | 23 return lhs->timestamp < rhs->timestamp; |
24 if (lhs->extensions != rhs->extensions) | 24 if (lhs->extensions != rhs->extensions) |
25 return lhs->extensions < rhs->extensions; | 25 return lhs->extensions < rhs->extensions; |
26 if (lhs->origin != rhs->origin) | 26 if (lhs->origin != rhs->origin) |
27 return lhs->origin < rhs->origin; | 27 return lhs->origin < rhs->origin; |
28 return lhs->version < rhs->version; | 28 return lhs->version < rhs->version; |
29 } | 29 } |
30 | 30 |
31 SignedCertificateTimestamp::SignedCertificateTimestamp() {} | 31 SignedCertificateTimestamp::SignedCertificateTimestamp() |
| 32 : version(V1), origin(SCT_EMBEDDED) {} |
32 | 33 |
33 SignedCertificateTimestamp::~SignedCertificateTimestamp() {} | 34 SignedCertificateTimestamp::~SignedCertificateTimestamp() {} |
34 | 35 |
35 void SignedCertificateTimestamp::Persist(base::Pickle* pickle) { | 36 void SignedCertificateTimestamp::Persist(base::Pickle* pickle) { |
36 CHECK(pickle->WriteInt(version)); | 37 CHECK(pickle->WriteInt(version)); |
37 CHECK(pickle->WriteString(log_id)); | 38 CHECK(pickle->WriteString(log_id)); |
38 CHECK(pickle->WriteInt64(timestamp.ToInternalValue())); | 39 CHECK(pickle->WriteInt64(timestamp.ToInternalValue())); |
39 CHECK(pickle->WriteString(extensions)); | 40 CHECK(pickle->WriteString(extensions)); |
40 CHECK(pickle->WriteInt(signature.hash_algorithm)); | 41 CHECK(pickle->WriteInt(signature.hash_algorithm)); |
41 CHECK(pickle->WriteInt(signature.signature_algorithm)); | 42 CHECK(pickle->WriteInt(signature.signature_algorithm)); |
(...skipping 28 matching lines...) Expand all Loading... |
70 sct->version = static_cast<Version>(version); | 71 sct->version = static_cast<Version>(version); |
71 sct->timestamp = base::Time::FromInternalValue(timestamp); | 72 sct->timestamp = base::Time::FromInternalValue(timestamp); |
72 sct->signature.hash_algorithm = | 73 sct->signature.hash_algorithm = |
73 static_cast<DigitallySigned::HashAlgorithm>(hash_algorithm); | 74 static_cast<DigitallySigned::HashAlgorithm>(hash_algorithm); |
74 sct->signature.signature_algorithm = | 75 sct->signature.signature_algorithm = |
75 static_cast<DigitallySigned::SignatureAlgorithm>(sig_algorithm); | 76 static_cast<DigitallySigned::SignatureAlgorithm>(sig_algorithm); |
76 sct->origin = static_cast<Origin>(origin); | 77 sct->origin = static_cast<Origin>(origin); |
77 return sct; | 78 return sct; |
78 } | 79 } |
79 | 80 |
80 LogEntry::LogEntry() {} | 81 LogEntry::LogEntry() : type(LOG_ENTRY_TYPE_X509) {} |
81 | 82 |
82 LogEntry::~LogEntry() {} | 83 LogEntry::~LogEntry() {} |
83 | 84 |
84 void LogEntry::Reset() { | 85 void LogEntry::Reset() { |
85 type = LogEntry::LOG_ENTRY_TYPE_X509; | 86 type = LogEntry::LOG_ENTRY_TYPE_X509; |
86 leaf_certificate.clear(); | 87 leaf_certificate.clear(); |
87 tbs_certificate.clear(); | 88 tbs_certificate.clear(); |
88 } | 89 } |
89 | 90 |
90 DigitallySigned::DigitallySigned() {} | 91 DigitallySigned::DigitallySigned() |
| 92 : hash_algorithm(HASH_ALGO_NONE), signature_algorithm(SIG_ALGO_ANONYMOUS) {} |
91 | 93 |
92 DigitallySigned::~DigitallySigned() {} | 94 DigitallySigned::~DigitallySigned() {} |
93 | 95 |
94 bool DigitallySigned::SignatureParametersMatch( | 96 bool DigitallySigned::SignatureParametersMatch( |
95 HashAlgorithm other_hash_algorithm, | 97 HashAlgorithm other_hash_algorithm, |
96 SignatureAlgorithm other_signature_algorithm) const { | 98 SignatureAlgorithm other_signature_algorithm) const { |
97 return (hash_algorithm == other_hash_algorithm) && | 99 return (hash_algorithm == other_hash_algorithm) && |
98 (signature_algorithm == other_signature_algorithm); | 100 (signature_algorithm == other_signature_algorithm); |
99 } | 101 } |
100 } // namespace ct | 102 } // namespace ct |
101 | 103 |
102 } // namespace net | 104 } // namespace net |
OLD | NEW |