LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)

This allows us to support parsing and serializing BigIntegers to and
from any base N (such that 2 <= N <= 36).
This commit is contained in:
Idan Horowitz
2021-06-29 17:51:52 +03:00
committed by Linus Groh
parent a768131720
commit 005d75656e
Notes: sideshowbarker 2024-07-18 11:20:46 +09:00
14 changed files with 56 additions and 132 deletions

View File

@@ -218,7 +218,7 @@ bool is_probably_prime(const UnsignedBigInteger& p)
UnsignedBigInteger random_big_prime(size_t bits)
{
VERIFY(bits >= 33);
UnsignedBigInteger min = UnsignedBigInteger::from_base10("6074001000").shift_left(bits - 33);
UnsignedBigInteger min = UnsignedBigInteger::from_base(10, "6074001000").shift_left(bits - 33);
UnsignedBigInteger max = UnsignedBigInteger { 1 }.shift_left(bits).minus(1);
for (;;) {
auto p = random_number(min, max);