diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 2c6a870e1e..d0de88b60b 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -394,6 +394,7 @@ rtc_library("dtls_transport") { ] deps = [ ":dtls_transport_internal", + ":dtls_utils", ":ice_transport_internal", ":packet_transport_internal", "../api:array_view", @@ -777,6 +778,18 @@ rtc_library("stun_dictionary") { ] } +rtc_library("dtls_utils") { + sources = [ + "dtls/dtls_utils.cc", + "dtls/dtls_utils.h", + ] + deps = [ + "../api:array_view", + "../rtc_base:byte_buffer", + "../rtc_base:checks", + ] +} + rtc_library("stun_port") { sources = [ "base/stun_port.cc", @@ -1114,6 +1127,7 @@ if (rtc_include_tests) { "base/turn_server_unittest.cc", "base/wrapping_active_ice_controller_unittest.cc", "client/basic_port_allocator_unittest.cc", + "dtls/dtls_utils_unittest.cc", ] deps = [ ":active_ice_controller_factory_interface", @@ -1124,6 +1138,7 @@ if (rtc_include_tests) { ":basic_port_allocator", ":connection", ":dtls_transport", + ":dtls_utils", ":fake_ice_transport", ":fake_port_allocator", ":ice_credentials_iterator", diff --git a/p2p/base/dtls_transport.cc b/p2p/base/dtls_transport.cc index 832acaf2be..f125f225ca 100644 --- a/p2p/base/dtls_transport.cc +++ b/p2p/base/dtls_transport.cc @@ -32,6 +32,7 @@ #include "p2p/base/dtls_transport_internal.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/packet_transport_internal.h" +#include "p2p/dtls/dtls_utils.h" #include "rtc_base/buffer.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -48,8 +49,6 @@ namespace cricket { // We don't pull the RTP constants from rtputils.h, to avoid a layer violation. -static const size_t kDtlsRecordHeaderLen = 13; -static const size_t kMaxDtlsPacketLen = 2048; static const size_t kMinRtpPacketLen = 12; // Maximum number of pending packets in the queue. Packets are read immediately @@ -64,17 +63,6 @@ static const size_t kMaxPendingPackets = 2; static const int kMinHandshakeTimeout = 50; static const int kMaxHandshakeTimeout = 3000; -static bool IsDtlsPacket(rtc::ArrayView payload) { - const uint8_t* u = payload.data(); - return (payload.size() >= kDtlsRecordHeaderLen && (u[0] > 19 && u[0] < 64)); -} -static bool IsDtlsClientHelloPacket(rtc::ArrayView payload) { - if (!IsDtlsPacket(payload)) { - return false; - } - const uint8_t* u = payload.data(); - return payload.size() > 17 && u[0] == 22 && u[13] == 1; -} static bool IsRtpPacket(rtc::ArrayView payload) { const uint8_t* u = payload.data(); return (payload.size() >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80); diff --git a/p2p/dtls/dtls_utils.cc b/p2p/dtls/dtls_utils.cc new file mode 100644 index 0000000000..050ecd9fac --- /dev/null +++ b/p2p/dtls/dtls_utils.cc @@ -0,0 +1,109 @@ +/* + * Copyright 2024 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "p2p/dtls/dtls_utils.h" + +#include +#include +#include + +#include "api/array_view.h" +#include "rtc_base/byte_buffer.h" +#include "rtc_base/checks.h" + +namespace { +// https://datatracker.ietf.org/doc/html/rfc5246#appendix-A.1 +const uint8_t kDtlsHandshakeRecord = 22; +const uint8_t kDtlsChangeCipherSpecRecord = 20; +} // namespace + +namespace cricket { + +bool IsDtlsPacket(rtc::ArrayView payload) { + const uint8_t* u = payload.data(); + return (payload.size() >= kDtlsRecordHeaderLen && (u[0] > 19 && u[0] < 64)); +} + +bool IsDtlsClientHelloPacket(rtc::ArrayView payload) { + if (!IsDtlsPacket(payload)) { + return false; + } + const uint8_t* u = payload.data(); + return payload.size() > 17 && u[0] == kDtlsHandshakeRecord && u[13] == 1; +} + +bool IsDtlsHandshakePacket(rtc::ArrayView payload) { + if (!IsDtlsPacket(payload)) { + return false; + } + // change cipher spec is not a handshake packet. This used + // to work because it was aggregated with the session ticket + // which is no more. It is followed by the encrypted handshake + // message which starts with a handshake record (22) again. + return payload.size() > 17 && (payload[0] == kDtlsHandshakeRecord || + payload[0] == kDtlsChangeCipherSpecRecord); +} + +// Returns a (unsorted) list of (msg_seq) received as part of the handshake. +std::optional> GetDtlsHandshakeAcks( + rtc::ArrayView dtls_packet) { + std::vector acks; + rtc::ByteBufferReader record_buf(dtls_packet); + // https://datatracker.ietf.org/doc/html/rfc6347#section-4.1 + while (record_buf.Length() >= kDtlsRecordHeaderLen) { + uint8_t content_type; + uint64_t epoch_and_seq; + uint16_t len; + // Read content_type(1), skip version(2), read epoch+seq(2+6), + // read len(2) + if (!(record_buf.ReadUInt8(&content_type) && record_buf.Consume(2) && + record_buf.ReadUInt64(&epoch_and_seq) && + record_buf.ReadUInt16(&len) && record_buf.Length() >= len)) { + return std::nullopt; + } + if (content_type != kDtlsHandshakeRecord) { + record_buf.Consume(len); + continue; + } + // Epoch 1+ is encrypted so we can not parse it. + if (epoch_and_seq >> 6 != 0) { + record_buf.Consume(len); + continue; + } + + // https://www.rfc-editor.org/rfc/rfc6347.html#section-4.2.2 + rtc::ByteBufferReader handshake_buf(record_buf.DataView().subview(0, len)); + while (handshake_buf.Length() > 0) { + uint16_t msg_seq; + uint32_t fragment_len; + uint32_t fragment_offset; + // Skip msg_type(1) and length(3), read msg_seq(2), skip + // fragment_offset(3), read fragment_length(3) and consume it. + if (!(handshake_buf.Consume(1 + 3) && + handshake_buf.ReadUInt16(&msg_seq) && + handshake_buf.ReadUInt24(&fragment_offset) && + handshake_buf.ReadUInt24(&fragment_len) && + handshake_buf.Consume(fragment_len))) { + return std::nullopt; + } + acks.push_back(msg_seq); + // Advance outer buffer. + record_buf.Consume(12 + fragment_len); + } + RTC_DCHECK(handshake_buf.Length() == 0); + } + // Should have consumed everything. + if (record_buf.Length() != 0) { + return std::nullopt; + } + return acks; +} + +} // namespace cricket diff --git a/p2p/dtls/dtls_utils.h b/p2p/dtls/dtls_utils.h new file mode 100644 index 0000000000..bf81d9f4f6 --- /dev/null +++ b/p2p/dtls/dtls_utils.h @@ -0,0 +1,35 @@ +/* + * Copyright 2024 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef P2P_DTLS_DTLS_UTILS_H_ +#define P2P_DTLS_DTLS_UTILS_H_ + +#include +#include +#include +#include + +#include "api/array_view.h" + +namespace cricket { + +const size_t kDtlsRecordHeaderLen = 13; +const size_t kMaxDtlsPacketLen = 2048; + +bool IsDtlsPacket(rtc::ArrayView payload); +bool IsDtlsClientHelloPacket(rtc::ArrayView payload); +bool IsDtlsHandshakePacket(rtc::ArrayView payload); + +std::optional> GetDtlsHandshakeAcks( + rtc::ArrayView dtls_packet); + +} // namespace cricket + +#endif // P2P_DTLS_DTLS_UTILS_H_ diff --git a/p2p/dtls/dtls_utils_unittest.cc b/p2p/dtls/dtls_utils_unittest.cc new file mode 100644 index 0000000000..9f3e25b7c4 --- /dev/null +++ b/p2p/dtls/dtls_utils_unittest.cc @@ -0,0 +1,182 @@ +/* + * Copyright 2024 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "p2p/dtls/dtls_utils.h" + +#include +#include +#include + +#include "test/gmock.h" +#include "test/gtest.h" + +namespace cricket { + +TEST(DtlsUtils, GetDtlsHandshakeAcksRejectsTooShort) { + std::vector packet = { + 0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xde, 0xad // Length given but bytes not present. + }; + EXPECT_FALSE(GetDtlsHandshakeAcks(packet)); +} + +TEST(DtlsUtils, GetDtlsHandshakeAcksRejectsInvalidContent) { + std::vector packet = {0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + // Correct length given but data is garbage. + 0x04, 0xde, 0xad, 0xbe, 0xef}; + EXPECT_FALSE(GetDtlsHandshakeAcks(packet)); +} + +TEST(DtlsUtils, GetDtlsHandshakeAcksRejectsTrailingData) { + std::vector packet = { + 0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Server hello done. + 0xde, 0xad, 0xbe, 0xef // Trailing data. + }; + EXPECT_FALSE(GetDtlsHandshakeAcks(packet)); +} + +TEST(DtlsUtils, GetDtlsHandshakeAcksBasic) { + std::vector packet = { + 0x16, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Server hello done. + }; + std::optional> acks = GetDtlsHandshakeAcks(packet); + ASSERT_TRUE(acks); + EXPECT_EQ(acks->size(), 1u); + EXPECT_THAT(*acks, ::testing::ElementsAreArray({0xac})); +} + +TEST(DtlsUtils, GetDtlsHandshakeAcksPackedRecords) { + // Flight two from server to client but with fragment packing per + // https://boringssl.googlesource.com/boringssl/+/5245371a08528f7fb21ab20bd7a479d8e395b61c + std::vector packet = { + 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x43, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x60, 0xfe, 0xfd, 0x67, 0x2a, 0x87, 0x84, 0xf8, 0xe5, 0xbc, 0xe5, 0xd1, + 0x2b, 0xfe, 0x53, 0x20, 0xd2, 0xd4, 0x53, 0xa5, 0xbe, 0xd8, 0x38, 0x58, + 0x91, 0xdf, 0x76, 0x21, 0x81, 0x60, 0x7c, 0x6d, 0x8c, 0xdb, 0x93, 0x20, + 0x91, 0xc8, 0xf6, 0x9c, 0xaa, 0xbe, 0x79, 0xa3, 0x28, 0xa6, 0x84, 0xc9, + 0xfa, 0xee, 0x59, 0x22, 0x5d, 0xe2, 0x11, 0x28, 0xf4, 0x80, 0xd6, 0x1a, + 0x3a, 0xb5, 0x3d, 0xb6, 0x61, 0x74, 0xb6, 0x1d, 0xc0, 0x2b, 0x00, 0x00, + 0x18, 0x00, 0x17, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b, + 0x00, 0x02, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x05, 0x00, 0x02, 0x00, 0x01, + 0x00, 0x0b, 0x00, 0x01, 0x1f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x1f, 0x00, 0x01, 0x1c, 0x00, 0x01, 0x19, 0x30, 0x82, 0x01, 0x15, 0x30, + 0x81, 0xbd, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x9d, 0x2a, + 0x69, 0x9b, 0x1d, 0x5a, 0x38, 0xe5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x11, 0x31, 0x0f, 0x30, 0x0d, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x06, 0x57, 0x65, 0x62, 0x52, 0x54, + 0x43, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x31, 0x30, 0x34, 0x32, + 0x31, 0x30, 0x30, 0x35, 0x31, 0x5a, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x32, + 0x30, 0x35, 0x32, 0x31, 0x30, 0x30, 0x35, 0x31, 0x5a, 0x30, 0x11, 0x31, + 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x06, 0x57, 0x65, + 0x62, 0x52, 0x54, 0x43, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x1e, 0xd8, 0xad, 0x96, 0x82, + 0xd0, 0xfb, 0xc8, 0xaa, 0xff, 0x84, 0x40, 0x84, 0xfc, 0x1e, 0x4a, 0xfd, + 0x8b, 0xfc, 0x13, 0xbb, 0xee, 0x93, 0xea, 0x91, 0x55, 0x61, 0x7d, 0xc3, + 0x96, 0x66, 0x38, 0x6d, 0x51, 0x59, 0x57, 0xbd, 0xc3, 0xd2, 0x03, 0xf4, + 0xde, 0x48, 0x3f, 0x61, 0x5e, 0x59, 0x2b, 0xfa, 0xfe, 0x68, 0xc0, 0x98, + 0xa3, 0x33, 0xe7, 0xd6, 0xb4, 0x0e, 0xbe, 0x56, 0x48, 0x50, 0x4b, 0x30, + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, + 0x47, 0x00, 0x30, 0x44, 0x02, 0x20, 0x4d, 0xff, 0x9f, 0xf3, 0xc4, 0x08, + 0x15, 0xe0, 0xdd, 0x76, 0x64, 0x0d, 0x50, 0x42, 0x30, 0xbb, 0xf7, 0xca, + 0x78, 0xff, 0xe7, 0x86, 0x05, 0x0f, 0x23, 0x6e, 0xd2, 0x69, 0xd3, 0xc5, + 0xbd, 0xaa, 0x02, 0x20, 0x43, 0x71, 0x52, 0x2f, 0x74, 0x25, 0x78, 0xcd, + 0x62, 0x62, 0x62, 0x0b, 0xbf, 0x76, 0x35, 0xe1, 0xfe, 0x8c, 0x03, 0x6b, + 0x56, 0xb8, 0x96, 0x1f, 0xb1, 0x3a, 0x9f, 0xd9, 0x78, 0x05, 0x66, 0xa7, + 0x0c, 0x00, 0x00, 0x6f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, + 0x03, 0x00, 0x1d, 0x20, 0xf5, 0x50, 0xad, 0x14, 0x55, 0xd1, 0xbc, 0x82, + 0xa8, 0xb0, 0x2b, 0x81, 0x3d, 0x18, 0xf4, 0xba, 0x11, 0x54, 0xbb, 0x24, + 0x8b, 0x07, 0xa7, 0x17, 0xf1, 0x33, 0xca, 0x45, 0xc0, 0x6a, 0x16, 0x0a, + 0x04, 0x03, 0x00, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xad, 0xb6, 0x59, + 0x0c, 0xe0, 0x56, 0x42, 0xb8, 0x9f, 0x40, 0x43, 0xd3, 0x7f, 0x9f, 0xa0, + 0x1d, 0xbc, 0x78, 0xf5, 0xc3, 0x38, 0x99, 0x02, 0xde, 0x11, 0x85, 0x0f, + 0x50, 0xd6, 0x5b, 0x82, 0x7c, 0x02, 0x20, 0x57, 0x2e, 0x0a, 0x82, 0xf7, + 0x14, 0xb6, 0xd6, 0xb2, 0x4b, 0xd7, 0x1a, 0xd6, 0x1b, 0xc2, 0xf6, 0xc2, + 0x4f, 0x3f, 0xe2, 0x8a, 0x06, 0x97, 0xf3, 0x84, 0xc8, 0x60, 0xf1, 0xab, + 0x2d, 0x29, 0xaf, 0x0d, 0x00, 0x00, 0x19, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x19, 0x02, 0x01, 0x40, 0x00, 0x12, 0x04, 0x03, 0x08, 0x04, + 0x04, 0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, + 0x02, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; + + std::optional> acks = GetDtlsHandshakeAcks(packet); + ASSERT_TRUE(acks); + EXPECT_EQ(acks->size(), 5u); + EXPECT_THAT(*acks, ::testing::ElementsAreArray({0, 1, 2, 3, 4})); + + std::vector packet2 = { + 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6c, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x60, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0xb2, 0xeb, 0x05, 0xc9, 0xba, + 0x39, 0xd0, 0xf6, 0x4b, 0xc9, 0x7e, 0xee, 0x57, 0xfc, 0x2b, 0x90, 0x93, + 0x09, 0xfd, 0x05, 0x80, 0xb3, 0xf5, 0xfc, 0x06, 0x68, 0x38, 0xa8, 0x20, + 0x42, 0x1d, 0x78, 0xe1, 0x97, 0x73, 0x55, 0x0a, 0x16, 0x2d, 0xc1, 0x3e, + 0x4f, 0x71, 0x55, 0xb4, 0x9f, 0xf8, 0x61, 0xe1, 0xbd, 0xe3, 0xf2, 0x2e, + 0x40, 0x29, 0x30, 0x58, 0x37, 0x26, 0x0d, 0xe8, 0xc0, 0x2b, 0x00, 0x00, + 0x18, 0x00, 0x17, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b, + 0x00, 0x02, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x05, 0x00, 0x02, 0x00, 0x01, + 0x00, 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x01, 0x28, 0x0b, 0x00, 0x01, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x1c, 0x00, 0x01, 0x19, 0x00, 0x01, 0x16, 0x30, 0x82, 0x01, 0x12, + 0x30, 0x81, 0xb8, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x15, 0xc9, + 0xcc, 0xd0, 0x55, 0x57, 0xa2, 0x32, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x0f, 0x31, 0x0d, 0x30, 0x0b, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x74, 0x65, 0x73, 0x74, 0x30, + 0x1e, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x31, 0x30, 0x35, 0x32, 0x30, 0x35, + 0x33, 0x34, 0x38, 0x5a, 0x17, 0x0d, 0x32, 0x34, 0x31, 0x32, 0x30, 0x36, + 0x32, 0x30, 0x35, 0x33, 0x34, 0x38, 0x5a, 0x30, 0x0f, 0x31, 0x0d, 0x30, + 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x74, 0x65, 0x73, 0x74, + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, + 0x42, 0x00, 0x04, 0x8f, 0x43, 0xeb, 0x7b, 0x88, 0x73, 0x4f, 0xe7, 0x69, + 0x06, 0x81, 0xb6, 0xb9, 0xf3, 0xca, 0x73, 0x32, 0x69, 0xb2, 0xc5, 0xe6, + 0x4e, 0xf0, 0x8c, 0xf4, 0xdd, 0x4e, 0x5b, 0xea, 0x06, 0x52, 0x94, 0x9a, + 0x12, 0x77, 0x11, 0xde, 0xf9, 0x12, 0x9a, 0xeb, 0x3c, 0x7c, 0xe4, 0xcf, + 0x58, 0x4c, 0x74, 0x44, 0x84, 0x0a, 0x84, 0xeb, 0xe6, 0xa4, 0xd5, 0xd3, + 0x06, 0xca, 0x52, 0x15, 0x7e, 0xeb, 0x19, 0x30, 0x0a, 0x06, 0x08, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x49, 0x00, 0x30, 0x46, + 0x02, 0x21, 0x00, 0xab, 0xc7, 0x06, 0x7e, 0x36, 0x9b, 0xad, 0xe0, 0x26, + 0x61, 0x6b, 0x59, 0xa0, 0x1c, 0x70, 0x0c, 0xa6, 0xd3, 0xff, 0x8a, 0xc7, + 0xba, 0xe4, 0x23, 0x0a, 0x8b, 0x22, 0x82, 0xcd, 0x5a, 0x5c, 0x56, 0x02, + 0x21, 0x00, 0xc7, 0xe8, 0x57, 0x04, 0xb5, 0x44, 0x69, 0x42, 0xa2, 0xa2, + 0x1e, 0xde, 0x7f, 0xc4, 0x44, 0x98, 0xa4, 0x5c, 0x84, 0x41, 0xa1, 0x31, + 0x38, 0x3c, 0xe5, 0x4f, 0xf5, 0xc0, 0xa9, 0xa8, 0xbc, 0x16, 0x16, 0xfe, + 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x7a, 0x0c, + 0x00, 0x00, 0x6e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x03, + 0x00, 0x1d, 0x20, 0x89, 0xb9, 0xeb, 0x39, 0x29, 0xa0, 0x31, 0x08, 0x9a, + 0xbf, 0xc3, 0xc0, 0x20, 0x60, 0xbb, 0xea, 0x73, 0x19, 0xcf, 0x63, 0xe4, + 0x5a, 0xa8, 0xa9, 0x56, 0x77, 0xe8, 0x81, 0x48, 0xae, 0x9f, 0x34, 0x04, + 0x03, 0x00, 0x46, 0x30, 0x44, 0x02, 0x20, 0x23, 0x34, 0xc6, 0x39, 0x94, + 0x84, 0xcc, 0x67, 0xeb, 0x44, 0xf9, 0xc3, 0x5c, 0x52, 0xb3, 0x99, 0x52, + 0xf7, 0x4f, 0xff, 0x8b, 0xc5, 0xea, 0xb5, 0xd0, 0xf9, 0x36, 0xb3, 0xe6, + 0xfc, 0x37, 0x50, 0x02, 0x20, 0x4c, 0xe2, 0x29, 0xf5, 0x4a, 0x4c, 0x7a, + 0x01, 0x37, 0xce, 0xc1, 0xb0, 0x15, 0x23, 0xfd, 0xa5, 0xd9, 0xac, 0x75, + 0xcb, 0x55, 0x56, 0x99, 0x97, 0xe3, 0x13, 0xbd, 0x5b, 0xcc, 0x5d, 0x0c, + 0xa8, 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x25, 0x0d, 0x00, 0x00, 0x19, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x19, 0x02, 0x01, 0x40, 0x00, 0x12, 0x04, 0x03, 0x08, 0x04, 0x04, + 0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, 0x02, + 0x01, 0x00, 0x00, 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; + + std::optional> acks2 = GetDtlsHandshakeAcks(packet2); + ASSERT_TRUE(acks2); + EXPECT_EQ(acks2->size(), 5u); + EXPECT_THAT(*acks2, ::testing::ElementsAreArray({0, 1, 2, 3, 4})); +} + +} // namespace cricket