| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ | 5 #ifndef NET_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ |
| 6 #define NET_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ | 6 #define NET_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ |
| 7 | 7 |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "net/quic/core/crypto/quic_encrypter.h" | 12 #include "net/quic/core/crypto/quic_encrypter.h" |
| 13 #include "net/quic/core/quic_types.h" | 13 #include "net/quic/core/quic_types.h" |
| 14 #include "net/quic/platform/api/quic_export.h" | 14 #include "net/quic/platform/api/quic_export.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 // A NullEncrypter is a QuicEncrypter used before a crypto negotiation | 18 // A NullEncrypter is a QuicEncrypter used before a crypto negotiation |
| 19 // has occurred. It does not actually encrypt the payload, but does | 19 // has occurred. It does not actually encrypt the payload, but does |
| 20 // generate a MAC (fnv128) over both the payload and associated data. | 20 // generate a MAC (fnv128) over both the payload and associated data. |
| 21 class QUIC_EXPORT_PRIVATE NullEncrypter : public QuicEncrypter { | 21 class QUIC_EXPORT_PRIVATE NullEncrypter : public QuicEncrypter { |
| 22 public: | 22 public: |
| 23 explicit NullEncrypter(Perspective perspective); | 23 explicit NullEncrypter(Perspective perspective); |
| 24 ~NullEncrypter() override {} | 24 ~NullEncrypter() override {} |
| 25 | 25 |
| 26 // QuicEncrypter implementation | 26 // QuicEncrypter implementation |
| 27 bool SetKey(base::StringPiece key) override; | 27 bool SetKey(base::StringPiece key) override; |
| 28 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; | 28 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; |
| 29 bool EncryptPacket(QuicVersion version, | 29 bool EncryptPacket(QuicVersion version, |
| 30 QuicPathId path_id, | |
| 31 QuicPacketNumber packet_number, | 30 QuicPacketNumber packet_number, |
| 32 base::StringPiece associated_data, | 31 base::StringPiece associated_data, |
| 33 base::StringPiece plaintext, | 32 base::StringPiece plaintext, |
| 34 char* output, | 33 char* output, |
| 35 size_t* output_length, | 34 size_t* output_length, |
| 36 size_t max_output_length) override; | 35 size_t max_output_length) override; |
| 37 size_t GetKeySize() const override; | 36 size_t GetKeySize() const override; |
| 38 size_t GetNoncePrefixSize() const override; | 37 size_t GetNoncePrefixSize() const override; |
| 39 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; | 38 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; |
| 40 size_t GetCiphertextSize(size_t plaintext_size) const override; | 39 size_t GetCiphertextSize(size_t plaintext_size) const override; |
| 41 base::StringPiece GetKey() const override; | 40 base::StringPiece GetKey() const override; |
| 42 base::StringPiece GetNoncePrefix() const override; | 41 base::StringPiece GetNoncePrefix() const override; |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 size_t GetHashLength() const; | 44 size_t GetHashLength() const; |
| 46 | 45 |
| 47 Perspective perspective_; | 46 Perspective perspective_; |
| 48 | 47 |
| 49 DISALLOW_COPY_AND_ASSIGN(NullEncrypter); | 48 DISALLOW_COPY_AND_ASSIGN(NullEncrypter); |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 } // namespace net | 51 } // namespace net |
| 53 | 52 |
| 54 #endif // NET_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ | 53 #endif // NET_QUIC_CORE_CRYPTO_NULL_ENCRYPTER_H_ |
| OLD | NEW |