Mercurial > dropbear
comparison libtommath/bn_mp_rand.c @ 1748:34d9d3c022ce
Use Dropbear's random source rather than libtommath's platform
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 19 Oct 2020 22:49:19 +0800 |
parents | 1051e4eea25a |
children |
comparison
equal
deleted
inserted
replaced
1747:ff51d5967e2d | 1748:34d9d3c022ce |
---|---|
1 #include "tommath_private.h" | 1 #include "tommath_private.h" |
2 #ifdef BN_MP_RAND_C | 2 #ifdef BN_MP_RAND_C |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ | 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ |
4 /* SPDX-License-Identifier: Unlicense */ | 4 /* SPDX-License-Identifier: Unlicense */ |
5 | 5 |
6 mp_err(*s_mp_rand_source)(void *out, size_t size) = s_mp_rand_platform; | 6 /* Dropbear sets this separately, avoid platform code */ |
7 mp_err(*s_mp_rand_source)(void *out, size_t size) = NULL; | |
7 | 8 |
8 void mp_rand_source(mp_err(*source)(void *out, size_t size)) | 9 void mp_rand_source(mp_err(*source)(void *out, size_t size)) |
9 { | 10 { |
10 s_mp_rand_source = (source == NULL) ? s_mp_rand_platform : source; | 11 /* Dropbear, don't reset to platform if source==NULL */ |
12 s_mp_rand_source = source; | |
11 } | 13 } |
12 | 14 |
13 mp_err mp_rand(mp_int *a, int digits) | 15 mp_err mp_rand(mp_int *a, int digits) |
14 { | 16 { |
15 int i; | 17 int i; |