mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-06 22:22:38 +03:00
Introduce a ByteRange typealias
Summary: See title Reviewed By: kvtsoy Differential Revision: D73444489 fbshipit-source-id: f83566ce023e8237335d3bb43d89fc471f053afa
This commit is contained in:
committed by
Facebook GitHub Bot
parent
048e64e2f1
commit
bcbe5adce4
@@ -35,6 +35,7 @@ using SystemClock = folly::chrono::SystemClock;
|
|||||||
|
|
||||||
namespace quic {
|
namespace quic {
|
||||||
|
|
||||||
|
using ByteRange = folly::ByteRange;
|
||||||
using BufHelpers = folly::IOBuf; // For stuff like BufHelpers::create, etc.
|
using BufHelpers = folly::IOBuf; // For stuff like BufHelpers::create, etc.
|
||||||
using Buf = folly::IOBuf; // Used when we're not wrapping the buffer in an
|
using Buf = folly::IOBuf; // Used when we're not wrapping the buffer in an
|
||||||
// std::unique_ptr
|
// std::unique_ptr
|
||||||
|
@@ -866,7 +866,7 @@ class QuicSocketLite {
|
|||||||
*/
|
*/
|
||||||
virtual Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
virtual Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) const = 0;
|
uint16_t keyLength) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -51,7 +51,7 @@ class MockQuicSocket : public QuicSocket {
|
|||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
(Optional<std::vector<uint8_t>>),
|
(Optional<std::vector<uint8_t>>),
|
||||||
getExportedKeyingMaterial,
|
getExportedKeyingMaterial,
|
||||||
(const std::string&, const Optional<folly::ByteRange>&, uint16_t),
|
(const std::string&, const Optional<ByteRange>&, uint16_t),
|
||||||
(const));
|
(const));
|
||||||
MOCK_METHOD(std::shared_ptr<QuicEventBase>, getEventBase, (), (const));
|
MOCK_METHOD(std::shared_ptr<QuicEventBase>, getEventBase, (), (const));
|
||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
|
@@ -281,7 +281,7 @@ TEST_F(QuicBatchWriterTest, TestBatchingSendmmsgInplaceIovecMatches) {
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
for (auto& message : messages) {
|
for (auto& message : messages) {
|
||||||
auto buf = folly::IOBuf::copyBuffer(
|
auto buf = folly::IOBuf::copyBuffer(
|
||||||
folly::ByteRange((unsigned char*)message.data(), message.size()));
|
ByteRange((unsigned char*)message.data(), message.size()));
|
||||||
batchWriter->append(
|
batchWriter->append(
|
||||||
std::move(buf), message.size(), folly::SocketAddress(), nullptr);
|
std::move(buf), message.size(), folly::SocketAddress(), nullptr);
|
||||||
size += message.size();
|
size += message.size();
|
||||||
@@ -306,7 +306,7 @@ TEST_F(QuicBatchWriterTest, TestBatchingSendmmsgInplaceIovecMatches) {
|
|||||||
folly::IOBufEqualTo eq;
|
folly::IOBufEqualTo eq;
|
||||||
EXPECT_TRUE(
|
EXPECT_TRUE(
|
||||||
eq(wrappedIovBuffer,
|
eq(wrappedIovBuffer,
|
||||||
folly::IOBuf::copyBuffer(folly::ByteRange(
|
folly::IOBuf::copyBuffer(ByteRange(
|
||||||
(unsigned char*)messages[i].data(), messages[i].size()))));
|
(unsigned char*)messages[i].data(), messages[i].size()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,8 +356,8 @@ TEST_F(QuicBatchWriterTest, TestBatchingSendmmsgNewlyAllocatedIovecMatches) {
|
|||||||
for (auto& message : messages) {
|
for (auto& message : messages) {
|
||||||
auto buf = std::make_unique<folly::IOBuf>();
|
auto buf = std::make_unique<folly::IOBuf>();
|
||||||
for (size_t j = 0; j < message.size(); j++) {
|
for (size_t j = 0; j < message.size(); j++) {
|
||||||
auto partBuf = folly::IOBuf::copyBuffer(folly::ByteRange(
|
auto partBuf = folly::IOBuf::copyBuffer(
|
||||||
(unsigned char*)message[j].data(), message[j].size()));
|
ByteRange((unsigned char*)message[j].data(), message[j].size()));
|
||||||
buf->appendToChain(std::move(partBuf));
|
buf->appendToChain(std::move(partBuf));
|
||||||
}
|
}
|
||||||
buffers.emplace_back(std::move(buf));
|
buffers.emplace_back(std::move(buf));
|
||||||
|
@@ -603,7 +603,7 @@ class TestQuicTransport
|
|||||||
|
|
||||||
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string&,
|
const std::string&,
|
||||||
const Optional<folly::ByteRange>&,
|
const Optional<ByteRange>&,
|
||||||
uint16_t) const override {
|
uint16_t) const override {
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
@@ -293,15 +293,14 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
|||||||
EXPECT_EQ(rt1.offset, 0);
|
EXPECT_EQ(rt1.offset, 0);
|
||||||
std::string expected = "hey w";
|
std::string expected = "hey w";
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange((uint8_t*)expected.data(), expected.size()),
|
ByteRange((uint8_t*)expected.data(), expected.size()),
|
||||||
rt1.data.getHead()->getRange());
|
rt1.data.getHead()->getRange());
|
||||||
|
|
||||||
EXPECT_EQ(stream2->retransmissionBuffer.size(), 1);
|
EXPECT_EQ(stream2->retransmissionBuffer.size(), 1);
|
||||||
auto& rt2 = *stream2->retransmissionBuffer.at(0);
|
auto& rt2 = *stream2->retransmissionBuffer.at(0);
|
||||||
EXPECT_EQ(rt2.offset, 0);
|
EXPECT_EQ(rt2.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf->buffer(), buf->length()),
|
ByteRange(buf->buffer(), buf->length()), rt2.data.getHead()->getRange());
|
||||||
rt2.data.getHead()->getRange());
|
|
||||||
EXPECT_TRUE(rt2.eof);
|
EXPECT_TRUE(rt2.eof);
|
||||||
|
|
||||||
// Testing retransmission
|
// Testing retransmission
|
||||||
@@ -358,13 +357,13 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
|||||||
auto& rt3 = *stream1->retransmissionBuffer.at(5);
|
auto& rt3 = *stream1->retransmissionBuffer.at(5);
|
||||||
expected = "hats up";
|
expected = "hats up";
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange((uint8_t*)expected.data(), expected.size()),
|
ByteRange((uint8_t*)expected.data(), expected.size()),
|
||||||
rt3.data.getHead()->getRange());
|
rt3.data.getHead()->getRange());
|
||||||
|
|
||||||
auto& rt4 = *stream1->retransmissionBuffer.at(0);
|
auto& rt4 = *stream1->retransmissionBuffer.at(0);
|
||||||
expected = "hey w";
|
expected = "hey w";
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange((uint8_t*)expected.data(), expected.size()),
|
ByteRange((uint8_t*)expected.data(), expected.size()),
|
||||||
rt4.data.getHead()->getRange());
|
rt4.data.getHead()->getRange());
|
||||||
|
|
||||||
// loss buffer should be split into 2. Part in retransmission buffer and
|
// loss buffer should be split into 2. Part in retransmission buffer and
|
||||||
@@ -374,7 +373,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
|||||||
auto& rt5 = *stream2->retransmissionBuffer.at(0);
|
auto& rt5 = *stream2->retransmissionBuffer.at(0);
|
||||||
expected = "hey wh";
|
expected = "hey wh";
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange((uint8_t*)expected.data(), expected.size()),
|
ByteRange((uint8_t*)expected.data(), expected.size()),
|
||||||
rt5.data.getHead()->getRange());
|
rt5.data.getHead()->getRange());
|
||||||
EXPECT_EQ(rt5.offset, 0);
|
EXPECT_EQ(rt5.offset, 0);
|
||||||
EXPECT_EQ(rt5.eof, 0);
|
EXPECT_EQ(rt5.eof, 0);
|
||||||
@@ -382,7 +381,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
|||||||
auto& rt6 = stream2->lossBuffer.front();
|
auto& rt6 = stream2->lossBuffer.front();
|
||||||
expected = "ats up";
|
expected = "ats up";
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange((uint8_t*)expected.data(), expected.size()),
|
ByteRange((uint8_t*)expected.data(), expected.size()),
|
||||||
rt6.data.getHead()->getRange());
|
rt6.data.getHead()->getRange());
|
||||||
EXPECT_EQ(rt6.offset, 6);
|
EXPECT_EQ(rt6.offset, 6);
|
||||||
EXPECT_EQ(rt6.eof, 1);
|
EXPECT_EQ(rt6.eof, 1);
|
||||||
@@ -494,8 +493,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketRetrans) {
|
|||||||
auto& rt = *stream1->retransmissionBuffer.at(0);
|
auto& rt = *stream1->retransmissionBuffer.at(0);
|
||||||
EXPECT_EQ(rt.offset, 0);
|
EXPECT_EQ(rt.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf->data(), buf->length()),
|
ByteRange(buf->data(), buf->length()), rt.data.getHead()->getRange());
|
||||||
rt.data.getHead()->getRange());
|
|
||||||
EXPECT_TRUE(rt.eof);
|
EXPECT_TRUE(rt.eof);
|
||||||
stream1->lossBuffer.push_back(std::move(rt));
|
stream1->lossBuffer.push_back(std::move(rt));
|
||||||
}
|
}
|
||||||
@@ -504,8 +502,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketRetrans) {
|
|||||||
auto& rt = *stream2->retransmissionBuffer.at(0);
|
auto& rt = *stream2->retransmissionBuffer.at(0);
|
||||||
EXPECT_EQ(rt.offset, 0);
|
EXPECT_EQ(rt.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf->data(), buf->length()),
|
ByteRange(buf->data(), buf->length()), rt.data.getHead()->getRange());
|
||||||
rt.data.getHead()->getRange());
|
|
||||||
EXPECT_TRUE(rt.eof);
|
EXPECT_TRUE(rt.eof);
|
||||||
stream2->lossBuffer.push_back(std::move(rt));
|
stream2->lossBuffer.push_back(std::move(rt));
|
||||||
}
|
}
|
||||||
@@ -670,8 +667,7 @@ TEST_F(
|
|||||||
auto& rt = *stream1->retransmissionBuffer.at(0);
|
auto& rt = *stream1->retransmissionBuffer.at(0);
|
||||||
EXPECT_EQ(rt.offset, 0);
|
EXPECT_EQ(rt.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf->data(), buf->length()),
|
ByteRange(buf->data(), buf->length()), rt.data.getHead()->getRange());
|
||||||
rt.data.getHead()->getRange());
|
|
||||||
EXPECT_TRUE(rt.eof);
|
EXPECT_TRUE(rt.eof);
|
||||||
stream1->lossBuffer.push_back(std::move(rt));
|
stream1->lossBuffer.push_back(std::move(rt));
|
||||||
}
|
}
|
||||||
@@ -681,7 +677,7 @@ TEST_F(
|
|||||||
EXPECT_EQ(rt.offset, 0);
|
EXPECT_EQ(rt.offset, 0);
|
||||||
auto expectedBuf = IOBuf::copyBuffer("hey w");
|
auto expectedBuf = IOBuf::copyBuffer("hey w");
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(expectedBuf->data(), expectedBuf->length()),
|
ByteRange(expectedBuf->data(), expectedBuf->length()),
|
||||||
rt.data.getHead()->getRange());
|
rt.data.getHead()->getRange());
|
||||||
EXPECT_FALSE(rt.eof);
|
EXPECT_FALSE(rt.eof);
|
||||||
stream2->lossBuffer.push_back(std::move(rt));
|
stream2->lossBuffer.push_back(std::move(rt));
|
||||||
@@ -691,8 +687,7 @@ TEST_F(
|
|||||||
auto& rt = *stream3->retransmissionBuffer.at(0);
|
auto& rt = *stream3->retransmissionBuffer.at(0);
|
||||||
EXPECT_EQ(rt.offset, 0);
|
EXPECT_EQ(rt.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf->data(), buf->length()),
|
ByteRange(buf->data(), buf->length()), rt.data.getHead()->getRange());
|
||||||
rt.data.getHead()->getRange());
|
|
||||||
EXPECT_FALSE(rt.eof);
|
EXPECT_FALSE(rt.eof);
|
||||||
stream3->lossBuffer.push_back(std::move(rt));
|
stream3->lossBuffer.push_back(std::move(rt));
|
||||||
}
|
}
|
||||||
|
@@ -200,7 +200,7 @@ class TestQuicTransport
|
|||||||
|
|
||||||
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string&,
|
const std::string&,
|
||||||
const Optional<folly::ByteRange>&,
|
const Optional<ByteRange>&,
|
||||||
uint16_t) const override {
|
uint16_t) const override {
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
@@ -113,7 +113,7 @@ class QuicClientTransportLite
|
|||||||
*/
|
*/
|
||||||
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) const override {
|
uint16_t keyLength) const override {
|
||||||
return clientConn_->clientHandshakeLayer->getExportedKeyingMaterial(
|
return clientConn_->clientHandshakeLayer->getExportedKeyingMaterial(
|
||||||
label, context, keyLength);
|
label, context, keyLength);
|
||||||
|
@@ -153,7 +153,7 @@ bool ClientHandshake::waitingForData() const {
|
|||||||
return waitForData_;
|
return waitForData_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandshake::computeCiphers(CipherKind kind, folly::ByteRange secret) {
|
void ClientHandshake::computeCiphers(CipherKind kind, ByteRange secret) {
|
||||||
std::unique_ptr<Aead> aead = buildAead(kind, secret);
|
std::unique_ptr<Aead> aead = buildAead(kind, secret);
|
||||||
std::unique_ptr<PacketNumberCipher> packetNumberCipher =
|
std::unique_ptr<PacketNumberCipher> packetNumberCipher =
|
||||||
buildHeaderCipher(secret);
|
buildHeaderCipher(secret);
|
||||||
|
@@ -145,7 +145,7 @@ class ClientHandshake : public Handshake {
|
|||||||
ZeroRttWrite,
|
ZeroRttWrite,
|
||||||
};
|
};
|
||||||
|
|
||||||
void computeCiphers(CipherKind kind, folly::ByteRange secret);
|
void computeCiphers(CipherKind kind, ByteRange secret);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various utilities for concrete implementations to use.
|
* Various utilities for concrete implementations to use.
|
||||||
@@ -176,7 +176,7 @@ class ClientHandshake : public Handshake {
|
|||||||
* Given secret_n, returns secret_n+1 to be used for generating the next Aead
|
* Given secret_n, returns secret_n+1 to be used for generating the next Aead
|
||||||
* on key updates.
|
* on key updates.
|
||||||
*/
|
*/
|
||||||
virtual BufPtr getNextTrafficSecret(folly::ByteRange secret) const = 0;
|
virtual BufPtr getNextTrafficSecret(ByteRange secret) const = 0;
|
||||||
|
|
||||||
BufPtr readTrafficSecret_;
|
BufPtr readTrafficSecret_;
|
||||||
BufPtr writeTrafficSecret_;
|
BufPtr writeTrafficSecret_;
|
||||||
@@ -192,9 +192,9 @@ class ClientHandshake : public Handshake {
|
|||||||
virtual bool matchEarlyParameters() = 0;
|
virtual bool matchEarlyParameters() = 0;
|
||||||
virtual std::unique_ptr<Aead> buildAead(
|
virtual std::unique_ptr<Aead> buildAead(
|
||||||
CipherKind kind,
|
CipherKind kind,
|
||||||
folly::ByteRange secret) = 0;
|
ByteRange secret) = 0;
|
||||||
virtual std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
virtual std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
||||||
folly::ByteRange secret) = 0;
|
ByteRange secret) = 0;
|
||||||
|
|
||||||
// Represents the packet type that should be used to write the data currently
|
// Represents the packet type that should be used to write the data currently
|
||||||
// in the stream.
|
// in the stream.
|
||||||
|
@@ -62,7 +62,7 @@ class MockClientHandshake : public ClientHandshake {
|
|||||||
Optional<std::vector<uint8_t>>,
|
Optional<std::vector<uint8_t>>,
|
||||||
getExportedKeyingMaterial,
|
getExportedKeyingMaterial,
|
||||||
(const std::string& label,
|
(const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength),
|
uint16_t keyLength),
|
||||||
());
|
());
|
||||||
MOCK_METHOD(Optional<bool>, getZeroRttRejected, ());
|
MOCK_METHOD(Optional<bool>, getZeroRttRejected, ());
|
||||||
@@ -82,12 +82,12 @@ class MockClientHandshake : public ClientHandshake {
|
|||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
std::unique_ptr<Aead>,
|
std::unique_ptr<Aead>,
|
||||||
buildAead,
|
buildAead,
|
||||||
(ClientHandshake::CipherKind kind, folly::ByteRange secret));
|
(ClientHandshake::CipherKind kind, ByteRange secret));
|
||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
std::unique_ptr<PacketNumberCipher>,
|
std::unique_ptr<PacketNumberCipher>,
|
||||||
buildHeaderCipher,
|
buildHeaderCipher,
|
||||||
(folly::ByteRange secret));
|
(ByteRange secret));
|
||||||
MOCK_METHOD(BufPtr, getNextTrafficSecret, (folly::ByteRange secret), (const));
|
MOCK_METHOD(BufPtr, getNextTrafficSecret, (ByteRange secret), (const));
|
||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
const Optional<std::string>&,
|
const Optional<std::string>&,
|
||||||
getApplicationProtocol,
|
getApplicationProtocol,
|
||||||
|
@@ -50,7 +50,7 @@ folly::Expected<PaddingFrame, QuicError> decodePaddingFrame(
|
|||||||
// Let's consume all the padding and return 1 padding frame for everything.
|
// Let's consume all the padding and return 1 padding frame for everything.
|
||||||
static_assert(
|
static_assert(
|
||||||
static_cast<int>(FrameType::PADDING) == 0, "Padding value is 0");
|
static_cast<int>(FrameType::PADDING) == 0, "Padding value is 0");
|
||||||
folly::ByteRange paddingBytes = cursor.peekBytes();
|
ByteRange paddingBytes = cursor.peekBytes();
|
||||||
if (paddingBytes.size() == 0) {
|
if (paddingBytes.size() == 0) {
|
||||||
return PaddingFrame();
|
return PaddingFrame();
|
||||||
}
|
}
|
||||||
@@ -1337,7 +1337,7 @@ size_t parsePacketNumberLength(uint8_t initialByte) {
|
|||||||
*/
|
*/
|
||||||
std::pair<PacketNum, size_t> parsePacketNumber(
|
std::pair<PacketNum, size_t> parsePacketNumber(
|
||||||
uint8_t initialByte,
|
uint8_t initialByte,
|
||||||
folly::ByteRange packetNumberRange,
|
ByteRange packetNumberRange,
|
||||||
PacketNum expectedNextPacketNum) {
|
PacketNum expectedNextPacketNum) {
|
||||||
size_t packetNumLen = parsePacketNumberLength(initialByte);
|
size_t packetNumLen = parsePacketNumberLength(initialByte);
|
||||||
uint32_t encodedPacketNum = 0;
|
uint32_t encodedPacketNum = 0;
|
||||||
|
@@ -242,7 +242,7 @@ size_t parsePacketNumberLength(uint8_t initialByte);
|
|||||||
*/
|
*/
|
||||||
std::pair<PacketNum, size_t> parsePacketNumber(
|
std::pair<PacketNum, size_t> parsePacketNumber(
|
||||||
uint8_t initialByte,
|
uint8_t initialByte,
|
||||||
folly::ByteRange packetNumberRange,
|
ByteRange packetNumberRange,
|
||||||
PacketNum expectedNextPacketNum);
|
PacketNum expectedNextPacketNum);
|
||||||
|
|
||||||
// cursor: has to be point to the byte just past initialByte
|
// cursor: has to be point to the byte just past initialByte
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
namespace quic {
|
namespace quic {
|
||||||
|
|
||||||
void PacketNumberCipher::decipherHeader(
|
void PacketNumberCipher::decipherHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
folly::MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
@@ -31,7 +31,7 @@ void PacketNumberCipher::decipherHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PacketNumberCipher::cipherHeader(
|
void PacketNumberCipher::cipherHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
folly::MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
@@ -47,7 +47,7 @@ void PacketNumberCipher::cipherHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PacketNumberCipher::decryptLongHeader(
|
void PacketNumberCipher::decryptLongHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
folly::MutableByteRange packetNumberBytes) const {
|
||||||
decipherHeader(
|
decipherHeader(
|
||||||
@@ -59,7 +59,7 @@ void PacketNumberCipher::decryptLongHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PacketNumberCipher::decryptShortHeader(
|
void PacketNumberCipher::decryptShortHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
folly::MutableByteRange packetNumberBytes) const {
|
||||||
decipherHeader(
|
decipherHeader(
|
||||||
@@ -71,7 +71,7 @@ void PacketNumberCipher::decryptShortHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PacketNumberCipher::encryptLongHeader(
|
void PacketNumberCipher::encryptLongHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
folly::MutableByteRange packetNumberBytes) const {
|
||||||
cipherHeader(
|
cipherHeader(
|
||||||
@@ -83,7 +83,7 @@ void PacketNumberCipher::encryptLongHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PacketNumberCipher::encryptShortHeader(
|
void PacketNumberCipher::encryptShortHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
folly::MutableByteRange packetNumberBytes) const {
|
||||||
cipherHeader(
|
cipherHeader(
|
||||||
|
@@ -20,9 +20,9 @@ class PacketNumberCipher {
|
|||||||
public:
|
public:
|
||||||
virtual ~PacketNumberCipher() = default;
|
virtual ~PacketNumberCipher() = default;
|
||||||
|
|
||||||
virtual void setKey(folly::ByteRange key) = 0;
|
virtual void setKey(ByteRange key) = 0;
|
||||||
|
|
||||||
virtual HeaderProtectionMask mask(folly::ByteRange sample) const = 0;
|
virtual HeaderProtectionMask mask(ByteRange sample) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts a long header from a sample.
|
* Decrypts a long header from a sample.
|
||||||
@@ -31,7 +31,7 @@ class PacketNumberCipher {
|
|||||||
* packetNumberBytes should be supplied with at least 4 bytes.
|
* packetNumberBytes should be supplied with at least 4 bytes.
|
||||||
*/
|
*/
|
||||||
virtual void decryptLongHeader(
|
virtual void decryptLongHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
folly::MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class PacketNumberCipher {
|
|||||||
* packetNumberBytes should be supplied with at least 4 bytes.
|
* packetNumberBytes should be supplied with at least 4 bytes.
|
||||||
*/
|
*/
|
||||||
virtual void decryptShortHeader(
|
virtual void decryptShortHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
folly::MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ class PacketNumberCipher {
|
|||||||
* initialByte is the initial byte.
|
* initialByte is the initial byte.
|
||||||
*/
|
*/
|
||||||
virtual void encryptLongHeader(
|
virtual void encryptLongHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
folly::MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class PacketNumberCipher {
|
|||||||
* initialByte is the initial byte.
|
* initialByte is the initial byte.
|
||||||
*/
|
*/
|
||||||
virtual void encryptShortHeader(
|
virtual void encryptShortHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
folly::MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
@@ -78,14 +78,14 @@ class PacketNumberCipher {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void cipherHeader(
|
virtual void cipherHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
folly::MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
uint8_t packetNumLengthMask) const;
|
uint8_t packetNumLengthMask) const;
|
||||||
|
|
||||||
virtual void decipherHeader(
|
virtual void decipherHeader(
|
||||||
folly::ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
folly::MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
folly::MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
|
@@ -25,7 +25,7 @@ uint8_t ConnectionId::size() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string ConnectionId::hex() const {
|
std::string ConnectionId::hex() const {
|
||||||
return folly::hexlify(folly::ByteRange(connid.data(), connidLen));
|
return folly::hexlify(ByteRange(connid.data(), connidLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionId::ConnectionId(const std::vector<uint8_t>& connidIn) {
|
ConnectionId::ConnectionId(const std::vector<uint8_t>& connidIn) {
|
||||||
|
@@ -290,8 +290,7 @@ CodecResult QuicReadCodec::tryParseShortHeaderPacket(
|
|||||||
folly::MutableByteRange initialByteRange(data->writableData(), 1);
|
folly::MutableByteRange initialByteRange(data->writableData(), 1);
|
||||||
folly::MutableByteRange packetNumberByteRange(
|
folly::MutableByteRange packetNumberByteRange(
|
||||||
data->writableData() + packetNumberOffset, kMaxPacketNumEncodingSize);
|
data->writableData() + packetNumberOffset, kMaxPacketNumEncodingSize);
|
||||||
folly::ByteRange sampleByteRange(
|
ByteRange sampleByteRange(data->writableData() + sampleOffset, sample.size());
|
||||||
data->writableData() + sampleOffset, sample.size());
|
|
||||||
|
|
||||||
oneRttHeaderCipher_->decryptShortHeader(
|
oneRttHeaderCipher_->decryptShortHeader(
|
||||||
sampleByteRange, initialByteRange, packetNumberByteRange);
|
sampleByteRange, initialByteRange, packetNumberByteRange);
|
||||||
@@ -447,8 +446,8 @@ CodecResult QuicReadCodec::parsePacket(
|
|||||||
}
|
}
|
||||||
// Only allocate & copy the token if it matches the token we have
|
// Only allocate & copy the token if it matches the token we have
|
||||||
if (cryptoEqual_(
|
if (cryptoEqual_(
|
||||||
folly::ByteRange(tokenSource, sizeof(StatelessResetToken)),
|
ByteRange(tokenSource, sizeof(StatelessResetToken)),
|
||||||
folly::ByteRange(
|
ByteRange(
|
||||||
statelessResetToken_->data(), sizeof(StatelessResetToken)))) {
|
statelessResetToken_->data(), sizeof(StatelessResetToken)))) {
|
||||||
token = StatelessResetToken();
|
token = StatelessResetToken();
|
||||||
memcpy(token->data(), tokenSource, token->size());
|
memcpy(token->data(), tokenSource, token->size());
|
||||||
@@ -569,7 +568,7 @@ void QuicReadCodec::setStatelessResetToken(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuicReadCodec::setCryptoEqual(
|
void QuicReadCodec::setCryptoEqual(
|
||||||
std::function<bool(folly::ByteRange, folly::ByteRange)> cryptoEqual) {
|
std::function<bool(ByteRange, ByteRange)> cryptoEqual) {
|
||||||
cryptoEqual_ = std::move(cryptoEqual);
|
cryptoEqual_ = std::move(cryptoEqual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -166,8 +166,7 @@ class QuicReadCodec {
|
|||||||
void setClientConnectionId(ConnectionId connId);
|
void setClientConnectionId(ConnectionId connId);
|
||||||
void setServerConnectionId(ConnectionId connId);
|
void setServerConnectionId(ConnectionId connId);
|
||||||
void setStatelessResetToken(StatelessResetToken statelessResetToken);
|
void setStatelessResetToken(StatelessResetToken statelessResetToken);
|
||||||
void setCryptoEqual(
|
void setCryptoEqual(std::function<bool(ByteRange, ByteRange)> cryptoEqual);
|
||||||
std::function<bool(folly::ByteRange, folly::ByteRange)> cryptoEqual);
|
|
||||||
const ConnectionId& getClientConnectionId() const;
|
const ConnectionId& getClientConnectionId() const;
|
||||||
const ConnectionId& getServerConnectionId() const;
|
const ConnectionId& getServerConnectionId() const;
|
||||||
|
|
||||||
@@ -237,7 +236,7 @@ class QuicReadCodec {
|
|||||||
std::unique_ptr<PacketNumberCipher> handshakeHeaderCipher_;
|
std::unique_ptr<PacketNumberCipher> handshakeHeaderCipher_;
|
||||||
|
|
||||||
Optional<StatelessResetToken> statelessResetToken_;
|
Optional<StatelessResetToken> statelessResetToken_;
|
||||||
std::function<bool(folly::ByteRange, folly::ByteRange)> cryptoEqual_;
|
std::function<bool(ByteRange, ByteRange)> cryptoEqual_;
|
||||||
Optional<TimePoint> handshakeDoneTime_;
|
Optional<TimePoint> handshakeDoneTime_;
|
||||||
|
|
||||||
QuicTransportStatsCallback* statsCallback_{nullptr};
|
QuicTransportStatsCallback* statsCallback_{nullptr};
|
||||||
|
@@ -127,7 +127,7 @@ ChainedByteRangeHead ChainedByteRangeHead::splitAtMost(size_t len) {
|
|||||||
if (head_.length() > len) {
|
if (head_.length() > len) {
|
||||||
// Just need to trim a little off the head.
|
// Just need to trim a little off the head.
|
||||||
ret.head_.range_ =
|
ret.head_.range_ =
|
||||||
folly::ByteRange(head_.range_.begin(), head_.range_.begin() + len);
|
ByteRange(head_.range_.begin(), head_.range_.begin() + len);
|
||||||
ret.head_.next_ = nullptr;
|
ret.head_.next_ = nullptr;
|
||||||
ret.tail_ = &ret.head_;
|
ret.tail_ = &ret.head_;
|
||||||
head_.trimStart(len);
|
head_.trimStart(len);
|
||||||
@@ -184,9 +184,9 @@ ChainedByteRangeHead ChainedByteRangeHead::splitAtMost(size_t len) {
|
|||||||
*/
|
*/
|
||||||
ret.head_.range_ = head_.range_;
|
ret.head_.range_ = head_.range_;
|
||||||
head_.range_ =
|
head_.range_ =
|
||||||
folly::ByteRange(current->range_.begin() + len, current->range_.end());
|
ByteRange(current->range_.begin() + len, current->range_.end());
|
||||||
current->range_ = folly::ByteRange(
|
current->range_ =
|
||||||
current->range_.begin(), current->range_.begin() + len);
|
ByteRange(current->range_.begin(), current->range_.begin() + len);
|
||||||
|
|
||||||
ret.head_.next_ = head_.next_;
|
ret.head_.next_ = head_.next_;
|
||||||
ret.tail_ = current;
|
ret.tail_ = current;
|
||||||
|
@@ -30,7 +30,7 @@ class ChainedByteRangeHead {
|
|||||||
public:
|
public:
|
||||||
ChainedByteRange() = default;
|
ChainedByteRange() = default;
|
||||||
|
|
||||||
explicit ChainedByteRange(folly::ByteRange range) : range_(range) {}
|
explicit ChainedByteRange(ByteRange range) : range_(range) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length only of this ChainedByteRange
|
* Returns the length only of this ChainedByteRange
|
||||||
@@ -47,7 +47,7 @@ class ChainedByteRangeHead {
|
|||||||
range_.advance(n);
|
range_.advance(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] folly::ByteRange getRange() const {
|
[[nodiscard]] ByteRange getRange() const {
|
||||||
return range_;
|
return range_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class ChainedByteRangeHead {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
folly::ByteRange range_;
|
ByteRange range_;
|
||||||
ChainedByteRange* next_{nullptr};
|
ChainedByteRange* next_{nullptr};
|
||||||
friend class ChainedByteRangeHead;
|
friend class ChainedByteRangeHead;
|
||||||
};
|
};
|
||||||
|
@@ -778,7 +778,7 @@ FizzCryptoTestFactory::makePacketNumberCipher(fizz::CipherSuite) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher>
|
std::unique_ptr<PacketNumberCipher>
|
||||||
FizzCryptoTestFactory::makePacketNumberCipher(folly::ByteRange secret) const {
|
FizzCryptoTestFactory::makePacketNumberCipher(ByteRange secret) const {
|
||||||
return _makePacketNumberCipher(secret);
|
return _makePacketNumberCipher(secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,7 +789,7 @@ void FizzCryptoTestFactory::setMockPacketNumberCipher(
|
|||||||
|
|
||||||
void FizzCryptoTestFactory::setDefault() {
|
void FizzCryptoTestFactory::setDefault() {
|
||||||
ON_CALL(*this, _makePacketNumberCipher(_))
|
ON_CALL(*this, _makePacketNumberCipher(_))
|
||||||
.WillByDefault(Invoke([&](folly::ByteRange secret) {
|
.WillByDefault(Invoke([&](ByteRange secret) {
|
||||||
return FizzCryptoFactory::makePacketNumberCipher(secret);
|
return FizzCryptoFactory::makePacketNumberCipher(secret);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@@ -354,11 +354,11 @@ class FizzCryptoTestFactory : public FizzCryptoFactory {
|
|||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
std::unique_ptr<PacketNumberCipher>,
|
std::unique_ptr<PacketNumberCipher>,
|
||||||
_makePacketNumberCipher,
|
_makePacketNumberCipher,
|
||||||
(folly::ByteRange),
|
(ByteRange),
|
||||||
(const));
|
(const));
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
||||||
folly::ByteRange secret) const override;
|
ByteRange secret) const override;
|
||||||
|
|
||||||
void setMockPacketNumberCipher(
|
void setMockPacketNumberCipher(
|
||||||
std::unique_ptr<PacketNumberCipher> packetNumberCipher);
|
std::unique_ptr<PacketNumberCipher> packetNumberCipher);
|
||||||
@@ -553,11 +553,11 @@ class FakeServerHandshake : public FizzServerHandshake {
|
|||||||
writeTrafficSecret_ = folly::IOBuf::copyBuffer(getRandSecret());
|
writeTrafficSecret_ = folly::IOBuf::copyBuffer(getRandSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Aead> buildAead(folly::ByteRange /*secret*/) override {
|
std::unique_ptr<Aead> buildAead(ByteRange /*secret*/) override {
|
||||||
return createNoOpAead();
|
return createNoOpAead();
|
||||||
}
|
}
|
||||||
|
|
||||||
BufPtr getNextTrafficSecret(folly::ByteRange /*secret*/) const override {
|
BufPtr getNextTrafficSecret(ByteRange /*secret*/) const override {
|
||||||
return folly::IOBuf::copyBuffer(getRandSecret());
|
return folly::IOBuf::copyBuffer(getRandSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -140,7 +140,7 @@ bool FizzClientHandshake::isTLSResumed() const {
|
|||||||
|
|
||||||
Optional<std::vector<uint8_t>> FizzClientHandshake::getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> FizzClientHandshake::getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) {
|
uint16_t keyLength) {
|
||||||
const auto& ems = state_.exporterMasterSecret();
|
const auto& ems = state_.exporterMasterSecret();
|
||||||
const auto cipherSuite = state_.cipher();
|
const auto cipherSuite = state_.cipher();
|
||||||
@@ -176,7 +176,7 @@ bool FizzClientHandshake::matchEarlyParameters() {
|
|||||||
|
|
||||||
std::unique_ptr<Aead> FizzClientHandshake::buildAead(
|
std::unique_ptr<Aead> FizzClientHandshake::buildAead(
|
||||||
CipherKind kind,
|
CipherKind kind,
|
||||||
folly::ByteRange secret) {
|
ByteRange secret) {
|
||||||
bool isEarlyTraffic = kind == CipherKind::ZeroRttWrite;
|
bool isEarlyTraffic = kind == CipherKind::ZeroRttWrite;
|
||||||
fizz::CipherSuite cipher =
|
fizz::CipherSuite cipher =
|
||||||
isEarlyTraffic ? state_.earlyDataParams()->cipher : *state_.cipher();
|
isEarlyTraffic ? state_.earlyDataParams()->cipher : *state_.cipher();
|
||||||
@@ -198,12 +198,11 @@ std::unique_ptr<Aead> FizzClientHandshake::buildAead(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher> FizzClientHandshake::buildHeaderCipher(
|
std::unique_ptr<PacketNumberCipher> FizzClientHandshake::buildHeaderCipher(
|
||||||
folly::ByteRange secret) {
|
ByteRange secret) {
|
||||||
return cryptoFactory_->makePacketNumberCipher(secret);
|
return cryptoFactory_->makePacketNumberCipher(secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufPtr FizzClientHandshake::getNextTrafficSecret(
|
BufPtr FizzClientHandshake::getNextTrafficSecret(ByteRange secret) const {
|
||||||
folly::ByteRange secret) const {
|
|
||||||
auto deriver =
|
auto deriver =
|
||||||
state_.context()->getFactory()->makeKeyDeriver(*state_.cipher());
|
state_.context()->getFactory()->makeKeyDeriver(*state_.cipher());
|
||||||
auto nextSecret = deriver->expandLabel(
|
auto nextSecret = deriver->expandLabel(
|
||||||
|
@@ -41,7 +41,7 @@ class FizzClientHandshake : public ClientHandshake {
|
|||||||
|
|
||||||
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) override;
|
uint16_t keyLength) override;
|
||||||
|
|
||||||
const fizz::client::State& getState() const {
|
const fizz::client::State& getState() const {
|
||||||
@@ -75,11 +75,10 @@ class FizzClientHandshake : public ClientHandshake {
|
|||||||
EncryptionLevel getReadRecordLayerEncryptionLevel() override;
|
EncryptionLevel getReadRecordLayerEncryptionLevel() override;
|
||||||
void processSocketData(folly::IOBufQueue& queue) override;
|
void processSocketData(folly::IOBufQueue& queue) override;
|
||||||
bool matchEarlyParameters() override;
|
bool matchEarlyParameters() override;
|
||||||
std::unique_ptr<Aead> buildAead(CipherKind kind, folly::ByteRange secret)
|
std::unique_ptr<Aead> buildAead(CipherKind kind, ByteRange secret) override;
|
||||||
override;
|
|
||||||
std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
||||||
folly::ByteRange secret) override;
|
ByteRange secret) override;
|
||||||
BufPtr getNextTrafficSecret(folly::ByteRange secret) const override;
|
BufPtr getNextTrafficSecret(ByteRange secret) const override;
|
||||||
|
|
||||||
class ActionMoveVisitor;
|
class ActionMoveVisitor;
|
||||||
void processActions(fizz::client::Actions actions);
|
void processActions(fizz::client::Actions actions);
|
||||||
|
@@ -314,7 +314,7 @@ TEST_F(ClientHandshakeTest, TestGetExportedKeyingMaterial) {
|
|||||||
EXPECT_EQ(ekm->size(), 32);
|
EXPECT_EQ(ekm->size(), 32);
|
||||||
|
|
||||||
ekm = handshake->getExportedKeyingMaterial(
|
ekm = handshake->getExportedKeyingMaterial(
|
||||||
"EXPORTER-Some-Label", folly::ByteRange(), 32);
|
"EXPORTER-Some-Label", ByteRange(), 32);
|
||||||
ASSERT_TRUE(ekm.has_value());
|
ASSERT_TRUE(ekm.has_value());
|
||||||
EXPECT_EQ(ekm->size(), 32);
|
EXPECT_EQ(ekm->size(), 32);
|
||||||
}
|
}
|
||||||
|
@@ -329,7 +329,7 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake {
|
|||||||
return params_;
|
return params_;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufPtr getNextTrafficSecret(folly::ByteRange /*secret*/) const override {
|
BufPtr getNextTrafficSecret(ByteRange /*secret*/) const override {
|
||||||
return folly::IOBuf::copyBuffer(getRandSecret());
|
return folly::IOBuf::copyBuffer(getRandSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,12 +382,11 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake {
|
|||||||
throw std::runtime_error("matchEarlyParameters not implemented");
|
throw std::runtime_error("matchEarlyParameters not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Aead> buildAead(CipherKind, folly::ByteRange) override {
|
std::unique_ptr<Aead> buildAead(CipherKind, ByteRange) override {
|
||||||
return createNoOpAead();
|
return createNoOpAead();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
std::unique_ptr<PacketNumberCipher> buildHeaderCipher(ByteRange) override {
|
||||||
folly::ByteRange) override {
|
|
||||||
throw std::runtime_error("buildHeaderCipher not implemented");
|
throw std::runtime_error("buildHeaderCipher not implemented");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -405,7 +404,7 @@ class QuicClientTransportTestBase : public virtual testing::Test {
|
|||||||
folly::SocketAddress addr;
|
folly::SocketAddress addr;
|
||||||
Optional<int> err;
|
Optional<int> err;
|
||||||
|
|
||||||
TestReadData(folly::ByteRange dataIn, folly::SocketAddress addrIn)
|
TestReadData(ByteRange dataIn, folly::SocketAddress addrIn)
|
||||||
: udpPacket(folly::IOBuf::copyBuffer(dataIn)),
|
: udpPacket(folly::IOBuf::copyBuffer(dataIn)),
|
||||||
addr(std::move(addrIn)) {}
|
addr(std::move(addrIn)) {}
|
||||||
|
|
||||||
@@ -799,7 +798,7 @@ class QuicClientTransportTestBase : public virtual testing::Test {
|
|||||||
|
|
||||||
void deliverDataWithoutErrorCheck(
|
void deliverDataWithoutErrorCheck(
|
||||||
const folly::SocketAddress& addr,
|
const folly::SocketAddress& addr,
|
||||||
folly::ByteRange data,
|
ByteRange data,
|
||||||
bool writes = true) {
|
bool writes = true) {
|
||||||
ASSERT_TRUE(networkReadCallback);
|
ASSERT_TRUE(networkReadCallback);
|
||||||
socketReads.emplace_back(data, addr);
|
socketReads.emplace_back(data, addr);
|
||||||
@@ -810,7 +809,7 @@ class QuicClientTransportTestBase : public virtual testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deliverDataWithoutErrorCheck(
|
void deliverDataWithoutErrorCheck(
|
||||||
folly::ByteRange data,
|
ByteRange data,
|
||||||
bool writes = true,
|
bool writes = true,
|
||||||
folly::SocketAddress* peer = nullptr) {
|
folly::SocketAddress* peer = nullptr) {
|
||||||
deliverDataWithoutErrorCheck(
|
deliverDataWithoutErrorCheck(
|
||||||
@@ -831,7 +830,7 @@ class QuicClientTransportTestBase : public virtual testing::Test {
|
|||||||
|
|
||||||
void deliverData(
|
void deliverData(
|
||||||
const folly::SocketAddress& addr,
|
const folly::SocketAddress& addr,
|
||||||
folly::ByteRange data,
|
ByteRange data,
|
||||||
bool writes = true) {
|
bool writes = true) {
|
||||||
deliverDataWithoutErrorCheck(addr, data, writes);
|
deliverDataWithoutErrorCheck(addr, data, writes);
|
||||||
if (client->getConn().localConnectionError) {
|
if (client->getConn().localConnectionError) {
|
||||||
@@ -849,7 +848,7 @@ class QuicClientTransportTestBase : public virtual testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deliverData(
|
void deliverData(
|
||||||
folly::ByteRange data,
|
ByteRange data,
|
||||||
bool writes = true,
|
bool writes = true,
|
||||||
folly::SocketAddress* peer = nullptr) {
|
folly::SocketAddress* peer = nullptr) {
|
||||||
deliverData(peer == nullptr ? serverAddr : *peer, data, writes);
|
deliverData(peer == nullptr ? serverAddr : *peer, data, writes);
|
||||||
|
@@ -57,7 +57,7 @@ std::unique_ptr<Aead> FizzCryptoFactory::makeInitialAead(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher> FizzCryptoFactory::makePacketNumberCipher(
|
std::unique_ptr<PacketNumberCipher> FizzCryptoFactory::makePacketNumberCipher(
|
||||||
folly::ByteRange baseSecret) const {
|
ByteRange baseSecret) const {
|
||||||
auto pnCipher =
|
auto pnCipher =
|
||||||
makePacketNumberCipher(fizz::CipherSuite::TLS_AES_128_GCM_SHA256);
|
makePacketNumberCipher(fizz::CipherSuite::TLS_AES_128_GCM_SHA256);
|
||||||
auto deriver =
|
auto deriver =
|
||||||
@@ -80,7 +80,7 @@ std::unique_ptr<PacketNumberCipher> FizzCryptoFactory::makePacketNumberCipher(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<bool(folly::ByteRange, folly::ByteRange)>
|
std::function<bool(ByteRange, ByteRange)>
|
||||||
FizzCryptoFactory::getCryptoEqualFunction() const {
|
FizzCryptoFactory::getCryptoEqualFunction() const {
|
||||||
return fizz::CryptoUtils::equal;
|
return fizz::CryptoUtils::equal;
|
||||||
}
|
}
|
||||||
|
@@ -27,12 +27,12 @@ class FizzCryptoFactory : public CryptoFactory {
|
|||||||
QuicVersion version) const override;
|
QuicVersion version) const override;
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
||||||
folly::ByteRange baseSecret) const override;
|
ByteRange baseSecret) const override;
|
||||||
|
|
||||||
virtual std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
virtual std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
||||||
fizz::CipherSuite cipher) const;
|
fizz::CipherSuite cipher) const;
|
||||||
|
|
||||||
[[nodiscard]] std::function<bool(folly::ByteRange, folly::ByteRange)>
|
[[nodiscard]] std::function<bool(ByteRange, ByteRange)>
|
||||||
getCryptoEqualFunction() const override;
|
getCryptoEqualFunction() const override;
|
||||||
|
|
||||||
std::shared_ptr<fizz::Factory> getFizzFactory() {
|
std::shared_ptr<fizz::Factory> getFizzFactory() {
|
||||||
|
@@ -12,7 +12,7 @@ namespace quic {
|
|||||||
static void setKeyImpl(
|
static void setKeyImpl(
|
||||||
folly::ssl::EvpCipherCtxUniquePtr& context,
|
folly::ssl::EvpCipherCtxUniquePtr& context,
|
||||||
const EVP_CIPHER* cipher,
|
const EVP_CIPHER* cipher,
|
||||||
folly::ByteRange key) {
|
ByteRange key) {
|
||||||
DCHECK_EQ(key.size(), EVP_CIPHER_key_length(cipher));
|
DCHECK_EQ(key.size(), EVP_CIPHER_key_length(cipher));
|
||||||
context.reset(EVP_CIPHER_CTX_new());
|
context.reset(EVP_CIPHER_CTX_new());
|
||||||
if (context == nullptr) {
|
if (context == nullptr) {
|
||||||
@@ -26,7 +26,7 @@ static void setKeyImpl(
|
|||||||
|
|
||||||
static HeaderProtectionMask maskImpl(
|
static HeaderProtectionMask maskImpl(
|
||||||
const folly::ssl::EvpCipherCtxUniquePtr& context,
|
const folly::ssl::EvpCipherCtxUniquePtr& context,
|
||||||
folly::ByteRange sample) {
|
ByteRange sample) {
|
||||||
HeaderProtectionMask outMask;
|
HeaderProtectionMask outMask;
|
||||||
CHECK_EQ(sample.size(), outMask.size());
|
CHECK_EQ(sample.size(), outMask.size());
|
||||||
int outLen = 0;
|
int outLen = 0;
|
||||||
@@ -42,12 +42,12 @@ static HeaderProtectionMask maskImpl(
|
|||||||
return outMask;
|
return outMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aes128PacketNumberCipher::setKey(folly::ByteRange key) {
|
void Aes128PacketNumberCipher::setKey(ByteRange key) {
|
||||||
pnKey_ = BufHelpers::copyBuffer(key);
|
pnKey_ = BufHelpers::copyBuffer(key);
|
||||||
return setKeyImpl(encryptCtx_, EVP_aes_128_ecb(), key);
|
return setKeyImpl(encryptCtx_, EVP_aes_128_ecb(), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aes256PacketNumberCipher::setKey(folly::ByteRange key) {
|
void Aes256PacketNumberCipher::setKey(ByteRange key) {
|
||||||
pnKey_ = BufHelpers::copyBuffer(key);
|
pnKey_ = BufHelpers::copyBuffer(key);
|
||||||
return setKeyImpl(encryptCtx_, EVP_aes_256_ecb(), key);
|
return setKeyImpl(encryptCtx_, EVP_aes_256_ecb(), key);
|
||||||
}
|
}
|
||||||
@@ -60,13 +60,11 @@ const BufPtr& Aes256PacketNumberCipher::getKey() const {
|
|||||||
return pnKey_;
|
return pnKey_;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeaderProtectionMask Aes128PacketNumberCipher::mask(
|
HeaderProtectionMask Aes128PacketNumberCipher::mask(ByteRange sample) const {
|
||||||
folly::ByteRange sample) const {
|
|
||||||
return maskImpl(encryptCtx_, sample);
|
return maskImpl(encryptCtx_, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeaderProtectionMask Aes256PacketNumberCipher::mask(
|
HeaderProtectionMask Aes256PacketNumberCipher::mask(ByteRange sample) const {
|
||||||
folly::ByteRange sample) const {
|
|
||||||
return maskImpl(encryptCtx_, sample);
|
return maskImpl(encryptCtx_, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,11 +17,11 @@ class Aes128PacketNumberCipher : public PacketNumberCipher {
|
|||||||
public:
|
public:
|
||||||
~Aes128PacketNumberCipher() override = default;
|
~Aes128PacketNumberCipher() override = default;
|
||||||
|
|
||||||
void setKey(folly::ByteRange key) override;
|
void setKey(ByteRange key) override;
|
||||||
|
|
||||||
const BufPtr& getKey() const override;
|
const BufPtr& getKey() const override;
|
||||||
|
|
||||||
HeaderProtectionMask mask(folly::ByteRange sample) const override;
|
HeaderProtectionMask mask(ByteRange sample) const override;
|
||||||
|
|
||||||
size_t keyLength() const override;
|
size_t keyLength() const override;
|
||||||
|
|
||||||
@@ -35,11 +35,11 @@ class Aes256PacketNumberCipher : public PacketNumberCipher {
|
|||||||
public:
|
public:
|
||||||
~Aes256PacketNumberCipher() override = default;
|
~Aes256PacketNumberCipher() override = default;
|
||||||
|
|
||||||
void setKey(folly::ByteRange key) override;
|
void setKey(ByteRange key) override;
|
||||||
|
|
||||||
const BufPtr& getKey() const override;
|
const BufPtr& getKey() const override;
|
||||||
|
|
||||||
HeaderProtectionMask mask(folly::ByteRange sample) const override;
|
HeaderProtectionMask mask(ByteRange sample) const override;
|
||||||
|
|
||||||
size_t keyLength() const override;
|
size_t keyLength() const override;
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ class FizzCryptoFactoryTest : public Test {
|
|||||||
std::unique_ptr<MockPacketNumberCipher> createMockPacketNumberCipher() {
|
std::unique_ptr<MockPacketNumberCipher> createMockPacketNumberCipher() {
|
||||||
auto mockPacketNumberCipher = std::make_unique<MockPacketNumberCipher>();
|
auto mockPacketNumberCipher = std::make_unique<MockPacketNumberCipher>();
|
||||||
EXPECT_CALL(*mockPacketNumberCipher, setKey(_))
|
EXPECT_CALL(*mockPacketNumberCipher, setKey(_))
|
||||||
.WillOnce(Invoke([&](folly::ByteRange key) {
|
.WillOnce(Invoke([&](ByteRange key) {
|
||||||
packetCipherKey_ = folly::IOBuf::copyBuffer(key);
|
packetCipherKey_ = folly::IOBuf::copyBuffer(key);
|
||||||
}));
|
}));
|
||||||
EXPECT_CALL(*mockPacketNumberCipher, keyLength())
|
EXPECT_CALL(*mockPacketNumberCipher, keyLength())
|
||||||
|
@@ -87,7 +87,7 @@ void FizzServerHandshake::processSocketData(folly::IOBufQueue& queue) {
|
|||||||
machine_.processSocketData(state_, queue, fizz::Aead::AeadOptions()));
|
machine_.processSocketData(state_, queue, fizz::Aead::AeadOptions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Aead> FizzServerHandshake::buildAead(folly::ByteRange secret) {
|
std::unique_ptr<Aead> FizzServerHandshake::buildAead(ByteRange secret) {
|
||||||
return FizzAead::wrap(fizz::Protocol::deriveRecordAeadWithLabel(
|
return FizzAead::wrap(fizz::Protocol::deriveRecordAeadWithLabel(
|
||||||
*state_.context()->getFactory(),
|
*state_.context()->getFactory(),
|
||||||
*state_.keyScheduler(),
|
*state_.keyScheduler(),
|
||||||
@@ -98,12 +98,11 @@ std::unique_ptr<Aead> FizzServerHandshake::buildAead(folly::ByteRange secret) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PacketNumberCipher> FizzServerHandshake::buildHeaderCipher(
|
std::unique_ptr<PacketNumberCipher> FizzServerHandshake::buildHeaderCipher(
|
||||||
folly::ByteRange secret) {
|
ByteRange secret) {
|
||||||
return cryptoFactory_->makePacketNumberCipher(secret);
|
return cryptoFactory_->makePacketNumberCipher(secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufPtr FizzServerHandshake::getNextTrafficSecret(
|
BufPtr FizzServerHandshake::getNextTrafficSecret(ByteRange secret) const {
|
||||||
folly::ByteRange secret) const {
|
|
||||||
auto deriver =
|
auto deriver =
|
||||||
state_.context()->getFactory()->makeKeyDeriver(*state_.cipher());
|
state_.context()->getFactory()->makeKeyDeriver(*state_.cipher());
|
||||||
auto nextSecret = deriver->expandLabel(
|
auto nextSecret = deriver->expandLabel(
|
||||||
|
@@ -39,10 +39,10 @@ class FizzServerHandshake : public ServerHandshake {
|
|||||||
|
|
||||||
EncryptionLevel getReadRecordLayerEncryptionLevel() override;
|
EncryptionLevel getReadRecordLayerEncryptionLevel() override;
|
||||||
void processSocketData(folly::IOBufQueue& queue) override;
|
void processSocketData(folly::IOBufQueue& queue) override;
|
||||||
std::unique_ptr<Aead> buildAead(folly::ByteRange secret) override;
|
std::unique_ptr<Aead> buildAead(ByteRange secret) override;
|
||||||
std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
||||||
folly::ByteRange secret) override;
|
ByteRange secret) override;
|
||||||
BufPtr getNextTrafficSecret(folly::ByteRange secret) const override;
|
BufPtr getNextTrafficSecret(ByteRange secret) const override;
|
||||||
|
|
||||||
void processAccept() override;
|
void processAccept() override;
|
||||||
bool processPendingCryptoEvent() override;
|
bool processPendingCryptoEvent() override;
|
||||||
|
@@ -62,9 +62,9 @@ class CryptoFactory {
|
|||||||
QuicVersion version) const = 0;
|
QuicVersion version) const = 0;
|
||||||
|
|
||||||
virtual std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
virtual std::unique_ptr<PacketNumberCipher> makePacketNumberCipher(
|
||||||
folly::ByteRange baseSecret) const = 0;
|
ByteRange baseSecret) const = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual std::function<bool(folly::ByteRange, folly::ByteRange)>
|
[[nodiscard]] virtual std::function<bool(ByteRange, ByteRange)>
|
||||||
getCryptoEqualFunction() const = 0;
|
getCryptoEqualFunction() const = 0;
|
||||||
|
|
||||||
virtual ~CryptoFactory() = default;
|
virtual ~CryptoFactory() = default;
|
||||||
|
@@ -48,7 +48,7 @@ class Handshake {
|
|||||||
*/
|
*/
|
||||||
virtual Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
virtual Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) = 0;
|
uint16_t keyLength) = 0;
|
||||||
|
|
||||||
virtual void handshakeConfirmed() {
|
virtual void handshakeConfirmed() {
|
||||||
|
@@ -23,8 +23,8 @@ class MockPacketNumberCipher : public PacketNumberCipher {
|
|||||||
public:
|
public:
|
||||||
virtual ~MockPacketNumberCipher() = default;
|
virtual ~MockPacketNumberCipher() = default;
|
||||||
|
|
||||||
MOCK_METHOD(void, setKey, (folly::ByteRange key));
|
MOCK_METHOD(void, setKey, (ByteRange key));
|
||||||
MOCK_METHOD(HeaderProtectionMask, mask, (folly::ByteRange), (const));
|
MOCK_METHOD(HeaderProtectionMask, mask, (ByteRange), (const));
|
||||||
MOCK_METHOD(size_t, keyLength, (), (const));
|
MOCK_METHOD(size_t, keyLength, (), (const));
|
||||||
MOCK_METHOD(const BufPtr&, getKey, (), (const));
|
MOCK_METHOD(const BufPtr&, getKey, (), (const));
|
||||||
|
|
||||||
|
@@ -87,7 +87,7 @@ void FileQLogger::writeToStream(folly::StringPiece message) {
|
|||||||
bool inputConsumed = false;
|
bool inputConsumed = false;
|
||||||
while (!inputConsumed) {
|
while (!inputConsumed) {
|
||||||
compressionBuffer_->clear();
|
compressionBuffer_->clear();
|
||||||
folly::ByteRange inputRange(message);
|
ByteRange inputRange(message);
|
||||||
auto outputRange = folly::MutableByteRange(
|
auto outputRange = folly::MutableByteRange(
|
||||||
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
||||||
compressionCodec_->compressStream(inputRange, outputRange);
|
compressionCodec_->compressStream(inputRange, outputRange);
|
||||||
@@ -148,7 +148,7 @@ void FileQLogger::finishStream() {
|
|||||||
bool ended = false;
|
bool ended = false;
|
||||||
while (!ended) {
|
while (!ended) {
|
||||||
compressionBuffer_->clear();
|
compressionBuffer_->clear();
|
||||||
folly::ByteRange inputRange(folly::StringPiece(""));
|
ByteRange inputRange(folly::StringPiece(""));
|
||||||
auto outputRange = folly::MutableByteRange(
|
auto outputRange = folly::MutableByteRange(
|
||||||
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
||||||
ended = compressionCodec_->compressStream(
|
ended = compressionCodec_->compressStream(
|
||||||
|
@@ -544,8 +544,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLoss) {
|
|||||||
auto& buffer = stream1->lossBuffer.front();
|
auto& buffer = stream1->lossBuffer.front();
|
||||||
EXPECT_EQ(buffer.offset, 0);
|
EXPECT_EQ(buffer.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf->data(), buf->length()),
|
ByteRange(buf->data(), buf->length()), buffer.data.getHead()->getRange());
|
||||||
buffer.data.getHead()->getRange());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool areEqual(folly::IOBuf* ptr, ChainedByteRangeHead* rch) {
|
bool areEqual(folly::IOBuf* ptr, ChainedByteRangeHead* rch) {
|
||||||
@@ -721,13 +720,13 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossNoMerge) {
|
|||||||
auto& buffer1 = stream1->lossBuffer[0];
|
auto& buffer1 = stream1->lossBuffer[0];
|
||||||
EXPECT_EQ(buffer1.offset, 0);
|
EXPECT_EQ(buffer1.offset, 0);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf1->data(), buf1->length()),
|
ByteRange(buf1->data(), buf1->length()),
|
||||||
buffer1.data.getHead()->getRange());
|
buffer1.data.getHead()->getRange());
|
||||||
|
|
||||||
auto& buffer3 = stream1->lossBuffer[1];
|
auto& buffer3 = stream1->lossBuffer[1];
|
||||||
EXPECT_EQ(buffer3.offset, 40);
|
EXPECT_EQ(buffer3.offset, 40);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
folly::ByteRange(buf3->data(), buf3->length()),
|
ByteRange(buf3->data(), buf3->length()),
|
||||||
buffer3.data.getHead()->getRange());
|
buffer3.data.getHead()->getRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2557,7 +2556,7 @@ TEST_F(QuicLossFunctionsTest, LossVisitorDSRTest) {
|
|||||||
ASSERT_FALSE(retxIter->second->eof);
|
ASSERT_FALSE(retxIter->second->eof);
|
||||||
auto expectedBuf = folly::IOBuf::copyBuffer("grape");
|
auto expectedBuf = folly::IOBuf::copyBuffer("grape");
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(
|
||||||
folly::ByteRange(expectedBuf->buffer(), expectedBuf->length()),
|
ByteRange(expectedBuf->buffer(), expectedBuf->length()),
|
||||||
retxIter->second->data.getHead()->getRange());
|
retxIter->second->data.getHead()->getRange());
|
||||||
ASSERT_EQ(stream->currentWriteOffset, bufMetaStartingOffset);
|
ASSERT_EQ(stream->currentWriteOffset, bufMetaStartingOffset);
|
||||||
|
|
||||||
|
@@ -181,7 +181,7 @@ class QuicServerTransport
|
|||||||
*/
|
*/
|
||||||
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) const override {
|
uint16_t keyLength) const override {
|
||||||
return serverConn_->serverHandshakeLayer->getExportedKeyingMaterial(
|
return serverConn_->serverHandshakeLayer->getExportedKeyingMaterial(
|
||||||
label, context, keyLength);
|
label, context, keyLength);
|
||||||
|
@@ -207,7 +207,7 @@ const fizz::server::State& ServerHandshake::getState() const {
|
|||||||
|
|
||||||
Optional<std::vector<uint8_t>> ServerHandshake::getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> ServerHandshake::getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) {
|
uint16_t keyLength) {
|
||||||
const auto cipherSuite = state_.cipher();
|
const auto cipherSuite = state_.cipher();
|
||||||
const auto& ems = state_.exporterMasterSecret();
|
const auto& ems = state_.exporterMasterSecret();
|
||||||
@@ -521,7 +521,7 @@ void ServerHandshake::processActions(
|
|||||||
processPendingEvents();
|
processPendingEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerHandshake::computeCiphers(CipherKind kind, folly::ByteRange secret) {
|
void ServerHandshake::computeCiphers(CipherKind kind, ByteRange secret) {
|
||||||
std::unique_ptr<Aead> aead = buildAead(secret);
|
std::unique_ptr<Aead> aead = buildAead(secret);
|
||||||
std::unique_ptr<PacketNumberCipher> headerCipher = buildHeaderCipher(secret);
|
std::unique_ptr<PacketNumberCipher> headerCipher = buildHeaderCipher(secret);
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
@@ -207,7 +207,7 @@ class ServerHandshake : public Handshake {
|
|||||||
*/
|
*/
|
||||||
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
|
||||||
const std::string& label,
|
const std::string& label,
|
||||||
const Optional<folly::ByteRange>& context,
|
const Optional<ByteRange>& context,
|
||||||
uint16_t keyLength) override;
|
uint16_t keyLength) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,7 +219,7 @@ class ServerHandshake : public Handshake {
|
|||||||
* Given secret_n, returns secret_n+1 to be used for generating the next Aead
|
* Given secret_n, returns secret_n+1 to be used for generating the next Aead
|
||||||
* on key updates.
|
* on key updates.
|
||||||
*/
|
*/
|
||||||
virtual BufPtr getNextTrafficSecret(folly::ByteRange secret) const = 0;
|
virtual BufPtr getNextTrafficSecret(ByteRange secret) const = 0;
|
||||||
|
|
||||||
~ServerHandshake() override = default;
|
~ServerHandshake() override = default;
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ class ServerHandshake : public Handshake {
|
|||||||
ZeroRttRead,
|
ZeroRttRead,
|
||||||
};
|
};
|
||||||
|
|
||||||
void computeCiphers(CipherKind kind, folly::ByteRange secret);
|
void computeCiphers(CipherKind kind, ByteRange secret);
|
||||||
|
|
||||||
fizz::server::State state_;
|
fizz::server::State state_;
|
||||||
fizz::server::ServerStateMachine machine_;
|
fizz::server::ServerStateMachine machine_;
|
||||||
@@ -321,9 +321,9 @@ class ServerHandshake : public Handshake {
|
|||||||
|
|
||||||
virtual EncryptionLevel getReadRecordLayerEncryptionLevel() = 0;
|
virtual EncryptionLevel getReadRecordLayerEncryptionLevel() = 0;
|
||||||
virtual void processSocketData(folly::IOBufQueue& queue) = 0;
|
virtual void processSocketData(folly::IOBufQueue& queue) = 0;
|
||||||
virtual std::unique_ptr<Aead> buildAead(folly::ByteRange secret) = 0;
|
virtual std::unique_ptr<Aead> buildAead(ByteRange secret) = 0;
|
||||||
virtual std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
virtual std::unique_ptr<PacketNumberCipher> buildHeaderCipher(
|
||||||
folly::ByteRange secret) = 0;
|
ByteRange secret) = 0;
|
||||||
|
|
||||||
virtual void processAccept() = 0;
|
virtual void processAccept() = 0;
|
||||||
/*
|
/*
|
||||||
|
@@ -20,7 +20,7 @@ const std::vector<std::string> kCipherContexts = {"RetryToken_V2"};
|
|||||||
namespace quic {
|
namespace quic {
|
||||||
|
|
||||||
TokenGenerator::TokenGenerator(TokenSecret secret) : cipher_(kCipherContexts) {
|
TokenGenerator::TokenGenerator(TokenSecret secret) : cipher_(kCipherContexts) {
|
||||||
std::vector<folly::ByteRange> secrets;
|
std::vector<ByteRange> secrets;
|
||||||
secrets.emplace_back(folly::range(secret));
|
secrets.emplace_back(folly::range(secret));
|
||||||
cipher_.setSecrets(secrets);
|
cipher_.setSecrets(secrets);
|
||||||
}
|
}
|
||||||
|
@@ -402,7 +402,7 @@ TEST_F(ServerHandshakeTest, TestGetExportedKeyingMaterial) {
|
|||||||
EXPECT_EQ(ekm->size(), 32);
|
EXPECT_EQ(ekm->size(), 32);
|
||||||
|
|
||||||
ekm = handshake->getExportedKeyingMaterial(
|
ekm = handshake->getExportedKeyingMaterial(
|
||||||
"EXPORTER-Some-Label", folly::ByteRange(), 32);
|
"EXPORTER-Some-Label", ByteRange(), 32);
|
||||||
ASSERT_TRUE(ekm.has_value());
|
ASSERT_TRUE(ekm.has_value());
|
||||||
EXPECT_EQ(ekm->size(), 32);
|
EXPECT_EQ(ekm->size(), 32);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user