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

Side by Side Diff: content/child/webcrypto/openssl/rsa_key_openssl.cc

Issue 689883002: Throw a SyntaxError when importing keys with invalid usages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | content/child/webcrypto/status.h » ('j') | content/child/webcrypto/status.h » ('J')
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 "content/child/webcrypto/openssl/rsa_key_openssl.h" 5 #include "content/child/webcrypto/openssl/rsa_key_openssl.h"
6 6
7 #include <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/pkcs12.h> 8 #include <openssl/pkcs12.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 case blink::WebCryptoKeyFormatJwk: 321 case blink::WebCryptoKeyFormatJwk:
322 // The JWK could represent either a public key or private key. The usages 322 // The JWK could represent either a public key or private key. The usages
323 // must make sense for one of the two. The usages will be checked again by 323 // must make sense for one of the two. The usages will be checked again by
324 // ImportKeyJwk() once the key type has been determined. 324 // ImportKeyJwk() once the key type has been determined.
325 if (CheckKeyCreationUsages(all_private_key_usages_, usages) 325 if (CheckKeyCreationUsages(all_private_key_usages_, usages)
326 .IsSuccess() || 326 .IsSuccess() ||
327 CheckKeyCreationUsages(all_public_key_usages_, usages) 327 CheckKeyCreationUsages(all_public_key_usages_, usages)
328 .IsSuccess()) { 328 .IsSuccess()) {
329 return Status::Success(); 329 return Status::Success();
330 } 330 }
331 return Status::ErrorCreateKeyBadUsages(); 331 return Status::SyntaxError("usages");
332 default: 332 default:
333 return Status::ErrorUnsupportedImportKeyFormat(); 333 return Status::ErrorUnsupportedImportKeyFormat();
334 } 334 }
335 } 335 }
336 336
337 Status RsaHashedAlgorithm::ImportKeyPkcs8( 337 Status RsaHashedAlgorithm::ImportKeyPkcs8(
338 const CryptoData& key_data, 338 const CryptoData& key_data,
339 const blink::WebCryptoAlgorithm& algorithm, 339 const blink::WebCryptoAlgorithm& algorithm,
340 bool extractable, 340 bool extractable,
341 blink::WebCryptoKeyUsageMask usages, 341 blink::WebCryptoKeyUsageMask usages,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return Status::Success(); 507 return Status::Success();
508 508
509 default: 509 default:
510 return Status::ErrorUnexpected(); 510 return Status::ErrorUnexpected();
511 } 511 }
512 } 512 }
513 513
514 } // namespace webcrypto 514 } // namespace webcrypto
515 515
516 } // namespace content 516 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/status.h » ('j') | content/child/webcrypto/status.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698