Skip to content

Conversation

@mendess
Copy link
Contributor

@mendess mendess commented Jan 26, 2026

We need to use rsa keys with large exponents, this was something that was a breaking change introduced in 2edd479#diff-0988d5d2259e1a401001675578c38d09c46290b877b66b07fb96a7e034ccdf70L274-R273

This commit mostly moves code around to avoid having duplicate code and introduces RsaPrivateKey::from_components_with_large_exponent as a way to support this use case

Comment on lines 416 to 427
/// # ⚠️ Warning: Hazmat!
///
/// This method accepts public exponents outside the standard bounds (2 ≤ e ≤ 2^33-1),
/// but still performs full cryptographic validation to ensure the key is mathematically
/// correct (i.e., verifies that de ≡ 1 mod λ(n)).
///
/// This is intended for interoperating with systems that use non-standard exponents
/// or loading legacy keys. Use [`RsaPrivateKey::from_components`] for standard key
/// construction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to add some citations on why large public exponents are bad to deter use: https://www.imperialviolet.org/2012/03/17/rsados.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@pinkforest
Copy link
Contributor

pinkforest commented Jan 27, 2026

fwiw for long term I think the whole construct is redundant when the key can be expressed through trait impl (and it's associated types) where we can impl it for the common things

I also allows expressivity to stack based things without copying things given trait provided methods can provide validation.

@mendess mendess force-pushed the private-key-unchecked branch from 200eec9 to 7002035 Compare January 27, 2026 12:03
@tarcieri tarcieri changed the title Re add support for large exponents in rsa private keys Add RsaPrivateKey::from_components_with_large_exponent Jan 27, 2026
@tarcieri tarcieri merged commit 2d2bf43 into RustCrypto:master Jan 27, 2026
12 checks passed
@mendess mendess deleted the private-key-unchecked branch January 29, 2026 11:24
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.

3 participants