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

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

Issue 745443002: Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more tests Created 6 years, 1 month 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 c6fe95dab2617a1777f6e5e875902b0dade28e8c..3eb9877b3906226b8ca5bcb32c5ffd6469790815 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -265,7 +265,7 @@ TEST(WebCryptoAesCbcTest, GenerateKeyIsRandom) {
GenerateSecretKey(
CreateAesCbcKeyGenAlgorithm(kKeyLength[key_length_i]),
true,
- 0,
+ blink::WebCryptoKeyUsageEncrypt,
&key));
EXPECT_TRUE(key.handle());
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
@@ -962,6 +962,15 @@ TEST(WebCryptoAesCbcTest, GenerateKeyBadUsages) {
}
}
+// Generate an AES-CBC key with no usages.
+TEST(WebCryptoAesCbcTest, GenerateKeyEmptyUsages) {
+ blink::WebCryptoKey key;
+
+ ASSERT_EQ(Status::ErrorCreateKeyBadUsages(),
+ GenerateSecretKey(
+ CreateAesCbcKeyGenAlgorithm(128), true, 0, &key));
+}
+
// Generate an AES-CBC key and an RSA key pair. Use the AES-CBC key to wrap the
// key pair (using SPKI format for public key, PKCS8 format for private key).
// Then unwrap the wrapped key pair and verify that the key data is the same.
@@ -991,7 +1000,7 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
modulus_length,
public_exponent),
true,
- 0,
+ blink::WebCryptoKeyUsageSign,
&public_key,
&private_key));
@@ -1053,7 +1062,7 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
wrap_algorithm,
rsa_import_algorithm,
true,
- 0,
+ blink::WebCryptoKeyUsageSign,
&unwrapped_private_key));
// Export unwrapped key pair as SPKI + PKCS8

Powered by Google App Engine
This is Rietveld 408576698