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 | |
| 10 | #include "base/macros.h" |
| 11 | #include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" |
| 12 | #include "net/third_party/quiche/src/quic/core/quic_types.h" |
| 13 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
| 14 | #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" |
| 15 | |
| 16 | namespace quic { |
| 17 | |
| 18 | // A NullEncrypter is a QuicEncrypter used before a crypto negotiation |
| 19 | // has occurred. It does not actually encrypt the payload, but does |
| 20 | // generate a MAC (fnv128) over both the payload and associated data. |
| 21 | class QUIC_EXPORT_PRIVATE NullEncrypter : public QuicEncrypter { |
| 22 | public: |
| 23 | explicit NullEncrypter(Perspective perspective); |
| 24 | NullEncrypter(const NullEncrypter&) = delete; |
| 25 | NullEncrypter& operator=(const NullEncrypter&) = delete; |
| 26 | ~NullEncrypter() override {} |
| 27 | |
| 28 | // QuicEncrypter implementation |
| 29 | bool SetKey(QuicStringPiece key) override; |
| 30 | bool SetNoncePrefix(QuicStringPiece nonce_prefix) override; |
| 31 | bool SetIV(QuicStringPiece iv) override; |
| 32 | bool EncryptPacket(uint64_t packet_number, |
| 33 | QuicStringPiece associated_data, |
| 34 | QuicStringPiece plaintext, |
| 35 | char* output, |
| 36 | size_t* output_length, |
| 37 | size_t max_output_length) override; |
| 38 | size_t GetKeySize() const override; |
| 39 | size_t GetNoncePrefixSize() const override; |
| 40 | size_t GetIVSize() const override; |
| 41 | size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; |
| 42 | size_t GetCiphertextSize(size_t plaintext_size) const override; |
| 43 | QuicStringPiece GetKey() const override; |
| 44 | QuicStringPiece GetNoncePrefix() const override; |
| 45 | |
| 46 | private: |
| 47 | size_t GetHashLength() const; |
| 48 | |
| 49 | Perspective perspective_; |
| 50 | }; |
| 51 | |
| 52 | } // namespace quic |
| 53 | |
| 54 | #endif // QUICHE_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ |