LibCrypto: Implement KMAC authentication support

Add a LibCrypto::Authentication::KMAC helper over OpenSSL.
Add keygen/import/export logic into WebCrypto.
Register KMAC128/KMAC256 operations with SubtleCrypto.
This commit is contained in:
mikiubo
2026-03-15 08:09:09 +01:00
committed by Jelle Raaijmakers
parent 6cc575b8a9
commit d4cf537d58
Notes: github-actions[bot] 2026-03-19 09:47:56 +00:00
12 changed files with 1230 additions and 564 deletions

View File

@@ -21,6 +21,7 @@ GC_DEFINE_ALLOCATOR(RsaHashedKeyAlgorithm);
GC_DEFINE_ALLOCATOR(EcKeyAlgorithm);
GC_DEFINE_ALLOCATOR(AesKeyAlgorithm);
GC_DEFINE_ALLOCATOR(HmacKeyAlgorithm);
GC_DEFINE_ALLOCATOR(KmacKeyAlgorithm);
template<typename T>
static JS::ThrowCompletionOr<T*> impl_from(JS::VM& vm, StringView Name)
@@ -237,4 +238,26 @@ JS_DEFINE_NATIVE_FUNCTION(HmacKeyAlgorithm::length_getter)
return TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->length(); }));
}
GC::Ref<KmacKeyAlgorithm> KmacKeyAlgorithm::create(JS::Realm& realm)
{
return realm.create<KmacKeyAlgorithm>(realm);
}
KmacKeyAlgorithm::KmacKeyAlgorithm(JS::Realm& realm)
: KeyAlgorithm(realm)
{
}
void KmacKeyAlgorithm::initialize(JS::Realm& realm)
{
Base::initialize(realm);
define_native_accessor(realm, "length"_utf16_fly_string, length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
}
JS_DEFINE_NATIVE_FUNCTION(KmacKeyAlgorithm::length_getter)
{
auto* impl = TRY(impl_from<KmacKeyAlgorithm>(vm, "KmacKeyAlgorithm"sv));
return TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->length(); }));
}
}