Index: content/child/webcrypto/shared_crypto.cc |
diff --git a/content/child/webcrypto/shared_crypto.cc b/content/child/webcrypto/shared_crypto.cc |
index cffdcc54dd9dc5290db18c08244ba8274e394d9b..580754ae47966343874aee1766ea68b8d2672d52 100644 |
--- a/content/child/webcrypto/shared_crypto.cc |
+++ b/content/child/webcrypto/shared_crypto.cc |
@@ -315,8 +315,15 @@ Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
const blink::WebCryptoHmacKeyGenParams* params = |
algorithm.hmacKeyGenParams(); |
DCHECK(params); |
+#if defined(WEBCRYPTO_HMAC_BITS) |
+ if (params->hasLengthBits()) { |
+ if (params->optionalLengthBits() % 8) |
+ return Status::ErrorGenerateKeyLength(); |
+ keylen_bytes = params->optionalLengthBits() / 8; |
+#else |
if (params->hasLengthBytes()) { |
keylen_bytes = params->optionalLengthBytes(); |
+#endif |
} else { |
keylen_bytes = ShaBlockSizeBytes(params->hash().id()); |
if (keylen_bytes == 0) |