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

Unified Diff: content/child/webcrypto/test/aes_cbc_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: 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/aes_cbc_unittest.cc
diff --git a/content/child/webcrypto/test/aes_cbc_unittest.cc b/content/child/webcrypto/test/aes_cbc_unittest.cc
index 6814c3580038b58930ab02babcca751e08223660..ea803e9c97306bf97a747e88a2237a5eddfc76b2 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -199,6 +199,16 @@ TEST(WebCryptoAesCbcTest, GenerateKeyBadLength) {
}
}
+TEST(WebCryptoAesCbcTest, ImportKeyEmptyUsage) {
+ blink::WebCryptoKey key;
+ std::vector<uint8_t> key_bytes(16);
+ ASSERT_EQ(Status::ErrorImportEmptyKeyUsage(),
+ ImportKey(blink::WebCryptoKeyFormatRaw,
+ CryptoData(key_bytes),
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
+ true, 0, &key));
+}
+
// If key_ops is specified but empty, no key usages are allowed for the key.
TEST(WebCryptoAesCbcTest, ImportKeyJwkEmptyKeyOps) {
blink::WebCryptoKey key;
@@ -208,13 +218,6 @@ TEST(WebCryptoAesCbcTest, ImportKeyJwkEmptyKeyOps) {
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg");
dict.Set("key_ops", new base::ListValue); // Takes ownership.
- EXPECT_EQ(Status::Success(),
- ImportKeyJwkFromDict(
- dict, CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), false,
- 0, &key));
-
- EXPECT_EQ(0, key.usages());
-
// The JWK does not contain encrypt usages.
EXPECT_EQ(Status::ErrorJwkKeyopsInconsistent(),
ImportKeyJwkFromDict(
@@ -524,16 +527,16 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
ASSERT_EQ(
Status::Success(),
UnwrapKey(blink::WebCryptoKeyFormatSpki, CryptoData(wrapped_public_key),
- wrapping_key, wrap_algorithm, rsa_import_algorithm, true, 0,
- &unwrapped_public_key));
+ wrapping_key, wrap_algorithm, rsa_import_algorithm, true,
+ blink::WebCryptoKeyUsageVerify, &unwrapped_public_key));
blink::WebCryptoKey unwrapped_private_key;
ASSERT_EQ(
Status::Success(),
UnwrapKey(blink::WebCryptoKeyFormatPkcs8, CryptoData(wrapped_private_key),
- wrapping_key, wrap_algorithm, rsa_import_algorithm, true, 0,
- &unwrapped_private_key));
+ wrapping_key, wrap_algorithm, rsa_import_algorithm, true,
+ blink::WebCryptoKeyUsageSign, &unwrapped_private_key));
// Export unwrapped key pair as SPKI + PKCS8
std::vector<uint8_t> unwrapped_public_key_spki;

Powered by Google App Engine
This is Rietveld 408576698