QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 10 | #include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" |
| 11 | #include "net/third_party/quiche/src/quic/core/quic_types.h" |
| 12 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame^] | 13 | #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 QUIC_EXPORT_PRIVATE NullEncrypter : public QuicEncrypter { |
| 21 | public: |
| 22 | explicit NullEncrypter(Perspective perspective); |
| 23 | NullEncrypter(const NullEncrypter&) = delete; |
| 24 | NullEncrypter& operator=(const NullEncrypter&) = delete; |
| 25 | ~NullEncrypter() override {} |
| 26 | |
| 27 | // QuicEncrypter implementation |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame^] | 28 | bool SetKey(quiche::QuicheStringPiece key) override; |
| 29 | bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) override; |
| 30 | bool SetIV(quiche::QuicheStringPiece iv) override; |
| 31 | bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 32 | bool EncryptPacket(uint64_t packet_number, |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame^] | 33 | quiche::QuicheStringPiece associated_data, |
| 34 | quiche::QuicheStringPiece plaintext, |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 35 | char* output, |
| 36 | size_t* output_length, |
| 37 | size_t max_output_length) override; |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame^] | 38 | std::string GenerateHeaderProtectionMask( |
| 39 | quiche::QuicheStringPiece sample) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 40 | size_t GetKeySize() const override; |
| 41 | size_t GetNoncePrefixSize() const override; |
| 42 | size_t GetIVSize() const override; |
| 43 | size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; |
| 44 | size_t GetCiphertextSize(size_t plaintext_size) const override; |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame^] | 45 | quiche::QuicheStringPiece GetKey() const override; |
| 46 | quiche::QuicheStringPiece GetNoncePrefix() const override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | size_t GetHashLength() const; |
| 50 | |
| 51 | Perspective perspective_; |
| 52 | }; |
| 53 | |
| 54 | } // namespace quic |
| 55 | |
| 56 | #endif // QUICHE_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ |