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

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

Issue 757873003: Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix bad merges 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
« 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 6814c3580038b58930ab02babcca751e08223660..b62a362acecc8cb13ae0bd3d24ac537e2f03fac9 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -173,7 +173,7 @@ TEST(WebCryptoAesCbcTest, GenerateKeyIsRandom) {
ASSERT_EQ(Status::Success(),
GenerateSecretKey(
CreateAesCbcKeyGenAlgorithm(kKeyLength[key_length_i]), true,
- 0, &key));
+ blink::WebCryptoKeyUsageEncrypt, &key));
EXPECT_TRUE(key.handle());
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
ASSERT_EQ(Status::Success(),
@@ -463,6 +463,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.
@@ -489,7 +497,8 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
blink::WebCryptoAlgorithmIdSha256,
modulus_length, public_exponent),
- true, 0, &public_key, &private_key));
+ true, blink::WebCryptoKeyUsageSign, &public_key,
+ &private_key));
// Export key pair as SPKI + PKCS8
std::vector<uint8_t> public_key_spki;
@@ -532,8 +541,8 @@ TEST(WebCryptoAesCbcTest, WrapUnwrapRoundtripSpkiPkcs8) {
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;
« 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