LibCrypto: Fix HMAC nullptr deref when key has length 0

While a key of length zero seems like a bad idea in general, the WPT
tests end up calling exactly this, so we need to support it one way or
another.

(cherry picked from commit e1c3e212defe92b4afe36e8184ffda5a08d0abdb)
This commit is contained in:
Ben Wiederhake authored and Nico Weber committed 2024-11-12 07:14:25 -05:00
1 parent 6598ff9926
commit 729b0e25be
1 file changed
+1 -1
@@ -98,7 +98,7 @@ private:
auto digest = m_inner_hasher.digest();
// FIXME: should we check if the hash function creates more data than its block size?
key_buffer.overwrite(0, digest.immutable_data(), m_inner_hasher.digest_size());
} else {
} else if (length > 0) {
key_buffer.overwrite(0, key, length);
}