| Index: net/quic/crypto/crypto_framer_test.cc
|
| diff --git a/net/quic/crypto/crypto_framer_test.cc b/net/quic/crypto/crypto_framer_test.cc
|
| index 4486f595eeeda3c13b9a7f0568f548f1856448c7..7c16e7454ccaac84a2f9014cc1f2b4ecdff030f2 100644
|
| --- a/net/quic/crypto/crypto_framer_test.cc
|
| +++ b/net/quic/crypto/crypto_framer_test.cc
|
| @@ -23,7 +23,9 @@ namespace net {
|
|
|
| namespace {
|
|
|
| -char* AsChars(unsigned char* data) { return reinterpret_cast<char*>(data); }
|
| +char* AsChars(unsigned char* data) {
|
| + return reinterpret_cast<char*>(data);
|
| +}
|
|
|
| } // namespace
|
|
|
| @@ -56,41 +58,39 @@ TEST(CryptoFramerTest, ConstructHandshakeMessage) {
|
| message.SetStringPiece(0x12345679, "ghijk");
|
| message.SetStringPiece(0x1234567A, "lmnopqr");
|
|
|
| - unsigned char packet[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x03, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x06, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x0b, 0x00, 0x00, 0x00,
|
| - // tag 3
|
| - 0x7A, 0x56, 0x34, 0x12,
|
| - // end offset 3
|
| - 0x12, 0x00, 0x00, 0x00,
|
| - // value 1
|
| - 'a', 'b', 'c', 'd',
|
| - 'e', 'f',
|
| - // value 2
|
| - 'g', 'h', 'i', 'j',
|
| - 'k',
|
| - // value 3
|
| - 'l', 'm', 'n', 'o',
|
| - 'p', 'q', 'r',
|
| + unsigned char packet[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x03, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x06, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x0b, 0x00, 0x00, 0x00,
|
| + // tag 3
|
| + 0x7A, 0x56, 0x34, 0x12,
|
| + // end offset 3
|
| + 0x12, 0x00, 0x00, 0x00,
|
| + // value 1
|
| + 'a', 'b', 'c', 'd', 'e', 'f',
|
| + // value 2
|
| + 'g', 'h', 'i', 'j', 'k',
|
| + // value 3
|
| + 'l', 'm', 'n', 'o', 'p', 'q', 'r',
|
| };
|
|
|
| CryptoFramer framer;
|
| scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
|
| ASSERT_TRUE(data.get() != NULL);
|
| - test::CompareCharArraysWithHexError("constructed packet", data->data(),
|
| - data->length(), AsChars(packet),
|
| + test::CompareCharArraysWithHexError("constructed packet",
|
| + data->data(),
|
| + data->length(),
|
| + AsChars(packet),
|
| arraysize(packet));
|
| }
|
|
|
| @@ -100,35 +100,34 @@ TEST(CryptoFramerTest, ConstructHandshakeMessageWithTwoKeys) {
|
| message.SetStringPiece(0x12345678, "abcdef");
|
| message.SetStringPiece(0x12345679, "ghijk");
|
|
|
| - unsigned char packet[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x06, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x0b, 0x00, 0x00, 0x00,
|
| - // value 1
|
| - 'a', 'b', 'c', 'd',
|
| - 'e', 'f',
|
| - // value 2
|
| - 'g', 'h', 'i', 'j',
|
| - 'k',
|
| + unsigned char packet[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x06, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x0b, 0x00, 0x00, 0x00,
|
| + // value 1
|
| + 'a', 'b', 'c', 'd', 'e', 'f',
|
| + // value 2
|
| + 'g', 'h', 'i', 'j', 'k',
|
| };
|
|
|
| CryptoFramer framer;
|
| scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
|
| ASSERT_TRUE(data.get() != NULL);
|
|
|
| - test::CompareCharArraysWithHexError("constructed packet", data->data(),
|
| - data->length(), AsChars(packet),
|
| + test::CompareCharArraysWithHexError("constructed packet",
|
| + data->data(),
|
| + data->length(),
|
| + AsChars(packet),
|
| arraysize(packet));
|
| }
|
|
|
| @@ -137,25 +136,26 @@ TEST(CryptoFramerTest, ConstructHandshakeMessageZeroLength) {
|
| message.set_tag(0xFFAA7733);
|
| message.SetStringPiece(0x12345678, "");
|
|
|
| - unsigned char packet[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x01, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x00, 0x00, 0x00, 0x00,
|
| + unsigned char packet[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x01, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x00, 0x00, 0x00, 0x00,
|
| };
|
|
|
| CryptoFramer framer;
|
| scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
|
| ASSERT_TRUE(data.get() != NULL);
|
|
|
| - test::CompareCharArraysWithHexError("constructed packet", data->data(),
|
| - data->length(), AsChars(packet),
|
| + test::CompareCharArraysWithHexError("constructed packet",
|
| + data->data(),
|
| + data->length(),
|
| + AsChars(packet),
|
| arraysize(packet));
|
| }
|
|
|
| @@ -177,37 +177,37 @@ TEST(CryptoFramerTest, ConstructHandshakeMessageMinimumSize) {
|
| message.SetStringPiece(0x01020304, "test");
|
| message.set_minimum_size(64);
|
|
|
| - unsigned char packet[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 'P', 'A', 'D', 0,
|
| - // end offset 1
|
| - 0x24, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x04, 0x03, 0x02, 0x01,
|
| - // end offset 2
|
| - 0x28, 0x00, 0x00, 0x00,
|
| - // 36 bytes of padding.
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-',
|
| - // value 2
|
| - 't', 'e', 's', 't',
|
| + unsigned char packet[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 'P', 'A', 'D', 0,
|
| + // end offset 1
|
| + 0x24, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x04, 0x03, 0x02, 0x01,
|
| + // end offset 2
|
| + 0x28, 0x00, 0x00, 0x00,
|
| + // 36 bytes of padding.
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| + // value 2
|
| + 't', 'e', 's', 't',
|
| };
|
|
|
| CryptoFramer framer;
|
| scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
|
| ASSERT_TRUE(data.get() != NULL);
|
|
|
| - test::CompareCharArraysWithHexError("constructed packet", data->data(),
|
| - data->length(), AsChars(packet),
|
| + test::CompareCharArraysWithHexError("constructed packet",
|
| + data->data(),
|
| + data->length(),
|
| + AsChars(packet),
|
| arraysize(packet));
|
| }
|
|
|
| @@ -218,34 +218,34 @@ TEST(CryptoFramerTest, ConstructHandshakeMessageMinimumSizePadLast) {
|
| message.set_minimum_size(64);
|
|
|
| unsigned char packet[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x01, 0x00, 0x00, 0x00,
|
| - // end offset 1
|
| - 0x00, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 'P', 'A', 'D', 0,
|
| - // end offset 2
|
| - 0x28, 0x00, 0x00, 0x00,
|
| - // 40 bytes of padding.
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| - '-', '-', '-', '-', '-', '-', '-', '-',
|
| + // tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x01, 0x00, 0x00, 0x00,
|
| + // end offset 1
|
| + 0x00, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 'P', 'A', 'D', 0,
|
| + // end offset 2
|
| + 0x28, 0x00, 0x00, 0x00,
|
| + // 40 bytes of padding.
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| + '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-',
|
| };
|
|
|
| CryptoFramer framer;
|
| scoped_ptr<QuicData> data(framer.ConstructHandshakeMessage(message));
|
| ASSERT_TRUE(data.get() != NULL);
|
|
|
| - test::CompareCharArraysWithHexError("constructed packet", data->data(),
|
| - data->length(), AsChars(packet),
|
| + test::CompareCharArraysWithHexError("constructed packet",
|
| + data->data(),
|
| + data->length(),
|
| + AsChars(packet),
|
| arraysize(packet));
|
| }
|
|
|
| @@ -254,27 +254,24 @@ TEST(CryptoFramerTest, ProcessInput) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x06, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x0b, 0x00, 0x00, 0x00,
|
| - // value 1
|
| - 'a', 'b', 'c', 'd',
|
| - 'e', 'f',
|
| - // value 2
|
| - 'g', 'h', 'i', 'j',
|
| - 'k',
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x06, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x0b, 0x00, 0x00, 0x00,
|
| + // value 1
|
| + 'a', 'b', 'c', 'd', 'e', 'f',
|
| + // value 2
|
| + 'g', 'h', 'i', 'j', 'k',
|
| };
|
|
|
| EXPECT_TRUE(
|
| @@ -294,34 +291,30 @@ TEST(CryptoFramerTest, ProcessInputWithThreeKeys) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x03, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x06, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x0b, 0x00, 0x00, 0x00,
|
| - // tag 3
|
| - 0x7A, 0x56, 0x34, 0x12,
|
| - // end offset 3
|
| - 0x12, 0x00, 0x00, 0x00,
|
| - // value 1
|
| - 'a', 'b', 'c', 'd',
|
| - 'e', 'f',
|
| - // value 2
|
| - 'g', 'h', 'i', 'j',
|
| - 'k',
|
| - // value 3
|
| - 'l', 'm', 'n', 'o',
|
| - 'p', 'q', 'r',
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x03, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x06, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x0b, 0x00, 0x00, 0x00,
|
| + // tag 3
|
| + 0x7A, 0x56, 0x34, 0x12,
|
| + // end offset 3
|
| + 0x12, 0x00, 0x00, 0x00,
|
| + // value 1
|
| + 'a', 'b', 'c', 'd', 'e', 'f',
|
| + // value 2
|
| + 'g', 'h', 'i', 'j', 'k',
|
| + // value 3
|
| + 'l', 'm', 'n', 'o', 'p', 'q', 'r',
|
| };
|
|
|
| EXPECT_TRUE(
|
| @@ -342,27 +335,24 @@ TEST(CryptoFramerTest, ProcessInputIncrementally) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x06, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x0b, 0x00, 0x00, 0x00,
|
| - // value 1
|
| - 'a', 'b', 'c', 'd',
|
| - 'e', 'f',
|
| - // value 2
|
| - 'g', 'h', 'i', 'j',
|
| - 'k',
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x06, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x0b, 0x00, 0x00, 0x00,
|
| + // value 1
|
| + 'a', 'b', 'c', 'd', 'e', 'f',
|
| + // value 2
|
| + 'g', 'h', 'i', 'j', 'k',
|
| };
|
|
|
| for (size_t i = 0; i < arraysize(input); i++) {
|
| @@ -382,21 +372,20 @@ TEST(CryptoFramerTest, ProcessInputTagsOutOfOrder) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x13,
|
| - // end offset 1
|
| - 0x01, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x02, 0x00, 0x00, 0x00,
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x13,
|
| + // end offset 1
|
| + 0x01, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x02, 0x00, 0x00, 0x00,
|
| };
|
|
|
| EXPECT_FALSE(
|
| @@ -410,21 +399,20 @@ TEST(CryptoFramerTest, ProcessEndOffsetsOutOfOrder) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x01, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x78, 0x56, 0x34, 0x13,
|
| - // end offset 2
|
| - 0x00, 0x00, 0x00, 0x00,
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x01, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x78, 0x56, 0x34, 0x13,
|
| + // end offset 2
|
| + 0x00, 0x00, 0x00, 0x00,
|
| };
|
|
|
| EXPECT_FALSE(
|
| @@ -438,13 +426,12 @@ TEST(CryptoFramerTest, ProcessInputTooManyEntries) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0xA0, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0xA0, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| };
|
|
|
| EXPECT_FALSE(
|
| @@ -458,21 +445,20 @@ TEST(CryptoFramerTest, ProcessInputZeroLength) {
|
| CryptoFramer framer;
|
| framer.set_visitor(&visitor);
|
|
|
| - unsigned char input[] = {
|
| - // tag
|
| - 0x33, 0x77, 0xAA, 0xFF,
|
| - // num entries
|
| - 0x02, 0x00,
|
| - // padding
|
| - 0x00, 0x00,
|
| - // tag 1
|
| - 0x78, 0x56, 0x34, 0x12,
|
| - // end offset 1
|
| - 0x00, 0x00, 0x00, 0x00,
|
| - // tag 2
|
| - 0x79, 0x56, 0x34, 0x12,
|
| - // end offset 2
|
| - 0x05, 0x00, 0x00, 0x00,
|
| + unsigned char input[] = {// tag
|
| + 0x33, 0x77, 0xAA, 0xFF,
|
| + // num entries
|
| + 0x02, 0x00,
|
| + // padding
|
| + 0x00, 0x00,
|
| + // tag 1
|
| + 0x78, 0x56, 0x34, 0x12,
|
| + // end offset 1
|
| + 0x00, 0x00, 0x00, 0x00,
|
| + // tag 2
|
| + 0x79, 0x56, 0x34, 0x12,
|
| + // end offset 2
|
| + 0x05, 0x00, 0x00, 0x00,
|
| };
|
|
|
| EXPECT_TRUE(
|
|
|