LibWeb: Define EcKeyImportParams

This commit is contained in:
devgianlu 2024-11-26 17:53:33 +01:00 committed by Andreas Kling
commit fd336ed619
Notes: github-actions[bot] 2024-11-27 10:01:21 +00:00
2 changed files with 29 additions and 0 deletions

View file

@ -609,6 +609,21 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcdhKeyDerivePrams::from_v
return adopt_own<AlgorithmParams>(*new EcdhKeyDerivePrams { name, key }); return adopt_own<AlgorithmParams>(*new EcdhKeyDerivePrams { name, key });
} }
EcKeyImportParams::~EcKeyImportParams() = default;
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcKeyImportParams::from_value(JS::VM& vm, JS::Value value)
{
auto& object = value.as_object();
auto name_value = TRY(object.get("name"));
auto name = TRY(name_value.to_string(vm));
auto named_curve_value = TRY(object.get("namedCurve"));
auto named_curve = TRY(named_curve_value.to_string(vm));
return adopt_own<AlgorithmParams>(*new EcKeyImportParams { name, named_curve });
}
HmacImportParams::~HmacImportParams() = default; HmacImportParams::~HmacImportParams() = default;
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HmacImportParams::from_value(JS::VM& vm, JS::Value value) JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> HmacImportParams::from_value(JS::VM& vm, JS::Value value)

View file

@ -591,6 +591,20 @@ struct EcdhKeyDerivePrams : public AlgorithmParams {
static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value); static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value);
}; };
struct EcKeyImportParams : public AlgorithmParams {
virtual ~EcKeyImportParams() override;
EcKeyImportParams(String name, String named_curve)
: AlgorithmParams(move(name))
, named_curve(move(named_curve))
{
}
String named_curve;
static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value);
};
ErrorOr<String> base64_url_uint_encode(::Crypto::UnsignedBigInteger); ErrorOr<String> base64_url_uint_encode(::Crypto::UnsignedBigInteger);
WebIDL::ExceptionOr<ByteBuffer> base64_url_bytes_decode(JS::Realm&, String const& base64_url_string); WebIDL::ExceptionOr<ByteBuffer> base64_url_bytes_decode(JS::Realm&, String const& base64_url_string);
WebIDL::ExceptionOr<::Crypto::UnsignedBigInteger> base64_url_uint_decode(JS::Realm&, String const& base64_url_string); WebIDL::ExceptionOr<::Crypto::UnsignedBigInteger> base64_url_uint_decode(JS::Realm&, String const& base64_url_string);