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

Side by Side Diff: net/quic/crypto/null_decrypter_test.cc

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/null_decrypter.cc ('k') | net/quic/crypto/null_encrypter.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic/crypto/null_decrypter.h" 5 #include "net/quic/crypto/null_decrypter.h"
6 #include "net/quic/test_tools/quic_test_utils.h" 6 #include "net/quic/test_tools/quic_test_utils.h"
7 7
8 using base::StringPiece; 8 using base::StringPiece;
9 9
10 namespace net { 10 namespace net {
11 namespace test { 11 namespace test {
12 12
13 TEST(NullDecrypterTest, Decrypt) { 13 TEST(NullDecrypterTest, Decrypt) {
14 unsigned char expected[] = { 14 unsigned char expected[] = {
15 // fnv hash 15 // fnv hash
16 0xa0, 0x6f, 0x44, 0x8a, 16 0xa0, 0x6f, 0x44, 0x8a,
17 0x44, 0xf8, 0x18, 0x3b, 17 0x44, 0xf8, 0x18, 0x3b,
18 0x47, 0x91, 0xb2, 0x13, 18 0x47, 0x91, 0xb2, 0x13,
19 0x6b, 0x09, 0xbb, 0xae, 19 0x6b, 0x09, 0xbb, 0xae,
20 // payload 20 // payload
21 'g', 'o', 'o', 'd', 21 'g', 'o', 'o', 'd',
22 'b', 'y', 'e', '!', 22 'b', 'y', 'e', '!',
23 }; 23 };
24 NullDecrypter decrypter; 24 NullDecrypter decrypter;
25 scoped_ptr<QuicData> decrypted( 25 scoped_ptr<QuicData> decrypted(decrypter.DecryptPacket(
26 decrypter.DecryptPacket( 26 0, "hello world!", StringPiece(reinterpret_cast<const char*>(expected),
27 0, "hello world!", 27 arraysize(expected))));
28 StringPiece(reinterpret_cast<const char*>(expected),
29 arraysize(expected))));
30 ASSERT_TRUE(decrypted.get()); 28 ASSERT_TRUE(decrypted.get());
31 EXPECT_EQ("goodbye!", decrypted->AsStringPiece()); 29 EXPECT_EQ("goodbye!", decrypted->AsStringPiece());
32 } 30 }
33 31
34 TEST(NullDecrypterTest, BadHash) { 32 TEST(NullDecrypterTest, BadHash) {
35 unsigned char expected[] = { 33 unsigned char expected[] = {
36 // fnv hash 34 // fnv hash
37 0x46, 0x11, 0xea, 0x5f, 35 0x46, 0x11, 0xea, 0x5f,
38 0xcf, 0x1d, 0x66, 0x5b, 36 0xcf, 0x1d, 0x66, 0x5b,
39 0xba, 0xf0, 0xbc, 0xfd, 37 0xba, 0xf0, 0xbc, 0xfd,
40 0x88, 0x79, 0xca, 0x37, 38 0x88, 0x79, 0xca, 0x37,
41 // payload 39 // payload
42 'g', 'o', 'o', 'd', 40 'g', 'o', 'o', 'd',
43 'b', 'y', 'e', '!', 41 'b', 'y', 'e', '!',
44 }; 42 };
45 NullDecrypter decrypter; 43 NullDecrypter decrypter;
46 scoped_ptr<QuicData> decrypted( 44 scoped_ptr<QuicData> decrypted(decrypter.DecryptPacket(
47 decrypter.DecryptPacket( 45 0, "hello world!", StringPiece(reinterpret_cast<const char*>(expected),
48 0, "hello world!", 46 arraysize(expected))));
49 StringPiece(reinterpret_cast<const char*>(expected),
50 arraysize(expected))));
51 ASSERT_FALSE(decrypted.get()); 47 ASSERT_FALSE(decrypted.get());
52 } 48 }
53 49
54 TEST(NullDecrypterTest, ShortInput) { 50 TEST(NullDecrypterTest, ShortInput) {
55 unsigned char expected[] = { 51 unsigned char expected[] = {
56 // fnv hash (truncated) 52 // fnv hash (truncated)
57 0x46, 0x11, 0xea, 0x5f, 53 0x46, 0x11, 0xea, 0x5f,
58 0xcf, 0x1d, 0x66, 0x5b, 54 0xcf, 0x1d, 0x66, 0x5b,
59 0xba, 0xf0, 0xbc, 0xfd, 55 0xba, 0xf0, 0xbc, 0xfd,
60 0x88, 0x79, 0xca, 56 0x88, 0x79, 0xca,
61 }; 57 };
62 NullDecrypter decrypter; 58 NullDecrypter decrypter;
63 scoped_ptr<QuicData> decrypted( 59 scoped_ptr<QuicData> decrypted(decrypter.DecryptPacket(
64 decrypter.DecryptPacket( 60 0, "hello world!", StringPiece(reinterpret_cast<const char*>(expected),
65 0, "hello world!", 61 arraysize(expected))));
66 StringPiece(reinterpret_cast<const char*>(expected),
67 arraysize(expected))));
68 ASSERT_FALSE(decrypted.get()); 62 ASSERT_FALSE(decrypted.get());
69 } 63 }
70 64
71 } // namespace test 65 } // namespace test
72 } // namespace net 66 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/null_decrypter.cc ('k') | net/quic/crypto/null_encrypter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698