mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-21 02:22:51 +00:00
LibWeb: Fix X448
JWK key export format
The presence of padding in the base64 fields made plenty of WPT tests fail. Additionally, export was performed with the wrong public key. The issue was discovered while implementing `wrapKey` and `unwrapKey` in the next commits.
This commit is contained in:
parent
ac99e2791f
commit
880401030d
Notes:
github-actions[bot]
2024-12-16 10:36:22 +00:00
Author: https://github.com/devgianlu
Commit: 880401030d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2915
2 changed files with 30 additions and 24 deletions
|
@ -5463,12 +5463,18 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> X448::export_key(Bindings::KeyFormat fo
|
|||
jwk.crv = "X448"_string;
|
||||
|
||||
// 4. Set the x attribute of jwk according to the definition in Section 2 of [RFC8037].
|
||||
jwk.x = TRY_OR_THROW_OOM(m_realm->vm(), encode_base64url(key_data));
|
||||
if (key->type() == Bindings::KeyType::Public) {
|
||||
jwk.x = TRY_OR_THROW_OOM(m_realm->vm(), encode_base64url(key_data, AK::OmitPadding::Yes));
|
||||
} else {
|
||||
::Crypto::Curves::X448 curve;
|
||||
auto public_key = TRY_OR_THROW_OOM(m_realm->vm(), curve.generate_public_key(key_data));
|
||||
jwk.x = TRY_OR_THROW_OOM(m_realm->vm(), encode_base64url(public_key, AK::OmitPadding::Yes));
|
||||
}
|
||||
|
||||
// 5. If the [[type]] internal slot of key is "private"
|
||||
if (key->type() == Bindings::KeyType::Private) {
|
||||
// 1. Set the d attribute of jwk according to the definition in Section 2 of [RFC8037].
|
||||
jwk.d = TRY_OR_THROW_OOM(m_realm->vm(), encode_base64url(key_data));
|
||||
jwk.d = TRY_OR_THROW_OOM(m_realm->vm(), encode_base64url(key_data, AK::OmitPadding::Yes));
|
||||
}
|
||||
|
||||
// 6. Set the key_ops attribute of jwk to the usages attribute of key.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue