Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: net/cert/signed_certificate_timestamp.cc

Issue 88643002: SignedCertificateTimestamp storing & serialization code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erans_patches
Patch Set: Fixes for jam. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cert/signed_certificate_timestamp.cc
diff --git a/net/cert/signed_certificate_timestamp.cc b/net/cert/signed_certificate_timestamp.cc
index 8925a994c123ba146f30bfd2bb8c8cd5fa4d975a..31d3415ccf3ae76dd4e6c03f2f80ee24b7d1b2ea 100644
--- a/net/cert/signed_certificate_timestamp.cc
+++ b/net/cert/signed_certificate_timestamp.cc
@@ -4,6 +4,8 @@
#include "net/cert/signed_certificate_timestamp.h"
+#include "base/pickle.h"
+
namespace net {
namespace ct {
@@ -28,6 +30,48 @@ SignedCertificateTimestamp::SignedCertificateTimestamp() {}
SignedCertificateTimestamp::~SignedCertificateTimestamp() {}
+void SignedCertificateTimestamp::Persist(Pickle* pickle) {
+ CHECK(pickle->WriteInt(version));
+ CHECK(pickle->WriteString(log_id));
+ CHECK(pickle->WriteInt64(timestamp.ToInternalValue()));
+ CHECK(pickle->WriteString(extensions));
+ CHECK(pickle->WriteInt(signature.hash_algorithm));
+ CHECK(pickle->WriteInt(signature.signature_algorithm));
+ CHECK(pickle->WriteString(signature.signature_data));
+}
+
+// static
+SignedCertificateTimestamp*
+SignedCertificateTimestamp::CreateFromPickle(PickleIterator* iter) {
+ int version;
+ std::string log_id;
+ int64 timestamp;
+ std::string extensions;
+ int hash_algorithm;
+ int sig_algorithm;
+ 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.
+ if (!(iter->ReadInt(&version) &&
+ iter->ReadString(&log_id) &&
+ iter->ReadInt64(&timestamp) &&
+ iter->ReadString(&extensions) &&
+ iter->ReadInt(&hash_algorithm) &&
+ iter->ReadInt(&sig_algorithm) &&
+ iter->ReadString(&sig_data))) {
+ return NULL;
+ }
+ SignedCertificateTimestamp* sct(new SignedCertificateTimestamp());
+ sct->version = static_cast<Version>(version);
+ sct->log_id = log_id;
+ sct->timestamp = base::Time::FromInternalValue(timestamp);
+ sct->extensions = extensions;
+ sct->signature.hash_algorithm =
+ static_cast<DigitallySigned::HashAlgorithm>(hash_algorithm);
+ sct->signature.signature_algorithm =
+ static_cast<DigitallySigned::SignatureAlgorithm>(sig_algorithm);
+ sct->signature.signature_data = sig_data;
+ return sct;
+}
+
LogEntry::LogEntry() {}
LogEntry::~LogEntry() {}

Powered by Google App Engine
This is Rietveld 408576698