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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/openssl/rsa_key_openssl.cc
diff --git a/content/child/webcrypto/openssl/rsa_key_openssl.cc b/content/child/webcrypto/openssl/rsa_key_openssl.cc
index 4d01c8eda2ea8057124c88ac2c3500163f914eff..554b55c726857846d1b07a4fede0863dc5f622e7 100644
--- a/content/child/webcrypto/openssl/rsa_key_openssl.cc
+++ b/content/child/webcrypto/openssl/rsa_key_openssl.cc
@@ -319,9 +319,16 @@ Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey(
case blink::WebCryptoKeyFormatPkcs8:
return CheckKeyCreationUsages(all_private_key_usages_, usages);
case blink::WebCryptoKeyFormatJwk:
- // TODO(eroman): http://crbug.com/395904
- return CheckKeyCreationUsages(
- all_public_key_usages_ | all_private_key_usages_, usages);
+ // The JWK could represent either a public key or private key. The usages
+ // must make sense for one of the two. The usages will be checked again by
+ // ImportKeyJwk() once the key type has been determined.
+ if (CheckKeyCreationUsages(all_private_key_usages_, usages)
+ .IsSuccess() ||
+ CheckKeyCreationUsages(all_public_key_usages_, usages)
+ .IsSuccess()) {
+ return Status::Success();
+ }
+ return Status::ErrorCreateKeyBadUsages();
default:
return Status::ErrorUnsupportedImportKeyFormat();
}
« 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