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

Unified Diff: content/child/webcrypto/test/hmac_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/test/ecdsa_unittest.cc ('k') | content/child/webcrypto/test/rsa_ssa_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/test/hmac_unittest.cc
diff --git a/content/child/webcrypto/test/hmac_unittest.cc b/content/child/webcrypto/test/hmac_unittest.cc
index d57116c01bd83d5cc454d7fae96995b43a0614db..5ab559b2ee2910880008d3f643554215f2402746 100644
--- a/content/child/webcrypto/test/hmac_unittest.cc
+++ b/content/child/webcrypto/test/hmac_unittest.cc
@@ -121,7 +121,9 @@ TEST(WebCryptoHmacTest, GenerateKeyIsRandom) {
blink::WebCryptoKey key;
blink::WebCryptoAlgorithm algorithm =
CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha1, 512);
- ASSERT_EQ(Status::Success(), GenerateSecretKey(algorithm, true, 0, &key));
+ ASSERT_EQ(
+ Status::Success(),
+ GenerateSecretKey(algorithm, true, blink::WebCryptoKeyUsageSign, &key));
EXPECT_FALSE(key.isNull());
EXPECT_TRUE(key.handle());
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
@@ -146,7 +148,9 @@ TEST(WebCryptoHmacTest, GenerateKeyNoLengthSha1) {
blink::WebCryptoKey key;
blink::WebCryptoAlgorithm algorithm =
CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha1, 0);
- ASSERT_EQ(Status::Success(), GenerateSecretKey(algorithm, true, 0, &key));
+ ASSERT_EQ(
+ Status::Success(),
+ GenerateSecretKey(algorithm, true, blink::WebCryptoKeyUsageSign, &key));
EXPECT_TRUE(key.handle());
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, key.algorithm().id());
@@ -164,7 +168,9 @@ TEST(WebCryptoHmacTest, GenerateKeyNoLengthSha512) {
blink::WebCryptoKey key;
blink::WebCryptoAlgorithm algorithm =
CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha512, 0);
- ASSERT_EQ(Status::Success(), GenerateSecretKey(algorithm, true, 0, &key));
+ ASSERT_EQ(
+ Status::Success(),
+ GenerateSecretKey(algorithm, true, blink::WebCryptoKeyUsageSign, &key));
EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, key.algorithm().id());
EXPECT_EQ(blink::WebCryptoAlgorithmIdSha512,
key.algorithm().hmacParams()->hash().id());
@@ -175,6 +181,14 @@ TEST(WebCryptoHmacTest, GenerateKeyNoLengthSha512) {
EXPECT_EQ(128U, raw_key.size());
}
+TEST(WebCryptoHmacTest, GenerateKeyEmptyUsage) {
+ blink::WebCryptoKey key;
+ blink::WebCryptoAlgorithm algorithm =
+ CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha512, 0);
+ ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(),
+ GenerateSecretKey(algorithm, true, 0, &key));
+}
+
TEST(WebCryptoHmacTest, ImportKeyJwkKeyOpsSignVerify) {
blink::WebCryptoKey key;
base::DictionaryValue dict;
« no previous file with comments | « content/child/webcrypto/test/ecdsa_unittest.cc ('k') | content/child/webcrypto/test/rsa_ssa_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698