Skip to content

PublicKeyParts: provide serialization helpers #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2025

Conversation

baloo
Copy link
Member

@baloo baloo commented May 22, 2025

When serializing the exponent or the modulus from a key, BoxedUint::to_be_bytes will return a slice padded with zeroes on the left because of its inner representation. Not every implementation out there will handle leading zeroes.

This provides a PublicKeyParts::n_bytes/e_bytes that will strip out those leading zeros.

See #518 for more context.

Depends:

Fixes #518

@baloo baloo force-pushed the baloo/publickeyparts/e_bytes branch from a93ca2b to b94a57c Compare May 22, 2025 23:06
@baloo baloo force-pushed the baloo/publickeyparts/e_bytes branch from b94a57c to db44475 Compare May 22, 2025 23:35
@baloo baloo marked this pull request as draft May 22, 2025 23:36
@baloo baloo force-pushed the baloo/publickeyparts/e_bytes branch 2 times, most recently from 2936e1d to 2664d4b Compare May 23, 2025 03:27
tarcieri pushed a commit to RustCrypto/crypto-bigint that referenced this pull request May 23, 2025
…824)

This helpers strips the leading zeroes from the serialization.

See:
 - RustCrypto/RSA#519
 - RustCrypto/RSA#518
When serializing the exponent or the modulus from a key,
`BoxedUint::to_be_bytes` will return a slice padded with zeroes on the
left because of its inner representation. Not every implementation out
there will handle leading zeroes.

This provides a `PublicKeyParts::n_bytes`/`e_bytes` that will strip out those
leading zeros.
@baloo baloo marked this pull request as ready for review May 23, 2025 17:43
@baloo baloo force-pushed the baloo/publickeyparts/e_bytes branch from 2664d4b to fb67d6a Compare May 23, 2025 17:43
@tarcieri tarcieri merged commit 731f5d3 into RustCrypto:master May 24, 2025
11 checks passed
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.

usability: exponent serialization
2 participants