Continue refactoring of RSA crate internals#304
Merged
tarcieri merged 8 commits intoRustCrypto:masterfrom Apr 23, 2023
Merged
Conversation
Make generate_multi_prime_key_with_exp() generic enough to generate abstract key structure. Rewrite RsaPrivateKey constructors to use RsaPrivateKey::from_components(). Signed-off-by: Dmitry Baryshkov <[email protected]>
Move PublicKeyParts to the separate module. Signed-off-by: Dmitry Baryshkov <[email protected]>
Make internals.rs generic enough to be moved to the algorithms module. Signed-off-by: Dmitry Baryshkov <[email protected]>
Separate software RSA implementation to separate module under crate::algorithms. Signed-off-by: Dmitry Baryshkov <[email protected]>
Now as raw_int_encryption_primitive() and raw_int_decryption_primitive() became simple wrappers around properly defined functions we can inline them and always use software RSA algorithm from src::algorithms::rsa.rs. Signed-off-by: Dmitry Baryshkov <[email protected]>
internals.rs now contains only small functions related to BigUint to Vec<u8> conversion. Move them to src/algorithms/pad.rs and get rid of internals.rs Signed-off-by: Dmitry Baryshkov <[email protected]>
Contributor
Author
tarcieri
reviewed
Apr 19, 2023
tarcieri
reviewed
Apr 19, 2023
While it is expected that the functions inside algorithms crates might be useful (and used) by other parties, they are low level functions and as such impose a high risk of being misused. Protect all of them with pub(crate) to prevent them from being exposed by mistake. Also add big fat warnings to raw RSA functions, which should never be used unless authors knows exactly what they are using. Signed-off-by: Dmitry Baryshkov <[email protected]>
Member
|
@lumag need to remove |
Signed-off-by: Dmitry Baryshkov <[email protected]>
Contributor
Author
|
done
|
tarcieri
approved these changes
Apr 19, 2023
tchebb
pushed a commit
to tchebb/RSA
that referenced
this pull request
Jul 21, 2023
External access to these functions was removed in RustCrypto#304 when the old `internals` module and `expose-internals` feature were removed. There are some valid use cases for them, though (see RustCrypto#351), so let's bring back a subset of what was in `internals` using the same naming and documentation conventions that the aes crate uses for its hazardous functions. Much of the added or changed documentation is derived from that in aes. Fixes RustCrypto#351.
tarcieri
pushed a commit
that referenced
this pull request
Jul 23, 2023
External access to these functions was removed in #304 when the old `internals` module and `expose-internals` feature were removed. There are some valid use cases for them, though (see #351), so let's bring back a subset of what was in `internals` using the same naming and documentation conventions that the aes crate uses for its hazardous functions. Much of the added or changed documentation is derived from that in the `aes` crate. Fixes #351.
flihp
added a commit
to flihp/pki-playground
that referenced
this pull request
Nov 9, 2023
In versions of the rsa crate >= 0.9 the `generate_multi_prime_key_with_exp` functions are no longer public. Their reasons for doing so are here: RustCrypto/RSA#304 but the TLDR; is: so no one hurts themselves. The closest analog available is `RsaPrivateKey::new_with_exp` but it doesn't allow us to specify the number of primes. Internally it hard codes this value to '2' which is our current default. None of our example configs set this value and they probably shouldn't so this commit removes the `num-primes` config option from the RsaKeyConfig. This changes the config file structure so this commit bumps the version number too.
flihp
added a commit
to oxidecomputer/pki-playground
that referenced
this pull request
Nov 10, 2023
In versions of the rsa crate >= 0.9 the `generate_multi_prime_key_with_exp` functions are no longer public. Their reasons for doing so are here: RustCrypto/RSA#304 but the TLDR; is: so no one hurts themselves. The closest analog available is `RsaPrivateKey::new_with_exp` but it doesn't allow us to specify the number of primes. Internally it hard codes this value to '2' which is our current default. None of our example configs set this value and they probably shouldn't so this commit removes the `num-primes` config option from the RsaKeyConfig. This changes the config file structure so this commit bumps the version number too.
takumi-earth
pushed a commit
to earthlings-dev/RSA
that referenced
this pull request
Jan 27, 2026
* feat: decouple key generation and random generation Make generate_multi_prime_key_with_exp() generic enough to generate abstract key structure. Rewrite RsaPrivateKey constructors to use RsaPrivateKey::from_components(). * feat: move key-related traits to separate module Move PublicKeyParts to the separate module. * feat: stop using RsaPrivateKey in internals.rs Make internals.rs generic enough to be moved to the algorithms module. * feat: move soft RSA implementation to crate::algorithms::rsa.rs Separate software RSA implementation to separate module under crate::algorithms. * key: drop raw_int_*_primitive wrappers Now as raw_int_encryption_primitive() and raw_int_decryption_primitive() became simple wrappers around properly defined functions we can inline them and always use software RSA algorithm from src::algorithms::rsa.rs. * feat: move internals.rs to src/algortihms/pad.rs internals.rs now contains only small functions related to BigUint to Vec<u8> conversion. Move them to src/algorithms/pad.rs and get rid of internals.rs * algorithms: protect all functions with pub(crate) While it is expected that the functions inside algorithms crates might be useful (and used) by other parties, they are low level functions and as such impose a high risk of being misused. Protect all of them with pub(crate) to prevent them from being exposed by mistake. Also add big fat warnings to raw RSA functions, which should never be used unless authors knows exactly what they are using. Signed-off-by: Dmitry Baryshkov <[email protected]>
takumi-earth
pushed a commit
to earthlings-dev/RSA
that referenced
this pull request
Jan 27, 2026
…pto#352) External access to these functions was removed in RustCrypto#304 when the old `internals` module and `expose-internals` feature were removed. There are some valid use cases for them, though (see RustCrypto#351), so let's bring back a subset of what was in `internals` using the same naming and documentation conventions that the aes crate uses for its hazardous functions. Much of the added or changed documentation is derived from that in the `aes` crate. Fixes RustCrypto#351.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Further refactoring of the RSA crate. Clean up internal interfaces, split software RSA implementation from the wrapping code.