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.
This commit is contained in:
Ben Wiederhake 2024-10-21 00:43:38 +02:00 committed by Andrew Kaster
parent 85541f1e76
commit e1c3e212de

View File

@ -93,7 +93,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);
}