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

Side by Side Diff: content/child/webcrypto/openssl/ec_key_openssl.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/openssl/ec_key_openssl.h" 5 #include "content/child/webcrypto/openssl/ec_key_openssl.h"
6 6
7 #include <openssl/ec.h> 7 #include <openssl/ec.h>
8 #include <openssl/ec_key.h> 8 #include <openssl/ec_key.h>
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 #include <openssl/pkcs12.h> 10 #include <openssl/pkcs12.h>
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return status; 276 return status;
277 277
278 result->AssignKeyPair(public_key, private_key); 278 result->AssignKeyPair(public_key, private_key);
279 return Status::Success(); 279 return Status::Success();
280 } 280 }
281 281
282 // TODO(eroman): This is identical to RSA. 282 // TODO(eroman): This is identical to RSA.
283 Status EcAlgorithm::VerifyKeyUsagesBeforeImportKey( 283 Status EcAlgorithm::VerifyKeyUsagesBeforeImportKey(
284 blink::WebCryptoKeyFormat format, 284 blink::WebCryptoKeyFormat format,
285 blink::WebCryptoKeyUsageMask usages) const { 285 blink::WebCryptoKeyUsageMask usages) const {
286 bool checkEmptyUsage = true;
eroman 2014/12/09 21:04:46 Same comment as earlier.
286 switch (format) { 287 switch (format) {
287 case blink::WebCryptoKeyFormatSpki: 288 case blink::WebCryptoKeyFormatSpki:
288 return CheckKeyCreationUsages(all_public_key_usages_, usages); 289 return CheckKeyCreationUsages(all_public_key_usages_, usages,
290 checkEmptyUsage);
289 case blink::WebCryptoKeyFormatPkcs8: 291 case blink::WebCryptoKeyFormatPkcs8:
290 return CheckKeyCreationUsages(all_private_key_usages_, usages); 292 return CheckKeyCreationUsages(all_private_key_usages_, usages,
293 checkEmptyUsage);
291 case blink::WebCryptoKeyFormatJwk: 294 case blink::WebCryptoKeyFormatJwk:
292 // The JWK could represent either a public key or private key. The usages 295 // The JWK could represent either a public key or private key. The usages
293 // must make sense for one of the two. The usages will be checked again by 296 // must make sense for one of the two. The usages will be checked again by
294 // ImportKeyJwk() once the key type has been determined. 297 // ImportKeyJwk() once the key type has been determined.
295 if (CheckKeyCreationUsages(all_private_key_usages_, usages).IsSuccess() || 298 if (CheckKeyCreationUsages(all_private_key_usages_, usages,
296 CheckKeyCreationUsages(all_public_key_usages_, usages).IsSuccess()) { 299 checkEmptyUsage).IsSuccess() ||
300 CheckKeyCreationUsages(all_public_key_usages_, usages,
301 checkEmptyUsage).IsSuccess()) {
297 return Status::Success(); 302 return Status::Success();
298 } 303 }
299 return Status::ErrorCreateKeyBadUsages(); 304 return Status::ErrorCreateKeyBadUsages();
300 default: 305 default:
301 return Status::ErrorUnsupportedImportKeyFormat(); 306 return Status::ErrorUnsupportedImportKeyFormat();
302 } 307 }
303 } 308 }
304 309
305 Status EcAlgorithm::ImportKeyPkcs8(const CryptoData& key_data, 310 Status EcAlgorithm::ImportKeyPkcs8(const CryptoData& key_data,
306 const blink::WebCryptoAlgorithm& algorithm, 311 const blink::WebCryptoAlgorithm& algorithm,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 key->algorithm().ecParams()->namedCurve()) { 576 key->algorithm().ecParams()->namedCurve()) {
572 return Status::ErrorUnexpected(); 577 return Status::ErrorUnexpected();
573 } 578 }
574 579
575 return Status::Success(); 580 return Status::Success();
576 } 581 }
577 582
578 } // namespace webcrypto 583 } // namespace webcrypto
579 584
580 } // namespace content 585 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698