blob: 6c8d826957a90af033a6c158ca269303f300a9ba [file] [log] [blame]
Ryan Hamilton56b10c5d2018-05-11 13:40:161// 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 Hamilton7582d2652018-08-01 22:35:325#ifndef NET_QUIC_MOCK_DECRYPTER_H_
6#define NET_QUIC_MOCK_DECRYPTER_H_
Ryan Hamilton56b10c5d2018-05-11 13:40:167
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 Hamilton8d9ee76e2018-05-29 23:52:5218namespace quic {
Ryan Hamilton56b10c5d2018-05-11 13:40:1619
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.
24class 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 Hamilton8d9ee76e2018-05-29 23:52:5253} // namespace quic
Ryan Hamilton56b10c5d2018-05-11 13:40:1654
Ryan Hamilton7582d2652018-08-01 22:35:3255#endif // NET_QUIC_MOCK_DECRYPTER_H_