1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibWeb: Add CryptoKeyPair object for use in upcoming SubtleCrypto APIs

This commit is contained in:
Andrew Kaster 2024-03-06 19:14:08 -07:00 committed by Andrew Kaster
parent 0a6f195a71
commit 810be6af07
2 changed files with 79 additions and 0 deletions

View file

@ -52,4 +52,28 @@ private:
InternalKeyData m_key_data;
};
// https://w3c.github.io/webcrypto/#ref-for-dfn-CryptoKeyPair-2
class CryptoKeyPair : public JS::Object {
JS_OBJECT(CryptoKeyPair, Object);
JS_DECLARE_ALLOCATOR(CryptoKeyPair);
public:
static JS::NonnullGCPtr<CryptoKeyPair> create(JS::Realm&, JS::NonnullGCPtr<CryptoKey> public_key, JS::NonnullGCPtr<CryptoKey> private_key);
virtual ~CryptoKeyPair() override = default;
JS::NonnullGCPtr<CryptoKey> public_key() const { return m_public_key; }
JS::NonnullGCPtr<CryptoKey> private_key() const { return m_private_key; }
private:
CryptoKeyPair(JS::Realm&, JS::NonnullGCPtr<CryptoKey> public_key, JS::NonnullGCPtr<CryptoKey> private_key);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor&) override;
JS_DECLARE_NATIVE_FUNCTION(public_key_getter);
JS_DECLARE_NATIVE_FUNCTION(private_key_getter);
JS::NonnullGCPtr<CryptoKey> m_public_key;
JS::NonnullGCPtr<CryptoKey> m_private_key;
};
}