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

Side by Side Diff: content/child/webcrypto/nss/aes_gcm_nss.cc

Issue 410743002: [refactor] Replace custom utility function with base's "vector_as_array()" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto master Created 6 years, 5 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
« no previous file with comments | « content/child/webcrypto/nss/aes_cbc_nss.cc ('k') | content/child/webcrypto/nss/hmac_nss.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 "base/numerics/safe_math.h" 5 #include "base/numerics/safe_math.h"
6 #include "base/stl_util.h"
6 #include "content/child/webcrypto/crypto_data.h" 7 #include "content/child/webcrypto/crypto_data.h"
7 #include "content/child/webcrypto/nss/aes_key_nss.h" 8 #include "content/child/webcrypto/nss/aes_key_nss.h"
8 #include "content/child/webcrypto/nss/key_nss.h" 9 #include "content/child/webcrypto/nss/key_nss.h"
9 #include "content/child/webcrypto/nss/util_nss.h" 10 #include "content/child/webcrypto/nss/util_nss.h"
10 #include "content/child/webcrypto/status.h" 11 #include "content/child/webcrypto/status.h"
11 #include "content/child/webcrypto/webcrypto_util.h" 12 #include "content/child/webcrypto/webcrypto_util.h"
12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
13 14
14 // At the time of this writing: 15 // At the time of this writing:
15 // * Windows and Mac builds ship with their own copy of NSS (3.15+) 16 // * Windows and Mac builds ship with their own copy of NSS (3.15+)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // However NSS has a bug whereby it will fail if the output buffer size is 106 // However NSS has a bug whereby it will fail if the output buffer size is
106 // not at least as large as the ciphertext: 107 // not at least as large as the ciphertext:
107 // 108 //
108 // https://bugzilla.mozilla.org/show_bug.cgi?id=%20853674 109 // https://bugzilla.mozilla.org/show_bug.cgi?id=%20853674
109 // 110 //
110 // From the analysis of that bug it looks like it might be safe to pass a 111 // From the analysis of that bug it looks like it might be safe to pass a
111 // correctly sized buffer but lie about its size. Since resizing the 112 // correctly sized buffer but lie about its size. Since resizing the
112 // WebCryptoArrayBuffer is expensive that hack may be worth looking into. 113 // WebCryptoArrayBuffer is expensive that hack may be worth looking into.
113 114
114 buffer->resize(buffer_size.ValueOrDie()); 115 buffer->resize(buffer_size.ValueOrDie());
115 unsigned char* buffer_data = Uint8VectorStart(buffer); 116 unsigned char* buffer_data = vector_as_array(buffer);
116 117
117 PK11_EncryptDecryptFunction encrypt_or_decrypt_func = 118 PK11_EncryptDecryptFunction encrypt_or_decrypt_func =
118 (mode == ENCRYPT) ? NssRuntimeSupport::Get()->pk11_encrypt_func() 119 (mode == ENCRYPT) ? NssRuntimeSupport::Get()->pk11_encrypt_func()
119 : NssRuntimeSupport::Get()->pk11_decrypt_func(); 120 : NssRuntimeSupport::Get()->pk11_decrypt_func();
120 121
121 unsigned int output_len = 0; 122 unsigned int output_len = 0;
122 SECStatus result = encrypt_or_decrypt_func(sym_key, 123 SECStatus result = encrypt_or_decrypt_func(sym_key,
123 CKM_AES_GCM, 124 CKM_AES_GCM,
124 &param, 125 &param,
125 buffer_data, 126 buffer_data,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 179
179 } // namespace 180 } // namespace
180 181
181 AlgorithmImplementation* CreatePlatformAesGcmImplementation() { 182 AlgorithmImplementation* CreatePlatformAesGcmImplementation() {
182 return new AesGcmImplementation; 183 return new AesGcmImplementation;
183 } 184 }
184 185
185 } // namespace webcrypto 186 } // namespace webcrypto
186 187
187 } // namespace content 188 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/aes_cbc_nss.cc ('k') | content/child/webcrypto/nss/hmac_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698