mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Fix X25519
JWK key export format
The presence of padding in the base64 fields made plenty of WPT tests fail. The issue was discovered while implementing `wrapKey` and `unwrapKey` in the next commits.
This commit is contained in:
parent
08af878466
commit
ac99e2791f
Notes:
github-actions[bot]
2024-12-16 10:36:27 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/ac99e2791f4 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2915
2 changed files with 25 additions and 25 deletions
|
@ -5222,7 +5222,7 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> X25519::export_key(Bindings::KeyFormat
|
|||
// 4. Set the x attribute of jwk according to the definition in Section 2 of [RFC8037].
|
||||
if (key->type() == Bindings::KeyType::Public) {
|
||||
auto public_key = handle.get<ByteBuffer>();
|
||||
jwk.x = TRY_OR_THROW_OOM(vm, encode_base64url(public_key));
|
||||
jwk.x = TRY_OR_THROW_OOM(vm, encode_base64url(public_key, AK::OmitPadding::Yes));
|
||||
} else {
|
||||
// The "x" parameter of the "epk" field is set as follows:
|
||||
// Apply the appropriate ECDH function to the ephemeral private key (as scalar input)
|
||||
|
@ -5230,14 +5230,14 @@ WebIDL::ExceptionOr<GC::Ref<JS::Object>> X25519::export_key(Bindings::KeyFormat
|
|||
// The base64url encoding of the output is the value for the "x" parameter of the "epk" field.
|
||||
::Crypto::Curves::X25519 curve;
|
||||
auto public_key = TRY_OR_THROW_OOM(vm, curve.generate_public_key(handle.get<ByteBuffer>()));
|
||||
jwk.x = TRY_OR_THROW_OOM(vm, encode_base64url(public_key));
|
||||
jwk.x = TRY_OR_THROW_OOM(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].
|
||||
auto private_key = handle.get<ByteBuffer>();
|
||||
jwk.d = TRY_OR_THROW_OOM(vm, encode_base64url(private_key));
|
||||
jwk.d = TRY_OR_THROW_OOM(vm, encode_base64url(private_key, AK::OmitPadding::Yes));
|
||||
}
|
||||
|
||||
// 6. Set the key_ops attribute of jwk to the usages attribute of key.
|
||||
|
|
|
@ -2,40 +2,40 @@ Harness status: OK
|
|||
|
||||
Found 54 tests
|
||||
|
||||
26 Pass
|
||||
28 Fail
|
||||
46 Pass
|
||||
8 Fail
|
||||
Pass Good parameters: X25519 bits (spki, buffer(44), {name: X25519}, true, [])
|
||||
Pass Good parameters: X25519 bits (spki, buffer(44), X25519, true, [])
|
||||
Fail Good parameters: X25519 bits (jwk, object(kty, crv, x), {name: X25519}, true, [])
|
||||
Fail Good parameters: X25519 bits (jwk, object(kty, crv, x), X25519, true, [])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(kty, crv, x), {name: X25519}, true, [])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(kty, crv, x), X25519, true, [])
|
||||
Pass Good parameters: X25519 bits (jwk, object(kty, crv, x), {name: X25519}, true, [])
|
||||
Pass Good parameters: X25519 bits (jwk, object(kty, crv, x), X25519, true, [])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(kty, crv, x), {name: X25519}, true, [])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(kty, crv, x), X25519, true, [])
|
||||
Pass Good parameters: X25519 bits (raw, buffer(32), {name: X25519}, true, [])
|
||||
Pass Good parameters: X25519 bits (raw, buffer(32), X25519, true, [])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), {name: X25519}, true, [deriveKey])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), X25519, true, [deriveKey])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveKey])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveKey])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveKey])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveKey])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), {name: X25519}, true, [deriveBits, deriveKey])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), X25519, true, [deriveBits, deriveKey])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits, deriveKey])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveBits, deriveKey])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits, deriveKey])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveBits, deriveKey])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits, deriveKey])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveBits, deriveKey])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits, deriveKey])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveBits, deriveKey])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), {name: X25519}, true, [deriveBits])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), X25519, true, [deriveBits])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveBits])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveBits])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveBits])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveBits])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveBits])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), {name: X25519}, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Fail Good parameters: X25519 bits (pkcs8, buffer(48), X25519, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Fail Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Fail Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Pass Good parameters: X25519 bits (jwk, object(crv, d, x, kty), X25519, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), {name: X25519}, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Pass Good parameters with ignored JWK alg: X25519 (jwk, object(crv, d, x, kty), X25519, true, [deriveKey, deriveBits, deriveKey, deriveBits])
|
||||
Pass Good parameters: X25519 bits (spki, buffer(44), {name: X25519}, false, [])
|
||||
Pass Good parameters: X25519 bits (spki, buffer(44), X25519, false, [])
|
||||
Pass Good parameters: X25519 bits (jwk, object(kty, crv, x), {name: X25519}, false, [])
|
||||
|
|
Loading…
Add table
Reference in a new issue