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

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

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing use_openssl (requires WebRTC change to compile) Created 4 years, 8 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
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_AEAD_BASE_ENCRYPTER_H_ 5 #ifndef NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_
6 #define NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_ 6 #define NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
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/crypto/quic_encrypter.h" 12 #include "net/quic/crypto/quic_encrypter.h"
13 13
14 #if defined(USE_OPENSSL)
15 #include "net/quic/crypto/scoped_evp_aead_ctx.h" 14 #include "net/quic/crypto/scoped_evp_aead_ctx.h"
16 #else
17 #include <pkcs11t.h>
18 #endif
19 15
20 namespace net { 16 namespace net {
21 17
22 // AeadBaseEncrypter is the base class of AEAD QuicEncrypter subclasses. 18 // AeadBaseEncrypter is the base class of AEAD QuicEncrypter subclasses.
23 class NET_EXPORT_PRIVATE AeadBaseEncrypter : public QuicEncrypter { 19 class NET_EXPORT_PRIVATE AeadBaseEncrypter : public QuicEncrypter {
24 public: 20 public:
25 #if defined(USE_OPENSSL)
26 AeadBaseEncrypter(const EVP_AEAD* aead_alg, 21 AeadBaseEncrypter(const EVP_AEAD* aead_alg,
27 size_t key_size, 22 size_t key_size,
28 size_t auth_tag_size, 23 size_t auth_tag_size,
29 size_t nonce_prefix_size); 24 size_t nonce_prefix_size);
30 #else
31 AeadBaseEncrypter(CK_MECHANISM_TYPE aead_mechanism,
32 size_t key_size,
33 size_t auth_tag_size,
34 size_t nonce_prefix_size);
35 #endif
36 ~AeadBaseEncrypter() override; 25 ~AeadBaseEncrypter() override;
37 26
38 // QuicEncrypter implementation 27 // QuicEncrypter implementation
39 bool SetKey(base::StringPiece key) override; 28 bool SetKey(base::StringPiece key) override;
40 bool SetNoncePrefix(base::StringPiece nonce_prefix) override; 29 bool SetNoncePrefix(base::StringPiece nonce_prefix) override;
41 bool EncryptPacket(QuicPathId path_id, 30 bool EncryptPacket(QuicPathId path_id,
42 QuicPacketNumber packet_number, 31 QuicPacketNumber packet_number,
43 base::StringPiece associated_data, 32 base::StringPiece associated_data,
44 base::StringPiece plaintext, 33 base::StringPiece plaintext,
45 char* output, 34 char* output,
(...skipping 13 matching lines...) Expand all
59 base::StringPiece plaintext, 48 base::StringPiece plaintext,
60 unsigned char* output); 49 unsigned char* output);
61 50
62 protected: 51 protected:
63 // Make these constants available to the subclasses so that the subclasses 52 // Make these constants available to the subclasses so that the subclasses
64 // can assert at compile time their key_size_ and nonce_prefix_size_ do not 53 // can assert at compile time their key_size_ and nonce_prefix_size_ do not
65 // exceed the maximum. 54 // exceed the maximum.
66 static const size_t kMaxKeySize = 32; 55 static const size_t kMaxKeySize = 32;
67 static const size_t kMaxNoncePrefixSize = 4; 56 static const size_t kMaxNoncePrefixSize = 4;
68 57
69 #if !defined(USE_OPENSSL)
70 struct AeadParams {
71 unsigned int len;
72 union {
73 CK_GCM_PARAMS gcm_params;
74 CK_NSS_AEAD_PARAMS nss_aead_params;
75 } data;
76 };
77
78 virtual void FillAeadParams(base::StringPiece nonce,
79 base::StringPiece associated_data,
80 size_t auth_tag_size,
81 AeadParams* aead_params) const = 0;
82 #endif
83
84 private: 58 private:
85 #if defined(USE_OPENSSL)
86 const EVP_AEAD* const aead_alg_; 59 const EVP_AEAD* const aead_alg_;
87 #else
88 const CK_MECHANISM_TYPE aead_mechanism_;
89 #endif
90 const size_t key_size_; 60 const size_t key_size_;
91 const size_t auth_tag_size_; 61 const size_t auth_tag_size_;
92 const size_t nonce_prefix_size_; 62 const size_t nonce_prefix_size_;
93 63
94 // The key. 64 // The key.
95 unsigned char key_[kMaxKeySize]; 65 unsigned char key_[kMaxKeySize];
96 // The nonce prefix. 66 // The nonce prefix.
97 unsigned char nonce_prefix_[kMaxNoncePrefixSize]; 67 unsigned char nonce_prefix_[kMaxNoncePrefixSize];
98 68
99 #if defined(USE_OPENSSL)
100 ScopedEVPAEADCtx ctx_; 69 ScopedEVPAEADCtx ctx_;
101 #endif
102 70
103 DISALLOW_COPY_AND_ASSIGN(AeadBaseEncrypter); 71 DISALLOW_COPY_AND_ASSIGN(AeadBaseEncrypter);
104 }; 72 };
105 73
106 } // namespace net 74 } // namespace net
107 75
108 #endif // NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_ 76 #endif // NET_QUIC_CRYPTO_AEAD_BASE_ENCRYPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698