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

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: 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/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 59d4882466246c862579a2d40827a8606dfeaef7..9d1fa6ac012e7715a87cd546b6f407d8180f9328 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -195,10 +195,19 @@ TEST(WebCryptoAesCbcTest, GenerateKeyBadLength) {
SCOPED_TRACE(i);
EXPECT_EQ(Status::ErrorGenerateAesKeyLength(),
GenerateSecretKey(CreateAesCbcKeyGenAlgorithm(kKeyLen[i]), true,
- 0, &key));
+ blink::WebCryptoKeyUsageEncrypt, &key));
}
}
+TEST(WebCryptoAesCbcTest, ImportKeyEmptyUsage) {
+ blink::WebCryptoKey key;
+ ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(),
+ ImportKey(blink::WebCryptoKeyFormatRaw,
+ CryptoData(std::vector<uint8_t>(16)),
+ 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 +217,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(
@@ -533,8 +535,8 @@ 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;

Powered by Google App Engine
This is Rietveld 408576698