Skip to content

Commit 40d3fa8

Browse files
committed
Add a bridge to fizz::Aead
1 parent ecd9ba7 commit 40d3fa8

25 files changed

+120
-106
lines changed

quic/api/QuicTransportFunctions.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ uint64_t writeQuicDataToSocket(
453453
QuicConnectionStateBase& connection,
454454
const ConnectionId& srcConnId,
455455
const ConnectionId& dstConnId,
456-
const fizz::Aead& aead,
456+
const Aead& aead,
457457
const PacketNumberCipher& headerCipher,
458458
QuicVersion version,
459459
uint64_t packetLimit) {
@@ -527,7 +527,7 @@ uint64_t writeCryptoAndAckDataToSocket(
527527
const ConnectionId& srcConnId,
528528
const ConnectionId& dstConnId,
529529
LongHeader::Types packetType,
530-
fizz::Aead& cleartextCipher,
530+
Aead& cleartextCipher,
531531
const PacketNumberCipher& headerCipher,
532532
QuicVersion version,
533533
uint64_t packetLimit,
@@ -572,7 +572,7 @@ uint64_t writeQuicDataExceptCryptoStreamToSocket(
572572
QuicConnectionStateBase& connection,
573573
const ConnectionId& srcConnId,
574574
const ConnectionId& dstConnId,
575-
const fizz::Aead& aead,
575+
const Aead& aead,
576576
const PacketNumberCipher& headerCipher,
577577
QuicVersion version,
578578
uint64_t packetLimit) {
@@ -640,7 +640,7 @@ uint64_t writeZeroRttDataToSocket(
640640
QuicConnectionStateBase& connection,
641641
const ConnectionId& srcConnId,
642642
const ConnectionId& dstConnId,
643-
const fizz::Aead& aead,
643+
const Aead& aead,
644644
const PacketNumberCipher& headerCipher,
645645
QuicVersion version,
646646
uint64_t packetLimit) {
@@ -688,7 +688,7 @@ void writeCloseCommon(
688688
QuicConnectionStateBase& connection,
689689
PacketHeader&& header,
690690
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
691-
const fizz::Aead& aead,
691+
const Aead& aead,
692692
const PacketNumberCipher& headerCipher) {
693693
// close is special, we're going to bypass all the packet sent logic for all
694694
// packets we send with a connection close frame.
@@ -773,7 +773,7 @@ void writeLongClose(
773773
const ConnectionId& dstConnId,
774774
LongHeader::Types headerType,
775775
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
776-
const fizz::Aead& aead,
776+
const Aead& aead,
777777
const PacketNumberCipher& headerCipher,
778778
QuicVersion version) {
779779
if (!connection.serverConnectionId) {
@@ -802,7 +802,7 @@ void writeShortClose(
802802
QuicConnectionStateBase& connection,
803803
const ConnectionId& connId,
804804
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
805-
const fizz::Aead& aead,
805+
const Aead& aead,
806806
const PacketNumberCipher& headerCipher) {
807807
auto header = ShortHeader(
808808
ProtectionType::KeyPhaseZero,
@@ -858,7 +858,7 @@ uint64_t writeConnectionDataToSocket(
858858
QuicPacketScheduler& scheduler,
859859
const WritableBytesFunc& writableBytesFunc,
860860
uint64_t packetLimit,
861-
const fizz::Aead& aead,
861+
const Aead& aead,
862862
const PacketNumberCipher& headerCipher,
863863
QuicVersion version,
864864
Buf token) {
@@ -961,7 +961,7 @@ uint64_t writeProbingDataToSocket(
961961
PacketNumberSpace pnSpace,
962962
FrameScheduler scheduler,
963963
uint8_t probesToSend,
964-
const fizz::Aead& aead,
964+
const Aead& aead,
965965
const PacketNumberCipher& headerCipher,
966966
QuicVersion version) {
967967
CloningScheduler cloningScheduler(

quic/api/QuicTransportFunctions.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ uint64_t writeQuicDataToSocket(
3939
QuicConnectionStateBase& connection,
4040
const ConnectionId& srcConnId,
4141
const ConnectionId& dstConnId,
42-
const fizz::Aead& aead,
42+
const Aead& aead,
4343
const PacketNumberCipher& headerCipher,
4444
QuicVersion version,
4545
uint64_t packetLimit);
@@ -55,7 +55,7 @@ uint64_t writeCryptoAndAckDataToSocket(
5555
const ConnectionId& srcConnId,
5656
const ConnectionId& dstConnId,
5757
LongHeader::Types packetType,
58-
fizz::Aead& cleartextCipher,
58+
Aead& cleartextCipher,
5959
const PacketNumberCipher& headerCipher,
6060
QuicVersion version,
6161
uint64_t packetLimit,
@@ -71,7 +71,7 @@ uint64_t writeQuicDataExceptCryptoStreamToSocket(
7171
QuicConnectionStateBase& connection,
7272
const ConnectionId& srcConnId,
7373
const ConnectionId& dstConnId,
74-
const fizz::Aead& aead,
74+
const Aead& aead,
7575
const PacketNumberCipher& headerCipher,
7676
QuicVersion version,
7777
uint64_t packetLimit);
@@ -85,7 +85,7 @@ uint64_t writeZeroRttDataToSocket(
8585
QuicConnectionStateBase& connection,
8686
const ConnectionId& srcConnId,
8787
const ConnectionId& dstConnId,
88-
const fizz::Aead& aead,
88+
const Aead& aead,
8989
const PacketNumberCipher& headerCipher,
9090
QuicVersion version,
9191
uint64_t packetLimit);
@@ -154,7 +154,7 @@ void writeCloseCommon(
154154
QuicConnectionStateBase& connection,
155155
PacketHeader&& header,
156156
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
157-
const fizz::Aead& aead,
157+
const Aead& aead,
158158
const PacketNumberCipher& headerCipher);
159159

160160
/**
@@ -168,7 +168,7 @@ void writeLongClose(
168168
const ConnectionId& dstConnId,
169169
LongHeader::Types headerType,
170170
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
171-
const fizz::Aead& aead,
171+
const Aead& aead,
172172
const PacketNumberCipher& headerCipher,
173173
QuicVersion);
174174

@@ -181,7 +181,7 @@ void writeShortClose(
181181
QuicConnectionStateBase& connection,
182182
const ConnectionId& connId,
183183
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
184-
const fizz::Aead& aead,
184+
const Aead& aead,
185185
const PacketNumberCipher& headerCipher);
186186

187187
/**
@@ -213,7 +213,7 @@ uint64_t writeConnectionDataToSocket(
213213
QuicPacketScheduler& scheduler,
214214
const WritableBytesFunc& writableBytesFunc,
215215
uint64_t packetLimit,
216-
const fizz::Aead& aead,
216+
const Aead& aead,
217217
const PacketNumberCipher& headerCipher,
218218
QuicVersion version,
219219
Buf token = nullptr);
@@ -227,7 +227,7 @@ uint64_t writeProbingDataToSocket(
227227
PacketNumberSpace pnSpace,
228228
FrameScheduler scheduler,
229229
uint8_t probesToSend,
230-
const fizz::Aead& aead,
230+
const Aead& aead,
231231
const PacketNumberCipher& headerCipher,
232232
QuicVersion version);
233233

quic/api/test/QuicTransportBaseTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class TestQuicTransport
332332
}
333333

334334
QuicServerConnectionState* transportConn;
335-
std::unique_ptr<fizz::Aead> aead;
335+
std::unique_ptr<Aead> aead;
336336
std::unique_ptr<PacketNumberCipher> headerCipher;
337337
std::unique_ptr<ConnectionIdAlgo> connIdAlgo_;
338338
bool transportClosed{false};

quic/api/test/QuicTransportFunctionsTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ uint64_t writeProbingDataToSocketForTest(
2828
folly::AsyncUDPSocket& sock,
2929
QuicConnectionStateBase& conn,
3030
uint8_t probesToSend,
31-
const fizz::Aead& aead,
31+
const Aead& aead,
3232
const PacketNumberCipher& headerCipher,
3333
QuicVersion version) {
3434
FrameScheduler scheduler = std::move(FrameScheduler::Builder(
@@ -57,7 +57,7 @@ void writeCryptoDataProbesToSocketForTest(
5757
folly::AsyncUDPSocket& sock,
5858
QuicConnectionStateBase& conn,
5959
uint8_t probesToSend,
60-
const fizz::Aead& aead,
60+
const Aead& aead,
6161
const PacketNumberCipher& headerCipher,
6262
QuicVersion version,
6363
LongHeader::Types type = LongHeader::Types::Initial) {
@@ -171,7 +171,7 @@ class QuicTransportFunctionsTest : public Test {
171171
return conn.version.value_or(*conn.originalVersion);
172172
}
173173

174-
std::unique_ptr<fizz::Aead> aead;
174+
std::unique_ptr<Aead> aead;
175175
std::unique_ptr<PacketNumberCipher> headerCipher;
176176
std::unique_ptr<MockQuicStats> transportInfoCb_;
177177
};

quic/api/test/QuicTransportTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class TestQuicTransport
138138
drainTimeoutExpired();
139139
}
140140

141-
std::unique_ptr<fizz::Aead> aead;
141+
std::unique_ptr<Aead> aead;
142142
std::unique_ptr<PacketNumberCipher> headerCipher;
143143
bool closed{false};
144144
};

quic/client/handshake/ClientHandshake.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,35 +90,35 @@ void ClientHandshake::doHandshake(
9090
}
9191
}
9292

93-
std::unique_ptr<fizz::Aead> ClientHandshake::getOneRttWriteCipher() {
93+
std::unique_ptr<Aead> ClientHandshake::getOneRttWriteCipher() {
9494
if (error_) {
9595
error_.throw_exception();
9696
}
9797
return std::move(oneRttWriteCipher_);
9898
}
9999

100-
std::unique_ptr<fizz::Aead> ClientHandshake::getOneRttReadCipher() {
100+
std::unique_ptr<Aead> ClientHandshake::getOneRttReadCipher() {
101101
if (error_) {
102102
error_.throw_exception();
103103
}
104104
return std::move(oneRttReadCipher_);
105105
}
106106

107-
std::unique_ptr<fizz::Aead> ClientHandshake::getZeroRttWriteCipher() {
107+
std::unique_ptr<Aead> ClientHandshake::getZeroRttWriteCipher() {
108108
if (error_) {
109109
error_.throw_exception();
110110
}
111111
return std::move(zeroRttWriteCipher_);
112112
}
113113

114-
std::unique_ptr<fizz::Aead> ClientHandshake::getHandshakeReadCipher() {
114+
std::unique_ptr<Aead> ClientHandshake::getHandshakeReadCipher() {
115115
if (error_) {
116116
error_.throw_exception();
117117
}
118118
return std::move(handshakeReadCipher_);
119119
}
120120

121-
std::unique_ptr<fizz::Aead> ClientHandshake::getHandshakeWriteCipher() {
121+
std::unique_ptr<Aead> ClientHandshake::getHandshakeWriteCipher() {
122122
if (error_) {
123123
error_.throw_exception();
124124
}

quic/client/handshake/ClientHandshake.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,31 @@ class ClientHandshake : public Handshake {
6565
* An edge triggered API to get the oneRttWriteCipher. Once you receive the
6666
* write cipher subsequent calls will return null.
6767
*/
68-
std::unique_ptr<fizz::Aead> getOneRttWriteCipher();
68+
std::unique_ptr<Aead> getOneRttWriteCipher();
6969

7070
/**
7171
* An edge triggered API to get the oneRttReadCipher. Once you receive the
7272
* read cipher subsequent calls will return null.
7373
*/
74-
std::unique_ptr<fizz::Aead> getOneRttReadCipher();
74+
std::unique_ptr<Aead> getOneRttReadCipher();
7575

7676
/**
7777
* An edge triggered API to get the zeroRttWriteCipher. Once you receive the
7878
* zero rtt write cipher subsequent calls will return null.
7979
*/
80-
std::unique_ptr<fizz::Aead> getZeroRttWriteCipher();
80+
std::unique_ptr<Aead> getZeroRttWriteCipher();
8181

8282
/**
8383
* An edge triggered API to get the handshakeReadCipher. Once you
8484
* receive the handshake read cipher subsequent calls will return null.
8585
*/
86-
std::unique_ptr<fizz::Aead> getHandshakeReadCipher();
86+
std::unique_ptr<Aead> getHandshakeReadCipher();
8787

8888
/**
8989
* An edge triggered API to get the handshakeWriteCipher. Once you
9090
* receive the handshake write cipher subsequent calls will return null.
9191
*/
92-
std::unique_ptr<fizz::Aead> getHandshakeWriteCipher();
92+
std::unique_ptr<Aead> getHandshakeWriteCipher();
9393

9494
/**
9595
* An edge triggered API to get the one rtt read header cpher. Once you

quic/client/handshake/test/ClientHandshakeTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ class ClientHandshakeTest : public Test, public boost::static_visitor<> {
244244
folly::IOBufQueue serverReadBuf{folly::IOBufQueue::cacheChainLength()};
245245
std::unique_ptr<DelayedHolder, folly::DelayedDestruction::Destructor> dg;
246246

247-
std::unique_ptr<fizz::Aead> handshakeWriteCipher;
248-
std::unique_ptr<fizz::Aead> handshakeReadCipher;
249-
std::unique_ptr<fizz::Aead> oneRttWriteCipher;
250-
std::unique_ptr<fizz::Aead> oneRttReadCipher;
251-
std::unique_ptr<fizz::Aead> zeroRttWriteCipher;
247+
std::unique_ptr<Aead> handshakeWriteCipher;
248+
std::unique_ptr<Aead> handshakeReadCipher;
249+
std::unique_ptr<Aead> oneRttWriteCipher;
250+
std::unique_ptr<Aead> oneRttReadCipher;
251+
std::unique_ptr<Aead> zeroRttWriteCipher;
252252

253253
folly::Optional<bool> zeroRttRejected;
254254

quic/client/test/QuicClientTransportTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ class QuicClientTransportTest : public Test {
13211321
bool handshakeCipher = false) {
13221322
QuicFizzFactory fizzFactory;
13231323
auto codec = std::make_unique<QuicReadCodec>(QuicNodeType::Server);
1324-
std::unique_ptr<fizz::Aead> handshakeReadCipher;
1324+
std::unique_ptr<Aead> handshakeReadCipher;
13251325
codec->setClientConnectionId(*originalConnId);
13261326
codec->setOneRttReadCipher(test::createNoOpAead());
13271327
codec->setOneRttHeaderCipher(test::createNoOpHeaderCipher());
@@ -1338,7 +1338,7 @@ class QuicClientTransportTest : public Test {
13381338
return codec;
13391339
}
13401340

1341-
const fizz::Aead& getInitialCipher() {
1341+
const Aead& getInitialCipher() {
13421342
return *client->getConn().readCodec->getInitialCipher();
13431343
}
13441344

@@ -3441,7 +3441,7 @@ Buf getHandshakePacketWithFrame(
34413441
QuicWriteFrame frame,
34423442
ConnectionId srcConnId,
34433443
ConnectionId destConnId,
3444-
const fizz::Aead& serverWriteCipher,
3444+
const Aead& serverWriteCipher,
34453445
const PacketNumberCipher& headerCipher) {
34463446
PacketNum packetNum = folly::Random::rand32();
34473447
LongHeader header(

quic/codec/QuicReadCodec.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ CodecResult QuicReadCodec::parseLongHeaderPacket(
104104
}
105105
cursor.pull(sample.data(), sample.size());
106106
const PacketNumberCipher* headerCipher{nullptr};
107-
const fizz::Aead* cipher{nullptr};
107+
const Aead* cipher{nullptr};
108108
auto protectionType = longHeader.getProtectionType();
109109
switch (protectionType) {
110110
case ProtectionType::Initial:
@@ -334,15 +334,15 @@ CodecResult QuicReadCodec::parsePacket(
334334
return decodeRegularPacket(std::move(*shortHeader), params_, packetCursor);
335335
}
336336

337-
const fizz::Aead* QuicReadCodec::getOneRttReadCipher() const {
337+
const Aead* QuicReadCodec::getOneRttReadCipher() const {
338338
return oneRttReadCipher_.get();
339339
}
340340

341-
const fizz::Aead* QuicReadCodec::getZeroRttReadCipher() const {
341+
const Aead* QuicReadCodec::getZeroRttReadCipher() const {
342342
return zeroRttReadCipher_.get();
343343
}
344344

345-
const fizz::Aead* QuicReadCodec::getHandshakeReadCipher() const {
345+
const Aead* QuicReadCodec::getHandshakeReadCipher() const {
346346
return handshakeReadCipher_.get();
347347
}
348348

@@ -352,17 +352,17 @@ QuicReadCodec::getStatelessResetToken() const {
352352
}
353353

354354
void QuicReadCodec::setInitialReadCipher(
355-
std::unique_ptr<fizz::Aead> initialReadCipher) {
355+
std::unique_ptr<Aead> initialReadCipher) {
356356
initialReadCipher_ = std::move(initialReadCipher);
357357
}
358358

359359
void QuicReadCodec::setOneRttReadCipher(
360-
std::unique_ptr<fizz::Aead> oneRttReadCipher) {
360+
std::unique_ptr<Aead> oneRttReadCipher) {
361361
oneRttReadCipher_ = std::move(oneRttReadCipher);
362362
}
363363

364364
void QuicReadCodec::setZeroRttReadCipher(
365-
std::unique_ptr<fizz::Aead> zeroRttReadCipher) {
365+
std::unique_ptr<Aead> zeroRttReadCipher) {
366366
if (nodeType_ == QuicNodeType::Client) {
367367
throw QuicTransportException(
368368
"Invalid cipher", TransportErrorCode::INTERNAL_ERROR);
@@ -371,7 +371,7 @@ void QuicReadCodec::setZeroRttReadCipher(
371371
}
372372

373373
void QuicReadCodec::setHandshakeReadCipher(
374-
std::unique_ptr<fizz::Aead> handshakeReadCipher) {
374+
std::unique_ptr<Aead> handshakeReadCipher) {
375375
handshakeReadCipher_ = std::move(handshakeReadCipher);
376376
}
377377

@@ -412,7 +412,7 @@ void QuicReadCodec::setStatelessResetToken(
412412
statelessResetToken_ = std::move(statelessResetToken);
413413
}
414414

415-
const fizz::Aead* QuicReadCodec::getInitialCipher() const {
415+
const Aead* QuicReadCodec::getInitialCipher() const {
416416
return initialReadCipher_.get();
417417
}
418418

0 commit comments

Comments
 (0)