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

Side by Side Diff: net/quic/crypto/aead_base_encrypter.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 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/crypto/aead_base_decrypter.cc ('k') | net/quic/crypto/aead_base_encrypter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_
6 #define NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_
7
8 #include <stddef.h>
9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "net/quic/crypto/quic_encrypter.h"
13 #include "net/quic/crypto/scoped_evp_aead_ctx.h"
14
15 namespace net {
16
17 // AeadBaseEncrypter is the base class of AEAD QuicEncrypter subclasses.
18 class NET_EXPORT_PRIVATE AeadBaseEncrypter : public QuicEncrypter {
19 public:
20 AeadBaseEncrypter(const EVP_AEAD* aead_alg,
21 size_t key_size,
22 size_t auth_tag_size,
23 size_t nonce_prefix_size);
24 ~AeadBaseEncrypter() override;
25
26 // QuicEncrypter implementation
27 bool SetKey(base::StringPiece key) override;
28 bool SetNoncePrefix(base::StringPiece nonce_prefix) override;
29 bool EncryptPacket(QuicPathId path_id,
30 QuicPacketNumber packet_number,
31 base::StringPiece associated_data,
32 base::StringPiece plaintext,
33 char* output,
34 size_t* output_length,
35 size_t max_output_length) override;
36 size_t GetKeySize() const override;
37 size_t GetNoncePrefixSize() const override;
38 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override;
39 size_t GetCiphertextSize(size_t plaintext_size) const override;
40 base::StringPiece GetKey() const override;
41 base::StringPiece GetNoncePrefix() const override;
42
43 // Necessary so unit tests can explicitly specify a nonce, instead of a
44 // nonce prefix and packet number.
45 bool Encrypt(base::StringPiece nonce,
46 base::StringPiece associated_data,
47 base::StringPiece plaintext,
48 unsigned char* output);
49
50 protected:
51 // Make these constants available to the subclasses so that the subclasses
52 // can assert at compile time their key_size_ and nonce_prefix_size_ do not
53 // exceed the maximum.
54 static const size_t kMaxKeySize = 32;
55 static const size_t kMaxNoncePrefixSize = 4;
56
57 private:
58 const EVP_AEAD* const aead_alg_;
59 const size_t key_size_;
60 const size_t auth_tag_size_;
61 const size_t nonce_prefix_size_;
62
63 // The key.
64 unsigned char key_[kMaxKeySize];
65 // The nonce prefix.
66 unsigned char nonce_prefix_[kMaxNoncePrefixSize];
67
68 ScopedEVPAEADCtx ctx_;
69
70 DISALLOW_COPY_AND_ASSIGN(AeadBaseEncrypter);
71 };
72
73 } // namespace net
74
75 #endif // NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/aead_base_decrypter.cc ('k') | net/quic/crypto/aead_base_encrypter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698