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

Unified Diff: net/cert/ct_serialization_unittest.cc

Issue 230713002: Certificate Transparency: Parse Signed Tree Heads and validate them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing more of Ryan's comments Created 6 years, 7 months 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
« no previous file with comments | « net/cert/ct_serialization.cc ('k') | net/cert/signed_certificate_timestamp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/ct_serialization_unittest.cc
diff --git a/net/cert/ct_serialization_unittest.cc b/net/cert/ct_serialization_unittest.cc
index 934cdb38a6000b138befbda0750485662b734a65..606bdd1d2d7d7a1347bf074b1270efbbdb5d260f 100644
--- a/net/cert/ct_serialization_unittest.cc
+++ b/net/cert/ct_serialization_unittest.cc
@@ -162,5 +162,23 @@ TEST_F(CtSerializationTest, FailsDecodingInvalidSignedCertificateTimestamp) {
ct::DecodeSignedCertificateTimestamp(&invalid_length_sct, &sct));
}
+TEST_F(CtSerializationTest, EncodesValidSignedTreeHead) {
+ ct::SignedTreeHead signed_tree_head;
+ GetSignedTreeHead(&signed_tree_head);
+
+ std::string encoded;
+ ct::EncodeTreeHeadSignature(signed_tree_head, &encoded);
+ // Expected size is 50 bytes:
+ // Byte 0 is version, byte 1 is signature type
+ // Bytes 2-9 are timestamp
+ // Bytes 10-17 are tree size
+ // Bytes 18-49 are sha256 root hash
+ ASSERT_EQ(50u, encoded.length());
+ std::string expected_buffer(
+ "\x0\x1\x0\x0\x1\x45\x3c\x5f\xb8\x35\x0\x0\x0\x0\x0\x0\x0\x15", 18);
+ expected_buffer.append(ct::GetSampleSTHSHA256RootHash());
+ ASSERT_EQ(expected_buffer, encoded);
+}
+
} // namespace net
« no previous file with comments | « net/cert/ct_serialization.cc ('k') | net/cert/signed_certificate_timestamp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698