| 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_DECRYPTER_H_ | 5 #ifndef NET_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ |
| 6 #define NET_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ | 6 #define NET_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ |
| 7 | 7 |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <cstdint> | 9 #include <cstdint> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "net/base/int128.h" | 13 #include "net/base/int128.h" |
| 14 #include "net/quic/core/crypto/quic_decrypter.h" | 14 #include "net/quic/core/crypto/quic_decrypter.h" |
| 15 #include "net/quic/core/quic_types.h" | 15 #include "net/quic/core/quic_types.h" |
| 16 #include "net/quic/platform/api/quic_export.h" | 16 #include "net/quic/platform/api/quic_export.h" |
| 17 #include "net/quic/platform/api/quic_string_piece.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 class QuicDataReader; | 21 class QuicDataReader; |
| 21 | 22 |
| 22 // A NullDecrypter is a QuicDecrypter used before a crypto negotiation | 23 // A NullDecrypter is a QuicDecrypter used before a crypto negotiation |
| 23 // has occurred. It does not actually decrypt the payload, but does | 24 // has occurred. It does not actually decrypt the payload, but does |
| 24 // verify a hash (fnv128) over both the payload and associated data. | 25 // verify a hash (fnv128) over both the payload and associated data. |
| 25 class QUIC_EXPORT_PRIVATE NullDecrypter : public QuicDecrypter { | 26 class QUIC_EXPORT_PRIVATE NullDecrypter : public QuicDecrypter { |
| 26 public: | 27 public: |
| 27 explicit NullDecrypter(Perspective perspective); | 28 explicit NullDecrypter(Perspective perspective); |
| 28 ~NullDecrypter() override {} | 29 ~NullDecrypter() override {} |
| 29 | 30 |
| 30 // QuicDecrypter implementation | 31 // QuicDecrypter implementation |
| 31 bool SetKey(base::StringPiece key) override; | 32 bool SetKey(QuicStringPiece key) override; |
| 32 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; | 33 bool SetNoncePrefix(QuicStringPiece nonce_prefix) override; |
| 33 bool SetPreliminaryKey(base::StringPiece key) override; | 34 bool SetPreliminaryKey(QuicStringPiece key) override; |
| 34 bool SetDiversificationNonce(const DiversificationNonce& nonce) override; | 35 bool SetDiversificationNonce(const DiversificationNonce& nonce) override; |
| 35 bool DecryptPacket(QuicVersion version, | 36 bool DecryptPacket(QuicVersion version, |
| 36 QuicPacketNumber packet_number, | 37 QuicPacketNumber packet_number, |
| 37 base::StringPiece associated_data, | 38 QuicStringPiece associated_data, |
| 38 base::StringPiece ciphertext, | 39 QuicStringPiece ciphertext, |
| 39 char* output, | 40 char* output, |
| 40 size_t* output_length, | 41 size_t* output_length, |
| 41 size_t max_output_length) override; | 42 size_t max_output_length) override; |
| 42 base::StringPiece GetKey() const override; | 43 QuicStringPiece GetKey() const override; |
| 43 base::StringPiece GetNoncePrefix() const override; | 44 QuicStringPiece GetNoncePrefix() const override; |
| 44 | 45 |
| 45 const char* cipher_name() const override; | 46 const char* cipher_name() const override; |
| 46 uint32_t cipher_id() const override; | 47 uint32_t cipher_id() const override; |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 bool ReadHash(QuicDataReader* reader, uint128* hash); | 50 bool ReadHash(QuicDataReader* reader, uint128* hash); |
| 50 uint128 ComputeHash(QuicVersion version, | 51 uint128 ComputeHash(QuicVersion version, |
| 51 base::StringPiece data1, | 52 QuicStringPiece data1, |
| 52 base::StringPiece data2) const; | 53 QuicStringPiece data2) const; |
| 53 | 54 |
| 54 Perspective perspective_; | 55 Perspective perspective_; |
| 55 | 56 |
| 56 DISALLOW_COPY_AND_ASSIGN(NullDecrypter); | 57 DISALLOW_COPY_AND_ASSIGN(NullDecrypter); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 } // namespace net | 60 } // namespace net |
| 60 | 61 |
| 61 #endif // NET_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ | 62 #endif // NET_QUIC_CORE_CRYPTO_NULL_DECRYPTER_H_ |
| OLD | NEW |