mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-10 21:22:20 +03:00
Summary: The CryptoFactory is extended with makePacketNumberCipher . In order to support that feature, FizzCryptoFactory now explicitly takes a QuicFizzFactory as argument instead of a generic fizz::Factory, which is the only type that is used in practice anyways. The cypher argument was removed because: 1/ Only one cypher is used at all. Fizz also supports ChaCha20, but using it in mvfst will throw an exception. 2/ it seems like the factory should know what cypher it is dealing with. If a choice of cypher needs to be supported going forward, it can be done by adding state to FizzCryptoFactory. Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/40 Reviewed By: mjoras Differential Revision: D16785274 Pulled By: yangchi fbshipit-source-id: a1c490e34c5ddd107e8e068d8b127c1ed00a59ec
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*/
|
|
|
|
#include <quic/handshake/CryptoFactory.h>
|
|
|
|
#include <quic/handshake/HandshakeLayer.h>
|
|
|
|
namespace quic {
|
|
|
|
std::unique_ptr<Aead> CryptoFactory::getClientInitialCipher(
|
|
const ConnectionId& clientDestinationConnId,
|
|
QuicVersion version) const {
|
|
return makeInitialAead(kClientInitialLabel, clientDestinationConnId, version);
|
|
}
|
|
|
|
std::unique_ptr<Aead> CryptoFactory::getServerInitialCipher(
|
|
const ConnectionId& clientDestinationConnId,
|
|
QuicVersion version) const {
|
|
return makeInitialAead(kServerInitialLabel, clientDestinationConnId, version);
|
|
}
|
|
|
|
Buf CryptoFactory::makeServerInitialTrafficSecret(
|
|
const ConnectionId& clientDestinationConnId,
|
|
QuicVersion version) const {
|
|
return makeInitialTrafficSecret(
|
|
kServerInitialLabel, clientDestinationConnId, version);
|
|
}
|
|
|
|
Buf CryptoFactory::makeClientInitialTrafficSecret(
|
|
const ConnectionId& clientDestinationConnId,
|
|
QuicVersion version) const {
|
|
return makeInitialTrafficSecret(
|
|
kClientInitialLabel, clientDestinationConnId, version);
|
|
}
|
|
|
|
std::unique_ptr<PacketNumberCipher>
|
|
CryptoFactory::makeClientInitialHeaderCipher(
|
|
const ConnectionId& initialDestinationConnectionId,
|
|
QuicVersion version) const {
|
|
auto clientInitialTrafficSecret =
|
|
makeClientInitialTrafficSecret(initialDestinationConnectionId, version);
|
|
return makePacketNumberCipher(clientInitialTrafficSecret->coalesce());
|
|
}
|
|
|
|
std::unique_ptr<PacketNumberCipher>
|
|
CryptoFactory::makeServerInitialHeaderCipher(
|
|
const ConnectionId& initialDestinationConnectionId,
|
|
QuicVersion version) const {
|
|
auto serverInitialTrafficSecret =
|
|
makeServerInitialTrafficSecret(initialDestinationConnectionId, version);
|
|
return makePacketNumberCipher(serverInitialTrafficSecret->coalesce());
|
|
}
|
|
|
|
} // namespace quic
|