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
36 lines
978 B
C++
36 lines
978 B
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/HandshakeLayer.h>
|
|
|
|
#include <fizz/crypto/KeyDerivation.h>
|
|
#include <fizz/crypto/Sha256.h>
|
|
#include <fizz/protocol/Factory.h>
|
|
#include <quic/handshake/FizzBridge.h>
|
|
#include <quic/handshake/FizzCryptoFactory.h>
|
|
#include <quic/handshake/QuicFizzFactory.h>
|
|
|
|
namespace quic {
|
|
|
|
EncryptionLevel protectionTypeToEncryptionLevel(ProtectionType type) {
|
|
switch (type) {
|
|
case ProtectionType::Initial:
|
|
return EncryptionLevel::Initial;
|
|
case ProtectionType::Handshake:
|
|
return EncryptionLevel::Handshake;
|
|
case ProtectionType::ZeroRtt:
|
|
return EncryptionLevel::EarlyData;
|
|
case ProtectionType::KeyPhaseZero:
|
|
case ProtectionType::KeyPhaseOne:
|
|
return EncryptionLevel::AppData;
|
|
}
|
|
folly::assume_unreachable();
|
|
}
|
|
|
|
} // namespace quic
|