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

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

Issue 413523003: [webcrypto] Properly fail-fast when importing RSA key as JWK with bad usages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert patchset 5; won't generalize well for DH keys Created 6 years, 2 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
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( 313 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey(
314 blink::WebCryptoKeyFormat format, 314 blink::WebCryptoKeyFormat format,
315 blink::WebCryptoKeyUsageMask usages) const { 315 blink::WebCryptoKeyUsageMask usages) const {
316 switch (format) { 316 switch (format) {
317 case blink::WebCryptoKeyFormatSpki: 317 case blink::WebCryptoKeyFormatSpki:
318 return CheckKeyCreationUsages(all_public_key_usages_, usages); 318 return CheckKeyCreationUsages(all_public_key_usages_, usages);
319 case blink::WebCryptoKeyFormatPkcs8: 319 case blink::WebCryptoKeyFormatPkcs8:
320 return CheckKeyCreationUsages(all_private_key_usages_, usages); 320 return CheckKeyCreationUsages(all_private_key_usages_, usages);
321 case blink::WebCryptoKeyFormatJwk: 321 case blink::WebCryptoKeyFormatJwk:
322 // TODO(eroman): http://crbug.com/395904 322 // The JWK could represent either a public key or private key. The usages
323 return CheckKeyCreationUsages( 323 // must make sense for one of the two. The usages will be checked again by
324 all_public_key_usages_ | all_private_key_usages_, usages); 324 // ImportKeyJwk() once the key type has been determined.
325 if (CheckKeyCreationUsages(all_private_key_usages_, usages)
326 .IsSuccess() ||
327 CheckKeyCreationUsages(all_public_key_usages_, usages)
328 .IsSuccess()) {
329 return Status::Success();
330 }
331 return Status::ErrorCreateKeyBadUsages();
325 default: 332 default:
326 return Status::ErrorUnsupportedImportKeyFormat(); 333 return Status::ErrorUnsupportedImportKeyFormat();
327 } 334 }
328 } 335 }
329 336
330 Status RsaHashedAlgorithm::ImportKeyPkcs8( 337 Status RsaHashedAlgorithm::ImportKeyPkcs8(
331 const CryptoData& key_data, 338 const CryptoData& key_data,
332 const blink::WebCryptoAlgorithm& algorithm, 339 const blink::WebCryptoAlgorithm& algorithm,
333 bool extractable, 340 bool extractable,
334 blink::WebCryptoKeyUsageMask usages, 341 blink::WebCryptoKeyUsageMask usages,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return Status::Success(); 507 return Status::Success();
501 508
502 default: 509 default:
503 return Status::ErrorUnexpected(); 510 return Status::ErrorUnexpected();
504 } 511 }
505 } 512 }
506 513
507 } // namespace webcrypto 514 } // namespace webcrypto
508 515
509 } // namespace content 516 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/rsa_key_nss.cc ('k') | content/child/webcrypto/test/rsa_ssa_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698