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

Side by Side Diff: net/quic/core/quic_framer_test.cc

Issue 2739323002: Drop Packets with the multipath bit set before decryption. Protected by FLAGS_quic_reloadable_flag_… (Closed)
Patch Set: Created 3 years, 9 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/quic/core/quic_framer.cc ('k') | net/quic/core/quic_packets.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 (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/core/quic_framer.h" 5 #include "net/quic/core/quic_framer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdint> 8 #include <cstdint>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); 908 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id);
909 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER, 909 EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER,
910 visitor_.header_->public_header.packet_number_length); 910 visitor_.header_->public_header.packet_number_length);
911 EXPECT_EQ(kPacketNumber - 1, visitor_.header_->packet_number); 911 EXPECT_EQ(kPacketNumber - 1, visitor_.header_->packet_number);
912 } 912 }
913 913
914 TEST_P(QuicFramerTest, PacketWithDiversificationNonce) { 914 TEST_P(QuicFramerTest, PacketWithDiversificationNonce) {
915 // clang-format off 915 // clang-format off
916 unsigned char packet[] = { 916 unsigned char packet[] = {
917 // public flags: includes nonce flag 917 // public flags: includes nonce flag
918 0x7C, 918 static_cast<unsigned char>(
919 FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x3C : 0x7C),
919 // connection_id 920 // connection_id
920 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, 921 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE,
921 // nonce 922 // nonce
922 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 923 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
923 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 924 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
924 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 925 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
925 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 926 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
926 // packet number 927 // packet number
927 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 928 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12,
928 929
929 // frame type (padding) 930 // frame type (padding)
930 0x00, 931 0x00,
931 0x00, 0x00, 0x00, 0x00 932 0x00, 0x00, 0x00, 0x00
932 }; 933 };
933 // clang-format on 934 // clang-format on
934 935
935 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 936 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
936 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); 937 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT);
937 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 938 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
938 ASSERT_TRUE(visitor_.public_header_->nonce != nullptr); 939 ASSERT_TRUE(visitor_.public_header_->nonce != nullptr);
939 for (char i = 0; i < 32; ++i) { 940 for (char i = 0; i < 32; ++i) {
940 EXPECT_EQ(i, (*visitor_.public_header_->nonce)[static_cast<size_t>(i)]); 941 EXPECT_EQ(i, (*visitor_.public_header_->nonce)[static_cast<size_t>(i)]);
941 } 942 }
942 }; 943 };
943 944
944 TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { 945 TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) {
945 // clang-format off 946 // clang-format off
946 unsigned char packet[] = { 947 unsigned char packet[] = {
947 // public flags (8 byte connection_id, version flag and an unknown flag) 948 // public flags (8 byte connection_id, version flag and an unknown flag)
948 0x79, 949 static_cast<unsigned char>(
950 FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x39 : 0x79),
949 // connection_id 951 // connection_id
950 0x10, 0x32, 0x54, 0x76, 952 0x10, 0x32, 0x54, 0x76,
951 0x98, 0xBA, 0xDC, 0xFE, 953 0x98, 0xBA, 0xDC, 0xFE,
952 // version tag 954 // version tag
953 'Q', '0', '0', '0', 955 'Q', '0', '0', '0',
954 // packet number 956 // packet number
955 0xBC, 0x9A, 0x78, 0x56, 957 0xBC, 0x9A, 0x78, 0x56,
956 0x34, 0x12, 958 0x34, 0x12,
957 959
958 // frame type (padding frame) 960 // frame type (padding frame)
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after
3658 'o', ' ', 'w', 'o', 3660 'o', ' ', 'w', 'o',
3659 'r', 'l', 'd', '!', 3661 'r', 'l', 'd', '!',
3660 }; 3662 };
3661 // clang-format on 3663 // clang-format on
3662 3664
3663 QuicFramerFuzzFunc(packet, arraysize(packet)); 3665 QuicFramerFuzzFunc(packet, arraysize(packet));
3664 } 3666 }
3665 3667
3666 } // namespace test 3668 } // namespace test
3667 } // namespace net 3669 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_framer.cc ('k') | net/quic/core/quic_packets.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698