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

Unified Diff: content/child/webcrypto/test/rsa_ssa_unittest.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/openssl/rsa_key_openssl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/test/rsa_ssa_unittest.cc
diff --git a/content/child/webcrypto/test/rsa_ssa_unittest.cc b/content/child/webcrypto/test/rsa_ssa_unittest.cc
index 81f510126b7862b7a06335ee51d88020ed108a95..31f23c1424f93e963c2fa785c1ef5f5a4a3fe90e 100644
--- a/content/child/webcrypto/test/rsa_ssa_unittest.cc
+++ b/content/child/webcrypto/test/rsa_ssa_unittest.cc
@@ -1200,6 +1200,32 @@ TEST(WebCryptoRsaSsaTest, ImportJwkRsaFailures) {
}
}
+// Try importing an RSA-SSA key from JWK format, having specified both Sign and
+// Verify usage, and an invalid JWK.
+//
+// The test must fail with a usage error BEFORE attempting to read the JWK data.
+// Although both Sign and Verify are valid usages for RSA-SSA keys, it is
+// invalid to have them both at the same time for one key (since Sign applies to
+// private keys, whereas Verify applies to public keys).
+//
+// If the implementation does not fail fast, this test will crash dereferencing
+// invalid memory.
+TEST(WebCryptoRsaSsaTest, ImportRsaSsaJwkBadUsageFailFast) {
+ CryptoData bad_data(NULL, 128); // Invalid buffer of length 128.
+
+ blink::WebCryptoKey key;
+ ASSERT_EQ(
+ Status::ErrorCreateKeyBadUsages(),
+ ImportKey(blink::WebCryptoKeyFormatJwk,
+ bad_data,
+ CreateRsaHashedImportAlgorithm(
+ blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
+ blink::WebCryptoAlgorithmIdSha256),
+ true,
+ blink::WebCryptoKeyUsageVerify | blink::WebCryptoKeyUsageSign,
+ &key));
+}
+
} // namespace
} // namespace webcrypto
« no previous file with comments | « content/child/webcrypto/openssl/rsa_key_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698