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" | |
8 | |
7 namespace net { | 9 namespace net { |
8 | 10 |
9 namespace ct { | 11 namespace ct { |
10 | 12 |
11 bool SignedCertificateTimestamp::LessThan::operator()( | 13 bool SignedCertificateTimestamp::LessThan::operator()( |
12 const scoped_refptr<SignedCertificateTimestamp>& lhs, | 14 const scoped_refptr<SignedCertificateTimestamp>& lhs, |
13 const scoped_refptr<SignedCertificateTimestamp>& rhs) const { | 15 const scoped_refptr<SignedCertificateTimestamp>& rhs) const { |
14 if (lhs.get() == rhs.get()) | 16 if (lhs.get() == rhs.get()) |
15 return false; | 17 return false; |
16 if (lhs->signature.signature_data != rhs->signature.signature_data) | 18 if (lhs->signature.signature_data != rhs->signature.signature_data) |
17 return lhs->signature.signature_data < rhs->signature.signature_data; | 19 return lhs->signature.signature_data < rhs->signature.signature_data; |
18 if (lhs->log_id != rhs->log_id) | 20 if (lhs->log_id != rhs->log_id) |
19 return lhs->log_id < rhs->log_id; | 21 return lhs->log_id < rhs->log_id; |
20 if (lhs->timestamp != rhs->timestamp) | 22 if (lhs->timestamp != rhs->timestamp) |
21 return lhs->timestamp < rhs->timestamp; | 23 return lhs->timestamp < rhs->timestamp; |
22 if (lhs->extensions != rhs->extensions) | 24 if (lhs->extensions != rhs->extensions) |
23 return lhs->extensions < rhs->extensions; | 25 return lhs->extensions < rhs->extensions; |
24 return lhs->version < rhs->version; | 26 return lhs->version < rhs->version; |
25 } | 27 } |
26 | 28 |
27 SignedCertificateTimestamp::SignedCertificateTimestamp() {} | 29 SignedCertificateTimestamp::SignedCertificateTimestamp() {} |
28 | 30 |
29 SignedCertificateTimestamp::~SignedCertificateTimestamp() {} | 31 SignedCertificateTimestamp::~SignedCertificateTimestamp() {} |
30 | 32 |
33 void SignedCertificateTimestamp::Persist(Pickle* pickle) { | |
34 CHECK(pickle->WriteInt(version)); | |
35 CHECK(pickle->WriteString(log_id)); | |
36 CHECK(pickle->WriteInt64(timestamp.ToInternalValue())); | |
37 CHECK(pickle->WriteString(extensions)); | |
38 CHECK(pickle->WriteInt(signature.hash_algorithm)); | |
39 CHECK(pickle->WriteInt(signature.signature_algorithm)); | |
40 CHECK(pickle->WriteString(signature.signature_data)); | |
41 } | |
42 | |
43 // static | |
44 SignedCertificateTimestamp* | |
45 SignedCertificateTimestamp::CreateFromPickle(PickleIterator* iter) { | |
46 int version; | |
47 std::string log_id; | |
48 int64 timestamp; | |
49 std::string extensions; | |
50 int hash_algorithm; | |
51 int sig_algorithm; | |
52 std::string sig_data; | |
wtc
2013/11/27 16:32:41
Nit: you can store the new SignedCertificateTimest
wtc
2013/11/27 17:29:18
I just realized that SignedCertificateTimestamp is
alcutter
2013/11/27 18:05:55
That occurred to me too, but I thought the split o
alcutter
2013/11/27 18:05:55
Ah, I'd assumed you meant a scoped_refptr in the o
wtc
2013/11/28 01:28:02
The new convention in Chromium seems to recommend
alcutter
2013/11/28 12:08:19
Ack.
| |
53 if (!(iter->ReadInt(&version) && | |
54 iter->ReadString(&log_id) && | |
55 iter->ReadInt64(×tamp) && | |
56 iter->ReadString(&extensions) && | |
57 iter->ReadInt(&hash_algorithm) && | |
58 iter->ReadInt(&sig_algorithm) && | |
59 iter->ReadString(&sig_data))) { | |
60 return NULL; | |
61 } | |
62 SignedCertificateTimestamp* sct(new SignedCertificateTimestamp()); | |
63 sct->version = static_cast<Version>(version); | |
64 sct->log_id = log_id; | |
65 sct->timestamp = base::Time::FromInternalValue(timestamp); | |
66 sct->extensions = extensions; | |
67 sct->signature.hash_algorithm = | |
68 static_cast<DigitallySigned::HashAlgorithm>(hash_algorithm); | |
69 sct->signature.signature_algorithm = | |
70 static_cast<DigitallySigned::SignatureAlgorithm>(sig_algorithm); | |
71 sct->signature.signature_data = sig_data; | |
72 return sct; | |
73 } | |
74 | |
31 LogEntry::LogEntry() {} | 75 LogEntry::LogEntry() {} |
32 | 76 |
33 LogEntry::~LogEntry() {} | 77 LogEntry::~LogEntry() {} |
34 | 78 |
35 void LogEntry::Reset() { | 79 void LogEntry::Reset() { |
36 type = LogEntry::LOG_ENTRY_TYPE_X509; | 80 type = LogEntry::LOG_ENTRY_TYPE_X509; |
37 leaf_certificate.clear(); | 81 leaf_certificate.clear(); |
38 tbs_certificate.clear(); | 82 tbs_certificate.clear(); |
39 } | 83 } |
40 | 84 |
41 DigitallySigned::DigitallySigned() {} | 85 DigitallySigned::DigitallySigned() {} |
42 | 86 |
43 DigitallySigned::~DigitallySigned() {} | 87 DigitallySigned::~DigitallySigned() {} |
44 | 88 |
45 } // namespace ct | 89 } // namespace ct |
46 | 90 |
47 } // namespace net | 91 } // namespace net |
OLD | NEW |