LibWeb: Expose SHA3 hashing algorithm through WebCryptoAPI

This give us 48 WPT subtests :)
This commit is contained in:
Tete17 2025-11-26 19:37:04 +01:00 committed by Tim Flynn
parent 0786486aa2
commit 5e736d4e07
Notes: github-actions[bot] 2025-11-27 03:01:53 +00:00
5 changed files with 196 additions and 0 deletions

View file

@ -3639,6 +3639,12 @@ WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> SHA::digest(AlgorithmParams const&
hash_kind = ::Crypto::Hash::HashKind::SHA384;
} else if (algorithm_name == "SHA-512") {
hash_kind = ::Crypto::Hash::HashKind::SHA512;
} else if (algorithm_name == "SHA3-256") {
hash_kind = ::Crypto::Hash::HashKind::SHA3_256;
} else if (algorithm_name == "SHA3-384") {
hash_kind = ::Crypto::Hash::HashKind::SHA3_384;
} else if (algorithm_name == "SHA3-512") {
hash_kind = ::Crypto::Hash::HashKind::SHA3_512;
} else {
return WebIDL::NotSupportedError::create(m_realm, Utf16String::formatted("Invalid hash function '{}'", algorithm_name));
}

View file

@ -1152,6 +1152,11 @@ SupportedAlgorithmsMap const& supported_algorithms()
define_an_algorithm<SHA>("digest"_string, "SHA-384"_string);
define_an_algorithm<SHA>("digest"_string, "SHA-512"_string);
// https://wicg.github.io/webcrypto-modern-algos/#sha3-registration
define_an_algorithm<SHA>("digest"_string, "SHA3-256"_string);
define_an_algorithm<SHA>("digest"_string, "SHA3-384"_string);
define_an_algorithm<SHA>("digest"_string, "SHA3-512"_string);
// https://w3c.github.io/webcrypto/#hkdf-registration
define_an_algorithm<HKDF, HKDFParams>("deriveBits"_string, "HKDF"_string);
define_an_algorithm<HKDF>("importKey"_string, "HKDF"_string);