mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
PrimeCandidateSource: two extra query functions.
pcs_get_upper_bound lets the holder of a PrimeCandidateSource ask what is the largest value it might ever generate. pcs_get_bits_remaining lets it ask how much extra entropy it's going to generate on top of the requirements that have already been input into it. Both of these will be needed by the upcoming provable-prime work to decide what sizes of subsidiary prime to generate.
This commit is contained in:
parent
18be6aec58
commit
cfa3f8b192
@ -381,6 +381,21 @@ unsigned pcs_get_bits(PrimeCandidateSource *pcs)
|
||||
return pcs->bits;
|
||||
}
|
||||
|
||||
unsigned pcs_get_bits_remaining(PrimeCandidateSource *pcs)
|
||||
{
|
||||
return mp_get_nbits(pcs->limit);
|
||||
}
|
||||
|
||||
mp_int *pcs_get_upper_bound(PrimeCandidateSource *pcs)
|
||||
{
|
||||
/* Compute (limit-1) * factor + addend */
|
||||
mp_int *tmp = mp_mul(pcs->limit, pcs->factor);
|
||||
mp_int *bound = mp_add(tmp, pcs->addend);
|
||||
mp_free(tmp);
|
||||
mp_sub_into(bound, bound, pcs->factor);
|
||||
return bound;
|
||||
}
|
||||
|
||||
mp_int **pcs_get_known_prime_factors(PrimeCandidateSource *pcs, size_t *nout)
|
||||
{
|
||||
*nout = pcs->nkps;
|
||||
|
@ -70,6 +70,8 @@ void pcs_inspect(PrimeCandidateSource *pcs, mp_int **limit_out,
|
||||
|
||||
/* Query functions for primegen to use */
|
||||
unsigned pcs_get_bits(PrimeCandidateSource *pcs);
|
||||
unsigned pcs_get_bits_remaining(PrimeCandidateSource *pcs);
|
||||
mp_int *pcs_get_upper_bound(PrimeCandidateSource *pcs);
|
||||
mp_int **pcs_get_known_prime_factors(PrimeCandidateSource *pcs, size_t *nout);
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user