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

Unified Diff: content/child/webcrypto/test/ecdh_unittest.cc

Issue 777403004: [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated issues in ecdh tests and other review comments. Created 6 years 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
Index: content/child/webcrypto/test/ecdh_unittest.cc
diff --git a/content/child/webcrypto/test/ecdh_unittest.cc b/content/child/webcrypto/test/ecdh_unittest.cc
index 4e255f02913ea4ac3f48a2361fca6464bbf14425..822013f6cc5058755f5d1c7e73bfbadfa6c3f8d6 100644
--- a/content/child/webcrypto/test/ecdh_unittest.cc
+++ b/content/child/webcrypto/test/ecdh_unittest.cc
@@ -316,6 +316,40 @@ TEST(WebCryptoEcdhTest, DeriveKeyAes128) {
EXPECT_EQ(16u, raw_key.size());
}
+TEST(WebCryptoEcdhTest, ImportKeyEmptyUsage) {
+ if (!SupportsEcdh())
+ return;
+
+ blink::WebCryptoKey key;
+
+ scoped_ptr<base::ListValue> tests;
+ ASSERT_TRUE(ReadJsonTestFileToList("ecdh.json", &tests));
+
+ const base::DictionaryValue* test;
+ ASSERT_TRUE(tests->GetDictionary(0, &test));
+
+ // Import the public key.
+ const base::DictionaryValue* public_key_json = NULL;
+ EXPECT_TRUE(test->GetDictionary("public_key", &public_key_json));
+ blink::WebCryptoNamedCurve curve =
+ GetCurveNameFromDictionary(public_key_json, "crv");
+ ASSERT_EQ(Status::Success(),
+ ImportKey(blink::WebCryptoKeyFormatJwk,
+ CryptoData(MakeJsonVector(*public_key_json)),
+ CreateEcdhImportAlgorithm(curve), true, 0, &key));
+ EXPECT_EQ(0, key.usages());
+
+ // Import the private key.
+ const base::DictionaryValue* private_key_json = NULL;
+ EXPECT_TRUE(test->GetDictionary("private_key", &private_key_json));
+ curve = GetCurveNameFromDictionary(private_key_json, "crv");
+ ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(),
+ ImportKey(blink::WebCryptoKeyFormatJwk,
+ CryptoData(MakeJsonVector(*private_key_json)),
+ CreateEcdhImportAlgorithm(curve), true,
+ 0, &key));
+}
+
} // namespace
} // namespace webcrypto

Powered by Google App Engine
This is Rietveld 408576698