Ryan Hamilton | 56b10c5d | 2018-05-11 13:40:16 | [diff] [blame] | 1 | // Copyright 2017 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 | |
Ryan Hamilton | 7582d265 | 2018-08-01 22:35:32 | [diff] [blame] | 5 | #ifndef NET_QUIC_MOCK_DECRYPTER_H_ |
| 6 | #define NET_QUIC_MOCK_DECRYPTER_H_ |
Ryan Hamilton | 56b10c5d | 2018-05-11 13:40:16 | [diff] [blame] | 7 | |
| 8 | #include <cstddef> |
| 9 | #include <cstdint> |
| 10 | |
| 11 | #include "base/compiler_specific.h" |
| 12 | #include "base/macros.h" |
| 13 | #include "net/third_party/quic/core/crypto/quic_decrypter.h" |
| 14 | #include "net/third_party/quic/core/quic_types.h" |
| 15 | #include "net/third_party/quic/platform/api/quic_export.h" |
| 16 | #include "net/third_party/quic/platform/api/quic_string_piece.h" |
| 17 | |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 18 | namespace quic { |
Ryan Hamilton | 56b10c5d | 2018-05-11 13:40:16 | [diff] [blame] | 19 | |
| 20 | // A MockDecrypter is a QuicDecrypter that does no validation of |
| 21 | // the given ciphertext and returns it untouched, ignoring the |
| 22 | // associated data. This is used to allow fuzzing to mutate |
| 23 | // plaintext packets. |
| 24 | class MockDecrypter : public QuicDecrypter { |
| 25 | public: |
| 26 | explicit MockDecrypter(Perspective perspective); |
| 27 | ~MockDecrypter() override {} |
| 28 | |
| 29 | // QuicDecrypter implementation |
| 30 | bool SetKey(QuicStringPiece key) override; |
| 31 | bool SetNoncePrefix(QuicStringPiece nonce_prefix) override; |
| 32 | bool SetIV(QuicStringPiece iv) override; |
| 33 | bool SetPreliminaryKey(QuicStringPiece key) override; |
| 34 | bool SetDiversificationNonce(const DiversificationNonce& nonce) override; |
| 35 | bool DecryptPacket(QuicTransportVersion version, |
| 36 | QuicPacketNumber packet_number, |
| 37 | QuicStringPiece associated_data, |
| 38 | QuicStringPiece ciphertext, |
| 39 | char* output, |
| 40 | size_t* output_length, |
| 41 | size_t max_output_length) override; |
| 42 | size_t GetKeySize() const override; |
| 43 | size_t GetIVSize() const override; |
| 44 | QuicStringPiece GetKey() const override; |
| 45 | QuicStringPiece GetNoncePrefix() const override; |
| 46 | |
| 47 | uint32_t cipher_id() const override; |
| 48 | |
| 49 | private: |
| 50 | DISALLOW_COPY_AND_ASSIGN(MockDecrypter); |
| 51 | }; |
| 52 | |
Ryan Hamilton | 8d9ee76e | 2018-05-29 23:52:52 | [diff] [blame] | 53 | } // namespace quic |
Ryan Hamilton | 56b10c5d | 2018-05-11 13:40:16 | [diff] [blame] | 54 | |
Ryan Hamilton | 7582d265 | 2018-08-01 22:35:32 | [diff] [blame] | 55 | #endif // NET_QUIC_MOCK_DECRYPTER_H_ |