Index: content/child/webcrypto/shared_crypto_unittest.cc |
diff --git a/content/child/webcrypto/shared_crypto_unittest.cc b/content/child/webcrypto/shared_crypto_unittest.cc |
index 55c3bb7a57a75a35305d7f46148e27ed28001044..814a26fb45ff31d140754e9e2ac4a3504cf9fdab 100644 |
--- a/content/child/webcrypto/shared_crypto_unittest.cc |
+++ b/content/child/webcrypto/shared_crypto_unittest.cc |
@@ -675,6 +675,9 @@ TEST_F(SharedCryptoTest, HMACSampleSets) { |
blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify); |
EXPECT_EQ(test_hash.id(), key.algorithm().hmacParams()->hash().id()); |
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH) |
+ EXPECT_EQ(test_key.size() * 8, key.algorithm().hmacParams()->lengthBits()); |
+#endif |
// Verify exported raw key is identical to the imported data |
blink::WebArrayBuffer raw_key; |
@@ -955,6 +958,9 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmac)) { |
EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, key.algorithm().id()); |
EXPECT_EQ(blink::WebCryptoAlgorithmIdSha1, |
key.algorithm().hmacParams()->hash().id()); |
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH) |
+ EXPECT_EQ(512u, key.algorithm().hmacParams()->lengthBits()); |
+#endif |
blink::WebArrayBuffer raw_key; |
ASSERT_STATUS_SUCCESS( |
@@ -975,6 +981,12 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmacNoLength)) { |
ASSERT_STATUS_SUCCESS(GenerateSecretKey(algorithm, true, 0, &key)); |
EXPECT_TRUE(key.handle()); |
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
+ EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, key.algorithm().id()); |
+ EXPECT_EQ(blink::WebCryptoAlgorithmIdSha1, |
+ key.algorithm().hmacParams()->hash().id()); |
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH) |
+ EXPECT_EQ(512u, key.algorithm().hmacParams()->lengthBits()); |
+#endif |
blink::WebArrayBuffer raw_key; |
ASSERT_STATUS_SUCCESS(ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
EXPECT_EQ(64U, raw_key.byteLength()); |
@@ -982,8 +994,12 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmacNoLength)) { |
// The block size for HMAC SHA-512 is larger. |
algorithm = CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha512, 0); |
ASSERT_STATUS_SUCCESS(GenerateSecretKey(algorithm, true, 0, &key)); |
+ EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, key.algorithm().id()); |
EXPECT_EQ(blink::WebCryptoAlgorithmIdSha512, |
key.algorithm().hmacParams()->hash().id()); |
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH) |
+ EXPECT_EQ(1024u, key.algorithm().hmacParams()->lengthBits()); |
+#endif |
ASSERT_STATUS_SUCCESS(ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
EXPECT_EQ(128U, raw_key.byteLength()); |
} |
@@ -1360,6 +1376,9 @@ TEST_F(SharedCryptoTest, MAYBE(ImportJwkInputConsistency)) { |
EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, key.algorithm().id()); |
EXPECT_EQ(blink::WebCryptoAlgorithmIdSha256, |
key.algorithm().hmacParams()->hash().id()); |
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH) |
+ EXPECT_EQ(320u, key.algorithm().hmacParams()->lengthBits()); |
+#endif |
EXPECT_EQ(blink::WebCryptoKeyUsageVerify, key.usages()); |
key = blink::WebCryptoKey::createNull(); |
@@ -2618,6 +2637,9 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwJwkSymkeyUnwrapKnownData)) { |
EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, unwrapped_key.algorithm().id()); |
EXPECT_EQ(blink::WebCryptoAlgorithmIdSha256, |
unwrapped_key.algorithm().hmacParams()->hash().id()); |
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH) |
+ EXPECT_EQ(256u, unwrapped_key.algorithm().hmacParams()->lengthBits()); |
+#endif |
EXPECT_EQ(true, unwrapped_key.extractable()); |
EXPECT_EQ(blink::WebCryptoKeyUsageVerify, unwrapped_key.usages()); |