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

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: 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
« no previous file with comments | « content/child/webcrypto/status.cc ('k') | content/child/webcrypto/test/aes_gcm_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b54e6339ff8cbe4f5b74892fa05aa5ea46d1e2c1 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -263,10 +263,8 @@ TEST(WebCryptoAesCbcTest, GenerateKeyIsRandom) {
for (int j = 0; j < 16; ++j) {
ASSERT_EQ(Status::Success(),
GenerateSecretKey(
- CreateAesCbcKeyGenAlgorithm(kKeyLength[key_length_i]),
- true,
- 0,
- &key));
+ CreateAesCbcKeyGenAlgorithm(kKeyLength[key_length_i]), true,
+ blink::WebCryptoKeyUsageEncrypt, &key));
EXPECT_TRUE(key.handle());
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
ASSERT_EQ(Status::Success(),
@@ -962,6 +960,14 @@ TEST(WebCryptoAesCbcTest, GenerateKeyBadUsages) {
}
}
+// Generate an AES-CBC key with no usages.
+TEST(WebCryptoAesCbcTest, GenerateKeyEmptyUsages) {
+ blink::WebCryptoKey key;
+
+ ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(),
+ 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.
@@ -988,11 +994,8 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
GenerateKeyPair(CreateRsaHashedKeyGenAlgorithm(
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
blink::WebCryptoAlgorithmIdSha256,
- modulus_length,
- public_exponent),
- true,
- 0,
- &public_key,
+ modulus_length, public_exponent),
+ true, blink::WebCryptoKeyUsageSign, &public_key,
&private_key));
// Export key pair as SPKI + PKCS8
@@ -1046,15 +1049,11 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
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));
+ ASSERT_EQ(
+ Status::Success(),
+ UnwrapKey(blink::WebCryptoKeyFormatPkcs8, CryptoData(wrapped_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;
« no previous file with comments | « content/child/webcrypto/status.cc ('k') | content/child/webcrypto/test/aes_gcm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698