1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-12 15:41:16 +03:00

dh: Do some basic refactoring

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Aris Adamantiadis
2018-11-06 16:12:20 +01:00
committed by Andreas Schneider
parent a6c47099b7
commit 9c88769707
5 changed files with 222 additions and 351 deletions

View File

@@ -106,13 +106,17 @@ int ssh_gcry_rand_range(bignum dest, bignum max)
{
size_t bits;
bignum rnd;
int rc;
bits = bignum_num_bits(max) + 64;
rnd = bignum_new();
if (rnd == NULL) {
return 0;
}
bignum_rand(rnd, bits);
rc = bignum_rand(rnd, bits);
if (rc != 1) {
return rc;
}
gcry_mpi_mod(dest, rnd, max);
bignum_safe_free(rnd);
return 1;