-
Notifications
You must be signed in to change notification settings - Fork 156
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
RSA key generation comparatively slow #144
Comments
Line 99 in 7395997
EDIT: After benchmarking this some more, it actually looks like the number of primes used to generate the key is the influencing factor. I increased the number of primes from Line 279 in 7395997
|
The main reason asfaik is that the underlying operations are nowhere nearly as optimized as the code in OpenSSL and whatever library C# is calling into. @aloucks that will generate a different RSA key setup though, and most applications today assume using 2 primes and not more asfaik. |
In https://github.com/jellevos/scicrypt/blob/master/scicrypt-numbertheory/src/lib.rs I have implemented an algorithm that is almost exactly the same as OpenSSL's. Depending on the machine and parameters it is slightly faster or slightly slower than OpenSSL. I am happy to give it a try to reimplement it in this crate (the algorithm is not complicated). Of course, if the bottleneck is the underlying arithmetic, then it might not make a large difference. |
@jellevos would definitely be curious what the performance is if you did port it over |
ftr: older issue with similar topic: #29 |
Once dignifiedquire/num-bigint#48 lands, prime generation should be a little faster. |
@darconeous |
do'h! |
I need to frequently generate RSA keys in bulk. I am using the following Rust code to generate a key:
Running this code in release mode to generate 100 RSA keys takes about 18 seconds on my machine. In comparison, I used the following code in C (OpenSSL) and C# (CNG) to generate the same-size RSA key.
C - OpenSSL
C# - CNG
To generate 100 keys, the C code takes about 6.7 seconds and the C# code takes about 5.5 seconds. I was surprised that the Rust key generation took about 3x more time than both C and C#.
The text was updated successfully, but these errors were encountered: