mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Implement Encapsulate(Key|Bits) dictionaries
These are needed structure for the encapsulate(Key|Bits) operations.
This commit is contained in:
parent
1d6a64b26c
commit
42f55c7c97
Notes:
github-actions[bot]
2025-11-27 20:51:24 +00:00
Author: https://github.com/tete17
Commit: 42f55c7c97
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6961
Reviewed-by: https://github.com/gmta ✅
3 changed files with 54 additions and 0 deletions
|
|
@ -274,6 +274,32 @@ static WebIDL::ExceptionOr<ByteBuffer> generate_random_key(JS::VM& vm, u16 const
|
||||||
return key_buffer;
|
return key_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JS::ThrowCompletionOr<GC::Ref<JS::Object>> EncapsulatedKey::to_object(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||||
|
|
||||||
|
if (shared_key.has_value())
|
||||||
|
TRY(object->create_data_property("shared_key"_utf16_fly_string, shared_key.value()));
|
||||||
|
|
||||||
|
if (ciphertext.has_value())
|
||||||
|
TRY(object->create_data_property("ciphertext"_utf16_fly_string, JS::ArrayBuffer::create(realm, ciphertext.value())));
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
JS::ThrowCompletionOr<GC::Ref<JS::Object>> EncapsulatedBits::to_object(JS::Realm& realm)
|
||||||
|
{
|
||||||
|
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||||
|
|
||||||
|
if (shared_key.has_value())
|
||||||
|
TRY(object->create_data_property("shared_key"_utf16_fly_string, JS::ArrayBuffer::create(realm, shared_key.value())));
|
||||||
|
|
||||||
|
if (ciphertext.has_value())
|
||||||
|
TRY(object->create_data_property("ciphertext"_utf16_fly_string, JS::ArrayBuffer::create(realm, ciphertext.value())));
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
AlgorithmParams::~AlgorithmParams() = default;
|
AlgorithmParams::~AlgorithmParams() = default;
|
||||||
|
|
||||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AlgorithmParams::from_value(JS::VM&, JS::Value)
|
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AlgorithmParams::from_value(JS::VM&, JS::Value)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,22 @@ using AlgorithmIdentifier = Variant<GC::Root<JS::Object>, String>;
|
||||||
using NamedCurve = String;
|
using NamedCurve = String;
|
||||||
using KeyDataType = Variant<GC::Root<WebIDL::BufferSource>, Bindings::JsonWebKey>;
|
using KeyDataType = Variant<GC::Root<WebIDL::BufferSource>, Bindings::JsonWebKey>;
|
||||||
|
|
||||||
|
// https://wicg.github.io/webcrypto-modern-algos/#encapsulation
|
||||||
|
struct EncapsulatedKey {
|
||||||
|
Optional<GC::Root<CryptoKey>> shared_key;
|
||||||
|
Optional<ByteBuffer> ciphertext;
|
||||||
|
|
||||||
|
JS::ThrowCompletionOr<GC::Ref<JS::Object>> to_object(JS::Realm&);
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://wicg.github.io/webcrypto-modern-algos/#encapsulation
|
||||||
|
struct EncapsulatedBits {
|
||||||
|
Optional<ByteBuffer> shared_key;
|
||||||
|
Optional<ByteBuffer> ciphertext;
|
||||||
|
|
||||||
|
JS::ThrowCompletionOr<GC::Ref<JS::Object>> to_object(JS::Realm&);
|
||||||
|
};
|
||||||
|
|
||||||
struct HashAlgorithmIdentifier : public AlgorithmIdentifier {
|
struct HashAlgorithmIdentifier : public AlgorithmIdentifier {
|
||||||
using AlgorithmIdentifier::AlgorithmIdentifier;
|
using AlgorithmIdentifier::AlgorithmIdentifier;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,18 @@ dictionary JsonWebKey {
|
||||||
DOMString k;
|
DOMString k;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://wicg.github.io/webcrypto-modern-algos/#encapsulation
|
||||||
|
dictionary EncapsulatedKey {
|
||||||
|
CryptoKey sharedKey;
|
||||||
|
ArrayBuffer ciphertext;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://wicg.github.io/webcrypto-modern-algos/#encapsulation
|
||||||
|
dictionary EncapsulatedBits {
|
||||||
|
ArrayBuffer sharedKey;
|
||||||
|
ArrayBuffer ciphertext;
|
||||||
|
};
|
||||||
|
|
||||||
// https://w3c.github.io/webcrypto/#subtlecrypto-interface
|
// https://w3c.github.io/webcrypto/#subtlecrypto-interface
|
||||||
[SecureContext,Exposed=(Window,Worker)]
|
[SecureContext,Exposed=(Window,Worker)]
|
||||||
interface SubtleCrypto {
|
interface SubtleCrypto {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue