mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Implement generateKey for ECDSA
This commit is contained in:
parent
cfae6523be
commit
41449814db
Notes:
sideshowbarker
2024-07-17 07:06:47 +09:00
Author: https://github.com/stelar7
Commit: 41449814db
Pull-request: https://github.com/SerenityOS/serenity/pull/23737
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/trflynn89
5 changed files with 201 additions and 0 deletions
|
@ -16,6 +16,7 @@ namespace Web::Crypto {
|
|||
JS_DEFINE_ALLOCATOR(KeyAlgorithm);
|
||||
JS_DEFINE_ALLOCATOR(RsaKeyAlgorithm);
|
||||
JS_DEFINE_ALLOCATOR(RsaHashedKeyAlgorithm);
|
||||
JS_DEFINE_ALLOCATOR(EcKeyAlgorithm);
|
||||
|
||||
template<typename T>
|
||||
static JS::ThrowCompletionOr<T*> impl_from(JS::VM& vm, StringView Name)
|
||||
|
@ -119,6 +120,34 @@ JS_DEFINE_NATIVE_FUNCTION(RsaKeyAlgorithm::public_exponent_getter)
|
|||
return impl->public_exponent();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<EcKeyAlgorithm> EcKeyAlgorithm::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<EcKeyAlgorithm>(realm, realm);
|
||||
}
|
||||
|
||||
EcKeyAlgorithm::EcKeyAlgorithm(JS::Realm& realm)
|
||||
: KeyAlgorithm(realm)
|
||||
{
|
||||
}
|
||||
|
||||
void EcKeyAlgorithm::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
|
||||
define_native_accessor(realm, "namedCurve", named_curve_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(EcKeyAlgorithm::named_curve_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from<EcKeyAlgorithm>(vm, "EcKeyAlgorithm"sv));
|
||||
return JS::PrimitiveString::create(vm, impl->named_curve());
|
||||
}
|
||||
|
||||
void EcKeyAlgorithm::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<RsaHashedKeyAlgorithm> RsaHashedKeyAlgorithm::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<RsaHashedKeyAlgorithm>(realm, realm);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue