diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index 25fd18a8556..f4fedd7e696 100644 --- a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -598,7 +598,7 @@ JS::ThrowCompletionOr> SubtleCrypto::verify(AlgorithmId } // https://w3c.github.io/webcrypto/#SubtleCrypto-method-deriveBits -JS::ThrowCompletionOr> SubtleCrypto::derive_bits(AlgorithmIdentifier algorithm, GC::Ref base_key, u32 length) +JS::ThrowCompletionOr> SubtleCrypto::derive_bits(AlgorithmIdentifier algorithm, GC::Ref base_key, Optional length_optional) { auto& realm = this->realm(); // 1. Let algorithm, baseKey and length, be the algorithm, baseKey and length parameters passed to the deriveBits() method, respectively. @@ -614,7 +614,7 @@ JS::ThrowCompletionOr> SubtleCrypto::derive_bits(Algori auto promise = WebIDL::create_promise(realm); // 5. Return promise and perform the remaining steps in parallel. - Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, base_key, length]() -> void { + Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, base_key, length_optional]() -> void { HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes); // 6. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm. @@ -631,7 +631,7 @@ JS::ThrowCompletionOr> SubtleCrypto::derive_bits(Algori } // 9. Let result be the result of creating an ArrayBuffer containing the result of performing the derive bits operation specified by normalizedAlgorithm using baseKey, algorithm and length. - auto result = normalized_algorithm.methods->derive_bits(*normalized_algorithm.parameter, base_key, length); + auto result = normalized_algorithm.methods->derive_bits(*normalized_algorithm.parameter, base_key, length_optional); if (result.is_error()) { WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value()); return; diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Libraries/LibWeb/Crypto/SubtleCrypto.h index 014e9b478d2..054187d847f 100644 --- a/Libraries/LibWeb/Crypto/SubtleCrypto.h +++ b/Libraries/LibWeb/Crypto/SubtleCrypto.h @@ -34,7 +34,7 @@ public: GC::Ref digest(AlgorithmIdentifier const& algorithm, GC::Root const& data); JS::ThrowCompletionOr> generate_key(AlgorithmIdentifier algorithm, bool extractable, Vector key_usages); - JS::ThrowCompletionOr> derive_bits(AlgorithmIdentifier algorithm, GC::Ref base_key, u32 length); + JS::ThrowCompletionOr> derive_bits(AlgorithmIdentifier algorithm, GC::Ref base_key, Optional length_optional); JS::ThrowCompletionOr> derive_key(AlgorithmIdentifier algorithm, GC::Ref base_key, AlgorithmIdentifier derived_key_type, bool extractable, Vector key_usages); JS::ThrowCompletionOr> import_key(Bindings::KeyFormat format, KeyDataType key_data, AlgorithmIdentifier algorithm, bool extractable, Vector key_usages); diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.idl b/Libraries/LibWeb/Crypto/SubtleCrypto.idl index bf47ba840d1..18b141e002b 100644 --- a/Libraries/LibWeb/Crypto/SubtleCrypto.idl +++ b/Libraries/LibWeb/Crypto/SubtleCrypto.idl @@ -53,7 +53,8 @@ interface SubtleCrypto { Promise generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence keyUsages); Promise deriveKey(AlgorithmIdentifier algorithm, CryptoKey baseKey, AlgorithmIdentifier derivedKeyType, boolean extractable, sequence keyUsages); - Promise deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, unsigned long length); + // FIXME: Promise deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, optional unsigned long? length = null); + Promise deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, optional unsigned long? length); Promise importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolean extractable, sequence keyUsages); Promise exportKey(KeyFormat format, CryptoKey key);