Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: net/quic/core/crypto/aead_base_decrypter.h

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/chromium/quic_utils_chromium.cc ('k') | net/quic/core/crypto/aead_base_decrypter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_AEAD_BASE_DECRYPTER_H_ 5 #ifndef NET_QUIC_CORE_CRYPTO_AEAD_BASE_DECRYPTER_H_
6 #define NET_QUIC_CORE_CRYPTO_AEAD_BASE_DECRYPTER_H_ 6 #define NET_QUIC_CORE_CRYPTO_AEAD_BASE_DECRYPTER_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_decrypter.h" 12 #include "net/quic/core/crypto/quic_decrypter.h"
13 #include "net/quic/core/crypto/scoped_evp_aead_ctx.h" 13 #include "net/quic/core/crypto/scoped_evp_aead_ctx.h"
14 #include "net/quic/platform/api/quic_export.h" 14 #include "net/quic/platform/api/quic_export.h"
15 #include "net/quic/platform/api/quic_string_piece.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 // AeadBaseDecrypter is the base class of AEAD QuicDecrypter subclasses. 19 // AeadBaseDecrypter is the base class of AEAD QuicDecrypter subclasses.
19 class QUIC_EXPORT_PRIVATE AeadBaseDecrypter : public QuicDecrypter { 20 class QUIC_EXPORT_PRIVATE AeadBaseDecrypter : public QuicDecrypter {
20 public: 21 public:
21 AeadBaseDecrypter(const EVP_AEAD* aead_alg, 22 AeadBaseDecrypter(const EVP_AEAD* aead_alg,
22 size_t key_size, 23 size_t key_size,
23 size_t auth_tag_size, 24 size_t auth_tag_size,
24 size_t nonce_prefix_size); 25 size_t nonce_prefix_size);
25 ~AeadBaseDecrypter() override; 26 ~AeadBaseDecrypter() override;
26 27
27 // QuicDecrypter implementation 28 // QuicDecrypter implementation
28 bool SetKey(base::StringPiece key) override; 29 bool SetKey(QuicStringPiece key) override;
29 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; 30 bool SetNoncePrefix(QuicStringPiece nonce_prefix) override;
30 bool SetPreliminaryKey(base::StringPiece key) override; 31 bool SetPreliminaryKey(QuicStringPiece key) override;
31 bool SetDiversificationNonce(const DiversificationNonce& nonce) override; 32 bool SetDiversificationNonce(const DiversificationNonce& nonce) override;
32 bool DecryptPacket(QuicVersion version, 33 bool DecryptPacket(QuicVersion version,
33 QuicPacketNumber packet_number, 34 QuicPacketNumber packet_number,
34 base::StringPiece associated_data, 35 QuicStringPiece associated_data,
35 base::StringPiece ciphertext, 36 QuicStringPiece ciphertext,
36 char* output, 37 char* output,
37 size_t* output_length, 38 size_t* output_length,
38 size_t max_output_length) override; 39 size_t max_output_length) override;
39 base::StringPiece GetKey() const override; 40 QuicStringPiece GetKey() const override;
40 base::StringPiece GetNoncePrefix() const override; 41 QuicStringPiece GetNoncePrefix() const override;
41 42
42 protected: 43 protected:
43 // Make these constants available to the subclasses so that the subclasses 44 // Make these constants available to the subclasses so that the subclasses
44 // can assert at compile time their key_size_ and nonce_prefix_size_ do not 45 // can assert at compile time their key_size_ and nonce_prefix_size_ do not
45 // exceed the maximum. 46 // exceed the maximum.
46 static const size_t kMaxKeySize = 32; 47 static const size_t kMaxKeySize = 32;
47 static const size_t kMaxNoncePrefixSize = 4; 48 static const size_t kMaxNoncePrefixSize = 4;
48 49
49 private: 50 private:
50 const EVP_AEAD* const aead_alg_; 51 const EVP_AEAD* const aead_alg_;
51 const size_t key_size_; 52 const size_t key_size_;
52 const size_t auth_tag_size_; 53 const size_t auth_tag_size_;
53 const size_t nonce_prefix_size_; 54 const size_t nonce_prefix_size_;
54 bool have_preliminary_key_; 55 bool have_preliminary_key_;
55 56
56 // The key. 57 // The key.
57 unsigned char key_[kMaxKeySize]; 58 unsigned char key_[kMaxKeySize];
58 // The nonce prefix. 59 // The nonce prefix.
59 unsigned char nonce_prefix_[kMaxNoncePrefixSize]; 60 unsigned char nonce_prefix_[kMaxNoncePrefixSize];
60 61
61 ScopedEVPAEADCtx ctx_; 62 ScopedEVPAEADCtx ctx_;
62 63
63 DISALLOW_COPY_AND_ASSIGN(AeadBaseDecrypter); 64 DISALLOW_COPY_AND_ASSIGN(AeadBaseDecrypter);
64 }; 65 };
65 66
66 } // namespace net 67 } // namespace net
67 68
68 #endif // NET_QUIC_CORE_CRYPTO_AEAD_BASE_DECRYPTER_H_ 69 #endif // NET_QUIC_CORE_CRYPTO_AEAD_BASE_DECRYPTER_H_
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_utils_chromium.cc ('k') | net/quic/core/crypto/aead_base_decrypter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698