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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ct_serialization.h" 5 #include "net/cert/ct_serialization.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 ASSERT_FALSE( 156 ASSERT_FALSE(
157 ct::DecodeSignedCertificateTimestamp(&invalid_version_sct, &sct)); 157 ct::DecodeSignedCertificateTimestamp(&invalid_version_sct, &sct));
158 158
159 // Valid version, invalid length (missing data) 159 // Valid version, invalid length (missing data)
160 base::StringPiece invalid_length_sct("\x0\xa\xb\xc", 4); 160 base::StringPiece invalid_length_sct("\x0\xa\xb\xc", 4);
161 ASSERT_FALSE( 161 ASSERT_FALSE(
162 ct::DecodeSignedCertificateTimestamp(&invalid_length_sct, &sct)); 162 ct::DecodeSignedCertificateTimestamp(&invalid_length_sct, &sct));
163 } 163 }
164 164
165 TEST_F(CtSerializationTest, EncodesValidSignedTreeHead) {
166 ct::SignedTreeHead signed_tree_head;
167 GetSignedTreeHead(&signed_tree_head);
168
169 std::string encoded;
170 ct::EncodeTreeHeadSignature(signed_tree_head, &encoded);
171 // Expected size is 50 bytes:
172 // Byte 0 is version, byte 1 is signature type
173 // Bytes 2-9 are timestamp
174 // Bytes 10-17 are tree size
175 // Bytes 18-49 are sha256 root hash
176 ASSERT_EQ(50u, encoded.length());
177 std::string expected_buffer(
178 "\x0\x1\x0\x0\x1\x45\x3c\x5f\xb8\x35\x0\x0\x0\x0\x0\x0\x0\x15", 18);
179 expected_buffer.append(ct::GetSampleSTHSHA256RootHash());
180 ASSERT_EQ(expected_buffer, encoded);
181 }
182
165 } // namespace net 183 } // namespace net
166 184
OLDNEW
« 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