1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-08 08:58:00 +00:00

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.
This commit is contained in:
Simon Tatham 2021-08-27 17:46:25 +01:00
parent 6520574e58
commit 3bb12dff3b

View File

@ -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 */
}