Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/quic/crypto/null_encrypter.h" | |
| 6 #include "net/quic/test_tools/quic_test_utils.h" | |
| 7 | |
| 8 using base::StringPiece; | |
| 9 | |
| 10 namespace net { | |
| 11 | |
| 12 namespace test { | |
| 13 | |
| 14 TEST(NullEncrypterTest, Encrypt) { | |
| 15 unsigned char expected[] = { | |
| 16 // fnv hash | |
| 17 0x07, 0x2d, 0x42, 0xf0, | |
| 18 0xbe, 0x69, 0x12, 0x3d, | |
| 19 0x20, 0x80, 0x5f, 0x9a, | |
| 20 0x84, 0x9d, 0xd6, 0x0a, | |
| 21 /* TODO(rch): use this when uint128 multiplication is implemented. | |
|
jar (doing other things)
2012/10/14 23:04:38
What is this all about?
Ryan Hamilton
2012/10/15 21:22:08
As the comment suggests, we don't currently have i
| |
| 22 0x47, 0x11, 0xea, 0x5f, | |
| 23 0xcf, 0x1d, 0x66, 0x5b, | |
| 24 0xba, 0xf0, 0xbc, 0xfd, | |
| 25 0x88, 0x79, 0xca, 0x37, | |
| 26 */ | |
| 27 // payload | |
| 28 'g', 'o', 'o', 'd', | |
| 29 'b', 'y', 'e', '!', | |
| 30 }; | |
| 31 NullEncrypter encrypter; | |
| 32 scoped_ptr<QuicData> encrypted(encrypter.Encrypt("hello world!", | |
| 33 "goodbye!")); | |
| 34 ASSERT_TRUE(encrypted.get()); | |
| 35 test::CompareCharArraysWithHexError( | |
| 36 "encrypted data", encrypted->data(), encrypted->length(), | |
| 37 reinterpret_cast<const char*>(expected), arraysize(expected)); | |
| 38 } | |
| 39 | |
| 40 TEST(NullEncrypterTest, GetMaxPlaintextSize) { | |
| 41 NullEncrypter encrypter; | |
| 42 EXPECT_EQ(1000u, encrypter.GetMaxPlaintextSize(1016)); | |
| 43 EXPECT_EQ(100u, encrypter.GetMaxPlaintextSize(116)); | |
| 44 EXPECT_EQ(10u, encrypter.GetMaxPlaintextSize(26)); | |
| 45 } | |
| 46 | |
| 47 TEST(NullEncrypterTest, GetCiphertextSize) { | |
| 48 NullEncrypter encrypter; | |
| 49 EXPECT_EQ(1016u, encrypter.GetCiphertextSize(1000)); | |
| 50 EXPECT_EQ(116u, encrypter.GetCiphertextSize(100)); | |
| 51 EXPECT_EQ(26u, encrypter.GetCiphertextSize(10)); | |
| 52 } | |
| 53 | |
| 54 } // namespace test | |
| 55 | |
| 56 } // namespace net | |
| OLD | NEW |