Skip to content

Conversation

@xoudini
Copy link

@xoudini xoudini commented Dec 31, 2025

Switches the ECDSA signer to use BugNum::to_vec_padded to ensure the signature is twice the component length for each curve.

Fixes #1 (as far as I can tell).

@xoudini xoudini changed the title Ensure correct signature length fix: ensure correct signature length Dec 31, 2025
@xoudini
Copy link
Author

xoudini commented Dec 31, 2025

The same issue exists in Jwk::try_from:

lers/src/api/jws.rs

Lines 122 to 123 in 991a275

x: BASE64.encode(x.to_vec()),
y: BASE64.encode(y.to_vec()),

Every now and then when either BigNum ends up with 8 (or more) leading zero bits, this error is produced:

Parse error reading JWS: failed to unmarshal JWK: go-jose/go-jose: invalid EC public key, wrong length for x: \"{\\\"crv\\\":\\\"P-256\\\",\\\"kty\\\":\\\"EC\\\",\\\"x\\\":\\\"rdYu9rs4jFRTSPIUiUryoHNu_j32BLaLEK3ZzVLc9w\\\",\\\"y\\\":\\\"eAgyilCBWz-FUUXdhpOPmBxdvbWsphsT-ep-paCx8-k\\\"}

With some formatting of the data:

{
  "crv": "P-256",
  "kty": "EC",
  "x": "rdYu9rs4jFRTSPIUiUryoHNu_j32BLaLEK3ZzVLc9w",
  "y": "eAgyilCBWz-FUUXdhpOPmBxdvbWsphsT-ep-paCx8-k"
}

...where x turns out to be 31 bytes instead of the expected 32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix flakey JWS signing implementation

1 participant