diff options
author | Simon Tatham <anakin@pobox.com> | 2021-08-27 19:46:25 +0300 |
---|---|---|
committer | Simon Tatham <anakin@pobox.com> | 2021-08-27 20:04:49 +0300 |
commit | 3bb12dff3b4e4e691fd413a6de642b339f99a072 (patch) | |
tree | 79d36f424ff9cc0b37e1daf8a4dac70986f3cf80 /keygen | |
parent | 6520574e584351f6c3af1fabcb6951db8ea98066 (diff) |
Make pcs_set_oneshot even more one-shot.
Previously, it would generate a prime candidate, test it, and abort if
that candidate failed to be prime. Now, it's even willing to fail
_before_ generating a prime candidate, if the first attempt to even do
that is unsuccessful.
This doesn't affect the existing use case of pcs_set_oneshot, which is
during generation of a safe prime (as implemented by test/primegen.py
--safe), where you want to make a PrimeCandidateSource that can only
return 2p+1 for your existing prime p, and then abort if that fails
the next step of testing. In that situation, the PrimeCandidateSource
will never fail to generate its first output anyway.
But these changed semantics will become useful in another use I'm
about to find for one-shot mode.
Diffstat (limited to 'keygen')
-rw-r--r-- | keygen/primecandidate.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/keygen/primecandidate.c b/keygen/primecandidate.c index 02c0259d..fca2b297 100644 --- a/keygen/primecandidate.c +++ b/keygen/primecandidate.c @@ -396,6 +396,8 @@ mp_int *pcs_generate(PrimeCandidateSource *s) if (!ok) { mp_free(x); + if (s->one_shot) + return NULL; continue; /* try a new x */ } |