LibWeb: Implement skeleton of ECDSA sign for SubtleCrypto

This commit is contained in:
stelar7 2024-03-27 01:34:04 +01:00 committed by Andrew Kaster
commit bc2a5e24bc
Notes: sideshowbarker 2024-07-17 01:06:10 +09:00
5 changed files with 113 additions and 0 deletions

View file

@ -117,6 +117,22 @@ struct RsaOaepParams : public AlgorithmParams {
static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value);
};
// https://w3c.github.io/webcrypto/#dfn-EcdsaParams
struct EcdsaParams : public AlgorithmParams {
virtual ~EcdsaParams() override;
EcdsaParams(String name, HashAlgorithmIdentifier hash)
: AlgorithmParams(move(name))
, hash(move(hash))
{
}
HashAlgorithmIdentifier hash;
static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value);
};
// https://w3c.github.io/webcrypto/#dfn-EcKeyGenParams
struct EcKeyGenParams : public AlgorithmParams {
virtual ~EcKeyGenParams() override;
@ -229,6 +245,8 @@ private:
class ECDSA : public AlgorithmMethods {
public:
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> sign(AlgorithmParams const&, JS::NonnullGCPtr<CryptoKey>, ByteBuffer const&) override;
virtual WebIDL::ExceptionOr<Variant<JS::NonnullGCPtr<CryptoKey>, JS::NonnullGCPtr<CryptoKeyPair>>> generate_key(AlgorithmParams const&, bool, Vector<Bindings::KeyUsage> const&) override;
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new ECDSA(realm)); }