mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-11 21:52:53 +00:00
LibWeb: Implement WebCrypto AES-CBC importKey operation
This alone lets us pass around 40 WPT tests: WebCryptoAPI/import_export/symmetric_importKey.https.any
This commit is contained in:
parent
92d4cb7b09
commit
6f88376e24
Notes:
github-actions[bot]
2024-10-26 15:51:42 +00:00
Author: https://github.com/BenWiederhake
Commit: 6f88376e24
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1971
5 changed files with 262 additions and 2 deletions
|
@ -17,6 +17,7 @@ JS_DEFINE_ALLOCATOR(KeyAlgorithm);
|
|||
JS_DEFINE_ALLOCATOR(RsaKeyAlgorithm);
|
||||
JS_DEFINE_ALLOCATOR(RsaHashedKeyAlgorithm);
|
||||
JS_DEFINE_ALLOCATOR(EcKeyAlgorithm);
|
||||
JS_DEFINE_ALLOCATOR(AesKeyAlgorithm);
|
||||
|
||||
template<typename T>
|
||||
static JS::ThrowCompletionOr<T*> impl_from(JS::VM& vm, StringView Name)
|
||||
|
@ -183,4 +184,29 @@ JS_DEFINE_NATIVE_FUNCTION(RsaHashedKeyAlgorithm::hash_getter)
|
|||
});
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<AesKeyAlgorithm> AesKeyAlgorithm::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<AesKeyAlgorithm>(realm, realm);
|
||||
}
|
||||
|
||||
AesKeyAlgorithm::AesKeyAlgorithm(JS::Realm& realm)
|
||||
: KeyAlgorithm(realm)
|
||||
, m_length(0)
|
||||
{
|
||||
}
|
||||
|
||||
void AesKeyAlgorithm::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "length", length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(AesKeyAlgorithm::length_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from<AesKeyAlgorithm>(vm, "AesKeyAlgorithm"sv));
|
||||
auto length = TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->length(); }));
|
||||
return length;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue