1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ 6 #define QUICHE_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ 7 8 #include <cstddef> 9 10 #include "absl/strings/string_view.h" 11 #include "quiche/quic/core/crypto/quic_encrypter.h" 12 #include "quiche/quic/core/quic_types.h" 13 #include "quiche/quic/platform/api/quic_export.h" 14 15 namespace quic { 16 17 // A NullEncrypter is a QuicEncrypter used before a crypto negotiation 18 // has occurred. It does not actually encrypt the payload, but does 19 // generate a MAC (fnv128) over both the payload and associated data. 20 class QUICHE_EXPORT NullEncrypter : public QuicEncrypter { 21 public: 22 explicit NullEncrypter(Perspective perspective); 23 NullEncrypter(const NullEncrypter&) = delete; 24 NullEncrypter& operator=(const NullEncrypter&) = delete; ~NullEncrypter()25 ~NullEncrypter() override {} 26 27 // QuicEncrypter implementation 28 bool SetKey(absl::string_view key) override; 29 bool SetNoncePrefix(absl::string_view nonce_prefix) override; 30 bool SetIV(absl::string_view iv) override; 31 bool SetHeaderProtectionKey(absl::string_view key) override; 32 bool EncryptPacket(uint64_t packet_number, absl::string_view associated_data, 33 absl::string_view plaintext, char* output, 34 size_t* output_length, size_t max_output_length) override; 35 std::string GenerateHeaderProtectionMask(absl::string_view sample) override; 36 size_t GetKeySize() const override; 37 size_t GetNoncePrefixSize() const override; 38 size_t GetIVSize() const override; 39 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; 40 size_t GetCiphertextSize(size_t plaintext_size) const override; 41 QuicPacketCount GetConfidentialityLimit() const override; 42 absl::string_view GetKey() const override; 43 absl::string_view GetNoncePrefix() const override; 44 45 private: 46 size_t GetHashLength() const; 47 48 Perspective perspective_; 49 }; 50 51 } // namespace quic 52 53 #endif // QUICHE_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ 54