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

Side by Side Diff: net/quic/crypto/chacha20_poly1305_encrypter_nss.cc

Issue 1082123003: Rename USE_NSS to USE_NSS_CERTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-nss-certs
Patch Set: rebase Created 5 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
« no previous file with comments | « net/quic/crypto/chacha20_poly1305_decrypter_nss.cc ('k') | net/socket/client_socket_factory.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "net/quic/crypto/chacha20_poly1305_encrypter.h" 5 #include "net/quic/crypto/chacha20_poly1305_encrypter.h"
6 6
7 #include <pk11pub.h> 7 #include <pk11pub.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 using base::StringPiece; 11 using base::StringPiece;
12 12
13 namespace net { 13 namespace net {
14 14
15 namespace { 15 namespace {
16 16
17 const size_t kKeySize = 32; 17 const size_t kKeySize = 32;
18 const size_t kNoncePrefixSize = 0; 18 const size_t kNoncePrefixSize = 0;
19 19
20 } // namespace 20 } // namespace
21 21
22 #if defined(USE_NSS) 22 #if defined(USE_NSS_CERTS)
23 23
24 // System NSS doesn't support ChaCha20+Poly1305 yet. 24 // System NSS doesn't support ChaCha20+Poly1305 yet.
25 25
26 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter() 26 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter()
27 : AeadBaseEncrypter(CKM_INVALID_MECHANISM, nullptr, kKeySize, 27 : AeadBaseEncrypter(CKM_INVALID_MECHANISM, nullptr, kKeySize,
28 kAuthTagSize, kNoncePrefixSize) { 28 kAuthTagSize, kNoncePrefixSize) {
29 NOTIMPLEMENTED(); 29 NOTIMPLEMENTED();
30 } 30 }
31 31
32 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {} 32 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {}
33 33
34 // static 34 // static
35 bool ChaCha20Poly1305Encrypter::IsSupported() { 35 bool ChaCha20Poly1305Encrypter::IsSupported() {
36 return false; 36 return false;
37 } 37 }
38 38
39 void ChaCha20Poly1305Encrypter::FillAeadParams(StringPiece nonce, 39 void ChaCha20Poly1305Encrypter::FillAeadParams(StringPiece nonce,
40 StringPiece associated_data, 40 StringPiece associated_data,
41 size_t auth_tag_size, 41 size_t auth_tag_size,
42 AeadParams* aead_params) const { 42 AeadParams* aead_params) const {
43 NOTIMPLEMENTED(); 43 NOTIMPLEMENTED();
44 } 44 }
45 45
46 #else // defined(USE_NSS) 46 #else // defined(USE_NSS_CERTS)
47 47
48 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter() 48 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter()
49 : AeadBaseEncrypter(CKM_NSS_CHACHA20_POLY1305, PK11_Encrypt, kKeySize, 49 : AeadBaseEncrypter(CKM_NSS_CHACHA20_POLY1305, PK11_Encrypt, kKeySize,
50 kAuthTagSize, kNoncePrefixSize) { 50 kAuthTagSize, kNoncePrefixSize) {
51 static_assert(kKeySize <= kMaxKeySize, "key size too big"); 51 static_assert(kKeySize <= kMaxKeySize, "key size too big");
52 static_assert(kNoncePrefixSize <= kMaxNoncePrefixSize, 52 static_assert(kNoncePrefixSize <= kMaxNoncePrefixSize,
53 "nonce prefix size too big"); 53 "nonce prefix size too big");
54 } 54 }
55 55
56 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {} 56 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {}
(...skipping 11 matching lines...) Expand all
68 CK_NSS_AEAD_PARAMS* nss_aead_params = &aead_params->data.nss_aead_params; 68 CK_NSS_AEAD_PARAMS* nss_aead_params = &aead_params->data.nss_aead_params;
69 nss_aead_params->pIv = 69 nss_aead_params->pIv =
70 reinterpret_cast<CK_BYTE*>(const_cast<char*>(nonce.data())); 70 reinterpret_cast<CK_BYTE*>(const_cast<char*>(nonce.data()));
71 nss_aead_params->ulIvLen = nonce.size(); 71 nss_aead_params->ulIvLen = nonce.size();
72 nss_aead_params->pAAD = 72 nss_aead_params->pAAD =
73 reinterpret_cast<CK_BYTE*>(const_cast<char*>(associated_data.data())); 73 reinterpret_cast<CK_BYTE*>(const_cast<char*>(associated_data.data()));
74 nss_aead_params->ulAADLen = associated_data.size(); 74 nss_aead_params->ulAADLen = associated_data.size();
75 nss_aead_params->ulTagLen = auth_tag_size; 75 nss_aead_params->ulTagLen = auth_tag_size;
76 } 76 }
77 77
78 #endif // defined(USE_NSS) 78 #endif // defined(USE_NSS_CERTS)
79 79
80 } // namespace net 80 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/chacha20_poly1305_decrypter_nss.cc ('k') | net/socket/client_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698