Skip to content

Commit

Permalink
LibWeb: Always return a KeyAlgorithm from RsaHashedKeyAlgorithm
Browse files Browse the repository at this point in the history
The spec never mentions the possibility for the `hash` member of
`RsaHashedKeyAlgorithm` to be a string, it should be a `KeyAlgorithm`
object containing a `name` string member.

Does not fix any WPT test now, but will eventually.

Spec: https://w3c.github.io/webcrypto/#dfn-RsaHashedKeyAlgorithm
  • Loading branch information
devgianlu committed Jan 12, 2025
1 parent 39a678c commit 1b3e1df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Libraries/LibWeb/Crypto/KeyAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ JS_DEFINE_NATIVE_FUNCTION(RsaHashedKeyAlgorithm::hash_getter)
auto hash = TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return impl->hash(); }));
return hash.visit(
[&](String const& hash_string) -> JS::Value {
return JS::PrimitiveString::create(vm, hash_string);
auto& realm = *vm.current_realm();
auto object = JS::Object::create(realm, realm.intrinsics().object_prototype());
MUST(object->create_data_property("name", JS::PrimitiveString::create(vm, hash_string)));
return object;
},
[&](GC::Root<JS::Object> const& hash) -> JS::Value {
return hash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
);
println(key.extractable);
println(key.algorithm.name);
println(key.algorithm.hash);
println(key.algorithm.hash.name);
println(key.algorithm.publicExponent);
done();
});
Expand Down

0 comments on commit 1b3e1df

Please sign in to comment.