-
Notifications
You must be signed in to change notification settings - Fork 195
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
Added calculation of the number of Miller-Rabin rounds necessary for DEA primes if done with M-R alone. #498
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "tommath_private.h" | ||
#ifdef MP_PRIME_RABIN_MILLER_TRIALS_DEA_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
/* Compute number of Miller-Rabin rounds necessary for DSA primes | ||
if only Miller-Rabin tests were used. Use | ||
mp_prime_rabin_miller_trials(size) | ||
or | ||
mp_prime_rabin_miller_trials_rsa(size) | ||
if the M-R tests are followed by a Lucas test. | ||
*/ | ||
int mp_prime_rabin_miller_trials_dea(int error) | ||
{ | ||
return ((error/2) + 1); | ||
} | ||
|
||
#endif |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "tommath_private.h" | ||
#ifdef MP_PRIME_RABIN_MILLER_TRIALS_RSA_C | ||
/* LibTomMath, multiple-precision integer library -- Tom St Denis */ | ||
/* SPDX-License-Identifier: Unlicense */ | ||
|
||
int mp_prime_rabin_miller_trials_rsa(int size) | ||
{ | ||
return mp_prime_rabin_miller_trials(size); | ||
} | ||
#endif |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the fact that the only difference between this API and the RSA one is the name of the argument, but the behavior is totally different ... and also the input is expected to be something entirely different...
How is the input to this function supposed to be calculated? (or is this supposed to be fixed depending on the probability that is supposed to be used?)
Would it maybe make sense to make this API
int mp_prime_rabin_miller_trials_dea(int size, int error)
?And maybe to also take into account whether
LTM_USE_ONLY_MR
resp.LTM_USE_FROBENIUS_TEST
are defined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, naming things was never my greatest forte.
The function name was already quite long to begin with and I didn't want to add too much to it but it is of course possible to make it a bit more "talkative". I'm wide open for suggestions.
The documentation for this function is short, admitted, is it too short?
(And it has a typo *sigh*)
It depends on the absolute value of the exponent of the binary representation of the probability the user wants. It is half of that, rounded to positive infinity in case of a tie. According to Fips. It is independent of the size of the prime. Also according to Fips.
So…
…would make no sense. But—and here it gets interesting—only if the tests use M-R only. If you follow your M-R tests by a Lucas test you can use the values for RSA calculated with that complicated formula. According to Fips.
So…
…is tempting but we don't know if the Frobenius test is used, even if
LTM_USE_FROBENIUS_TEST
is defined (M-R is a public function and many, way too many roll their own). On the other sideLTM_USE_ONLY_MR
would be useful but only if the RSA method is the default and the RSA method is only the default for computing RSA trials.Now that I wrote that: yes it is a very good idea to check for
LTM_USE_ONLY_MR
in computing RSA trials and returning the DEA computation (half the error as described above) in that case. RSA error depends also on the size of the prime in the table and we can spend that table another column for little money.It is not that easy for DEA but I think that you should not automate everything even if you can. Some things are better left to the documentation.
BTW: The Frobenius test can and should go, it was for MP_8BIT only. It is not known if it is independent of the Strong-Lucas-Test and was only meant as a replacement for the Strong-Lucas-Test. The Extra-Strong-Lucas-Test is said to be independent of the S-L-T for some parameters different from the parameters used in the implementation by Thomas Nicely but I haven't found time to verify that properly (Just because Wikipedia said so? Nope!).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is nonsense. The table is for M-R-only. (see e.g.: Damgard et. al. or Burthe)
Let me see if I can remove that commit accident-free.