LibWeb: Implement skeleton of RSA-OAEP encrypt for SubtleCrypto

The actual Crypto algorithm part isn't implemented yet, so we just copy
the plaintext and claim that's the ciphertext :^)
This commit is contained in:
Andrew Kaster 2024-03-14 23:07:13 -06:00 committed by Andrew Kaster
commit 29b68a1b10
Notes: sideshowbarker 2024-07-17 09:37:30 +09:00
3 changed files with 69 additions and 1 deletions

View file

@ -102,6 +102,21 @@ struct RsaHashedImportParams : public AlgorithmParams {
static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value);
};
// https://w3c.github.io/webcrypto/#dfn-RsaOaepParams
struct RsaOaepParams : public AlgorithmParams {
virtual ~RsaOaepParams() override;
RsaOaepParams(String name, ByteBuffer label)
: AlgorithmParams(move(name))
, label(move(label))
{
}
ByteBuffer label;
static JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> from_value(JS::VM&, JS::Value);
};
class AlgorithmMethods {
public:
virtual ~AlgorithmMethods();
@ -149,6 +164,8 @@ protected:
class RSAOAEP : public AlgorithmMethods {
public:
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> encrypt(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;
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<CryptoKey>> import_key(AlgorithmParams const&, Bindings::KeyFormat, CryptoKey::InternalKeyData, bool, Vector<Bindings::KeyUsage> const&) override;