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

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

Issue 189893002: Add ChaCha20Poly1305Encrypter, based on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove the six svn copy files from the CL Created 6 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 | Annotate | Revision Log
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_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_ 5 #ifndef NET_QUIC_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_
6 #define NET_QUIC_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_ 6 #define NET_QUIC_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_
7 7
8 #include <string> 8 #include "net/quic/crypto/aead_base_encrypter.h"
9
10 #include "base/compiler_specific.h"
11 #include "net/quic/crypto/quic_encrypter.h"
12
13 #if defined(USE_OPENSSL)
14 #include "net/quic/crypto/scoped_evp_aead_ctx.h"
15 #endif
16 9
17 namespace net { 10 namespace net {
18 11
19 namespace test {
20 class Aes128Gcm12EncrypterPeer;
21 } // namespace test
22
23 // An Aes128Gcm12Encrypter is a QuicEncrypter that implements the 12 // An Aes128Gcm12Encrypter is a QuicEncrypter that implements the
24 // AEAD_AES_128_GCM_12 algorithm specified in RFC 5282. Create an instance by 13 // AEAD_AES_128_GCM_12 algorithm specified in RFC 5282. Create an instance by
25 // calling QuicEncrypter::Create(kAESG). 14 // calling QuicEncrypter::Create(kAESG).
26 // 15 //
27 // It uses an authentication tag of 12 bytes (96 bits). The fixed prefix 16 // It uses an authentication tag of 12 bytes (96 bits). The fixed prefix
28 // of the nonce is four bytes. 17 // of the nonce is four bytes.
29 class NET_EXPORT_PRIVATE Aes128Gcm12Encrypter : public QuicEncrypter { 18 class NET_EXPORT_PRIVATE Aes128Gcm12Encrypter : public AeadBaseEncrypter {
30 public: 19 public:
31 enum { 20 enum {
32 // Authentication tags are truncated to 96 bits. 21 // Authentication tags are truncated to 96 bits.
33 kAuthTagSize = 12, 22 kAuthTagSize = 12,
34 }; 23 };
35 24
36 Aes128Gcm12Encrypter(); 25 Aes128Gcm12Encrypter();
37 virtual ~Aes128Gcm12Encrypter(); 26 virtual ~Aes128Gcm12Encrypter();
38 27
39 // QuicEncrypter implementation 28 #if !defined(USE_OPENSSL)
40 virtual bool SetKey(base::StringPiece key) OVERRIDE; 29 protected:
41 virtual bool SetNoncePrefix(base::StringPiece nonce_prefix) OVERRIDE; 30 // AeadBaseEncrypter methods:
42 virtual bool Encrypt(base::StringPiece nonce, 31 virtual void FillAeadParams(base::StringPiece nonce,
43 base::StringPiece associated_data, 32 base::StringPiece associated_data,
44 base::StringPiece plaintext, 33 size_t auth_tag_size,
45 unsigned char* output) OVERRIDE; 34 AeadParams* aead_params) const OVERRIDE;
46 virtual QuicData* EncryptPacket(QuicPacketSequenceNumber sequence_number,
47 base::StringPiece associated_data,
48 base::StringPiece plaintext) OVERRIDE;
49 virtual size_t GetKeySize() const OVERRIDE;
50 virtual size_t GetNoncePrefixSize() const OVERRIDE;
51 virtual size_t GetMaxPlaintextSize(size_t ciphertext_size) const OVERRIDE;
52 virtual size_t GetCiphertextSize(size_t plaintext_size) const OVERRIDE;
53 virtual base::StringPiece GetKey() const OVERRIDE;
54 virtual base::StringPiece GetNoncePrefix() const OVERRIDE;
55
56 private:
57 // The 128-bit AES key.
58 unsigned char key_[16];
59 // The nonce prefix.
60 unsigned char nonce_prefix_[4];
61
62 #if defined(USE_OPENSSL)
63 ScopedEVPAEADCtx ctx_;
64 #endif 35 #endif
65 }; 36 };
66 37
67 } // namespace net 38 } // namespace net
68 39
69 #endif // NET_QUIC_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_ 40 #endif // NET_QUIC_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/aes_128_gcm_12_decrypter_test.cc ('k') | net/quic/crypto/aes_128_gcm_12_encrypter_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698