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

Unified Diff: components/webcrypto/algorithms/rsa_ssa_unittest.cc

Issue 2163053002: [webcrypto] Check for empty key usages *after* key creation rather than before, to match the spec's… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 | « components/webcrypto/algorithms/rsa.cc ('k') | components/webcrypto/algorithms/secret_key_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webcrypto/algorithms/rsa_ssa_unittest.cc
diff --git a/components/webcrypto/algorithms/rsa_ssa_unittest.cc b/components/webcrypto/algorithms/rsa_ssa_unittest.cc
index 5d5c4fee5ccf10a6287da6ec59ee4a3fd8b5b580..fea882a5f392c639a30955702ce2204e9130a2b3 100644
--- a/components/webcrypto/algorithms/rsa_ssa_unittest.cc
+++ b/components/webcrypto/algorithms/rsa_ssa_unittest.cc
@@ -965,21 +965,15 @@ TEST_F(WebCryptoRsaSsaTest, ImportJwkRsaFailures) {
}
// Try importing an RSA-SSA key from JWK format, having specified both Sign and
-// Verify usage, and an invalid JWK.
+// 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_F(WebCryptoRsaSsaTest, ImportRsaSsaJwkBadUsageFailFast) {
- CryptoData bad_data(NULL, 128); // Invalid buffer of length 128.
+// Parsing the invalid JWK will fail before the usage check is done.
+TEST_F(WebCryptoRsaSsaTest, ImportRsaSsaJwkBadUsageAndData) {
+ std::string bad_data = "hello";
blink::WebCryptoKey key;
- ASSERT_EQ(Status::ErrorCreateKeyBadUsages(),
- ImportKey(blink::WebCryptoKeyFormatJwk, bad_data,
+ ASSERT_EQ(Status::ErrorJwkNotDictionary(),
+ ImportKey(blink::WebCryptoKeyFormatJwk, CryptoData(bad_data),
CreateRsaHashedImportAlgorithm(
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
blink::WebCryptoAlgorithmIdSha256),
« no previous file with comments | « components/webcrypto/algorithms/rsa.cc ('k') | components/webcrypto/algorithms/secret_key_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698