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

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: 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..ab2234947717fd76f35a5cab31c0b83ff81ef3b2 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,51 @@ SignedCertificateTimestamp::SignedCertificateTimestamp() {}
SignedCertificateTimestamp::~SignedCertificateTimestamp() {}
+void SignedCertificateTimestamp::Persist(Pickle* pickle) {
+ if (!(pickle->WriteInt(version) &&
+ pickle->WriteString(log_id) &&
+ pickle->WriteInt64(timestamp.ToInternalValue()) &&
+ pickle->WriteString(extensions) &&
+ pickle->WriteInt(signature.hash_algorithm) &&
+ pickle->WriteInt(signature.signature_algorithm) &&
+ pickle->WriteString(signature.signature_data))) {
+ NOTREACHED();
Eran M. (Google) 2013/11/26 21:33:22 Nit: use CHECK(all conditions) rather than if?
alcutter 2013/11/26 23:00:05 Done.
+ return;
Eran M. (Google) 2013/11/26 21:33:22 The return statement here seems superfluous.
alcutter 2013/11/26 23:00:05 The style of this was lifted from the cert pickle
+ }
+}
+
+// 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;
+ 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