-
Notifications
You must be signed in to change notification settings - Fork 163
Shorten widths of BoxedUint
s
#506
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
Conversation
cbc5789
to
7305628
Compare
Everything was variable-time before Hopefully we'll get better performance after a migration to bingcd |
So if I understand the goal of these, it's to prevent truncating the contents of a value, correct? If so, adding them upstream seems fine. Perhaps they could be made constant-time? |
That's unfortunate, it's like a 5x slowdown.
Yep. |
@fjarri do you want to try to upstream |
Let me try it out, I'll see if I can distill some required functionality into general-use methods. As for the inversion, I need to check if preparing the inverter in advance makes things any better. |
It’s unlikely to impact performance aside from optimizing away a single allocation |
Converting to draft until we merge RustCrypto/crypto-bigint#809 in some form |
This PR attempts to simplify some scenarios that were encountered during the work on RustCrypto/RSA#506. - Instead of having `BoxedUint::shorten()`/`widen()` methods, introduce the `Resize` trait with more convenience methods. Implemented for `BoxedUint`, `NonZero<BoxedUint>`, `Odd<BoxedUint>`, and their references. - `BoxedUint::shorten()` and `widen()` are marked as deprecated. Note that `try_resize` fails if `self.bits() > at_least_bits_precision`, unlike the more relaxed `shorten()` behavior.
Fixes #490
crypto-bigint
dependency to the current trunk.bench_rsa_2048_pkcsv1_decrypt
to pre-crypto-bigint
values.RsaPrivateKey::from_components()
to ensure consistency between the primes and the modulus.RsaPrivateKey::from_components()
.rsa_decrypt()
to ensure the bit precision of the ciphertext is the same as that of the modulus.Notes:
bench_rsa_2048_pkcsv1_sign_blinded
can be restored to the original performance by using variable-time inversion inalgorithms::rsa::blind()
(as it was duringnum-bigint
times), but it seems to me that the blinding factor must be kept secret, so we have to use the constant-time inversion. This leads to about 5x slowdown compared to pre-crypto-bigint
performance.random_bits_core
platform independent crypto-bigint#781Possible further improvements
Odd
/NonZero
as appropriate.