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

Side by Side Diff: content/child/webcrypto/webcrypto_util.cc

Issue 777403004: [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 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 "content/child/webcrypto/webcrypto_util.h" 5 #include "content/child/webcrypto/webcrypto_util.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return Status::Success(); 222 return Status::Success();
223 223
224 // BoringSSL does not support 192-bit AES. 224 // BoringSSL does not support 192-bit AES.
225 if (keylen_bytes == 24) 225 if (keylen_bytes == 24)
226 return Status::ErrorAes192BitUnsupported(); 226 return Status::ErrorAes192BitUnsupported();
227 227
228 return Status::ErrorImportAesKeyLength(); 228 return Status::ErrorImportAesKeyLength();
229 } 229 }
230 230
231 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, 231 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages,
232 blink::WebCryptoKeyUsageMask actual_usages) { 232 blink::WebCryptoKeyUsageMask actual_usages,
233 bool check_usage) {
eroman 2014/12/09 21:04:46 This is poorly named -- the entire purpose of this
Habib Virji 2014/12/15 18:48:56 Done.
234 // In case import key calls this function, it checks for empty usage
eroman 2014/12/09 21:04:46 This comment is unnecessary (will apply to both im
Habib Virji 2014/12/15 18:48:56 Removed
235 if (check_usage && actual_usages == 0)
236 return Status::ErrorImportKeyEmptyUsages();
237
233 if (!ContainsKeyUsages(all_possible_usages, actual_usages)) 238 if (!ContainsKeyUsages(all_possible_usages, actual_usages))
234 return Status::ErrorCreateKeyBadUsages(); 239 return Status::ErrorCreateKeyBadUsages();
235 return Status::Success(); 240 return Status::Success();
236 } 241 }
237 242
238 Status GetRsaKeyGenParameters( 243 Status GetRsaKeyGenParameters(
239 const blink::WebCryptoRsaHashedKeyGenParams* params, 244 const blink::WebCryptoRsaHashedKeyGenParams* params,
240 unsigned int* public_exponent, 245 unsigned int* public_exponent,
241 unsigned int* modulus_length_bits) { 246 unsigned int* modulus_length_bits) {
242 *modulus_length_bits = params->modulusLengthBits(); 247 *modulus_length_bits = params->modulusLengthBits();
(...skipping 15 matching lines...) Expand all
258 // avoid feeding OpenSSL data that will hang use a whitelist. 263 // avoid feeding OpenSSL data that will hang use a whitelist.
259 if (*public_exponent != 3 && *public_exponent != 65537) 264 if (*public_exponent != 3 && *public_exponent != 65537)
260 return Status::ErrorGenerateKeyPublicExponent(); 265 return Status::ErrorGenerateKeyPublicExponent();
261 266
262 return Status::Success(); 267 return Status::Success();
263 } 268 }
264 269
265 } // namespace webcrypto 270 } // namespace webcrypto
266 271
267 } // namespace content 272 } // namespace content
OLDNEW
« content/child/webcrypto/test/rsa_ssa_unittest.cc ('K') | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698