diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index fb3c22fafdc..f7c64e39a01 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -609,6 +609,21 @@ JS::ThrowCompletionOr> EcdhKeyDerivePrams::from_v return adopt_own(*new EcdhKeyDerivePrams { name, key }); } +EcKeyImportParams::~EcKeyImportParams() = default; + +JS::ThrowCompletionOr> 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(*new EcKeyImportParams { name, named_curve }); +} + HmacImportParams::~HmacImportParams() = default; JS::ThrowCompletionOr> HmacImportParams::from_value(JS::VM& vm, JS::Value value) diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.h b/Libraries/LibWeb/Crypto/CryptoAlgorithms.h index 09cb1a936ad..538c9a556f1 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.h +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.h @@ -591,6 +591,20 @@ struct EcdhKeyDerivePrams : public AlgorithmParams { static JS::ThrowCompletionOr> 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> from_value(JS::VM&, JS::Value); +}; + ErrorOr base64_url_uint_encode(::Crypto::UnsignedBigInteger); WebIDL::ExceptionOr 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);