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_DECRYPTER_H_ |
| 6 | #define QUICHE_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ |
| 7 | |
| 8 | #include <cstddef> |
| 9 | #include <cstdint> |
| 10 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 11 | #include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.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" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 14 | #include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame] | 15 | #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] | 16 | |
| 17 | namespace quic { |
| 18 | |
| 19 | class QuicDataReader; |
| 20 | |
| 21 | // A NullDecrypter is a QuicDecrypter used before a crypto negotiation |
| 22 | // has occurred. It does not actually decrypt the payload, but does |
| 23 | // verify a hash (fnv128) over both the payload and associated data. |
| 24 | class QUIC_EXPORT_PRIVATE NullDecrypter : public QuicDecrypter { |
| 25 | public: |
| 26 | explicit NullDecrypter(Perspective perspective); |
| 27 | NullDecrypter(const NullDecrypter&) = delete; |
| 28 | NullDecrypter& operator=(const NullDecrypter&) = delete; |
| 29 | ~NullDecrypter() override {} |
| 30 | |
| 31 | // QuicDecrypter implementation |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame] | 32 | bool SetKey(quiche::QuicheStringPiece key) override; |
| 33 | bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) override; |
| 34 | bool SetIV(quiche::QuicheStringPiece iv) override; |
| 35 | bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; |
| 36 | bool SetPreliminaryKey(quiche::QuicheStringPiece key) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 37 | bool SetDiversificationNonce(const DiversificationNonce& nonce) override; |
| 38 | bool DecryptPacket(uint64_t packet_number, |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame] | 39 | quiche::QuicheStringPiece associated_data, |
| 40 | quiche::QuicheStringPiece ciphertext, |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 41 | char* output, |
| 42 | size_t* output_length, |
| 43 | size_t max_output_length) override; |
QUICHE team | 2d18797 | 2019-03-19 16:23:47 -0700 | [diff] [blame] | 44 | std::string GenerateHeaderProtectionMask( |
| 45 | QuicDataReader* sample_reader) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 46 | size_t GetKeySize() const override; |
nharper | 965e592 | 2019-09-23 22:33:54 -0700 | [diff] [blame] | 47 | size_t GetNoncePrefixSize() const override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 48 | size_t GetIVSize() const override; |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame] | 49 | quiche::QuicheStringPiece GetKey() const override; |
| 50 | quiche::QuicheStringPiece GetNoncePrefix() const override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 51 | |
| 52 | uint32_t cipher_id() const override; |
| 53 | |
| 54 | private: |
| 55 | bool ReadHash(QuicDataReader* reader, QuicUint128* hash); |
dmcardle | 904ef18 | 2019-12-13 08:34:33 -0800 | [diff] [blame] | 56 | QuicUint128 ComputeHash(quiche::QuicheStringPiece data1, |
| 57 | quiche::QuicheStringPiece data2) const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 58 | |
| 59 | Perspective perspective_; |
| 60 | }; |
| 61 | |
| 62 | } // namespace quic |
| 63 | |
| 64 | #endif // QUICHE_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ |