blob: bda73dc0ad86fed8e502ce91b2c6700060424c87 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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 teama6ef0a62019-03-07 20:34:33 -050010#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"
dmcardle904ef182019-12-13 08:34:33 -080013#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050014
15namespace 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.
20class 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
dmcardle904ef182019-12-13 08:34:33 -080028 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 teama6ef0a62019-03-07 20:34:33 -050032 bool EncryptPacket(uint64_t packet_number,
dmcardle904ef182019-12-13 08:34:33 -080033 quiche::QuicheStringPiece associated_data,
34 quiche::QuicheStringPiece plaintext,
QUICHE teama6ef0a62019-03-07 20:34:33 -050035 char* output,
36 size_t* output_length,
37 size_t max_output_length) override;
dmcardle904ef182019-12-13 08:34:33 -080038 std::string GenerateHeaderProtectionMask(
39 quiche::QuicheStringPiece sample) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -050040 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;
dmcardle904ef182019-12-13 08:34:33 -080045 quiche::QuicheStringPiece GetKey() const override;
46 quiche::QuicheStringPiece GetNoncePrefix() const override;
QUICHE teama6ef0a62019-03-07 20:34:33 -050047
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_