aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/random.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1999-04-06 18:04:55 +0000
committerWerner Koch <[email protected]>1999-04-06 18:04:55 +0000
commit1b9a820c19d8ada57d19ea9ec1bbf7e80cb69d18 (patch)
treefa5639c6ee2652942b712a244125734d7155c937 /cipher/random.c
parent./BUGS (diff)
downloadgnupg-1b9a820c19d8ada57d19ea9ec1bbf7e80cb69d18.tar.gz
gnupg-1b9a820c19d8ada57d19ea9ec1bbf7e80cb69d18.zip
See ChangeLog: Tue Apr 6 19:58:12 CEST 1999 Werner Koch
Diffstat (limited to 'cipher/random.c')
-rw-r--r--cipher/random.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/cipher/random.c b/cipher/random.c
index eedfcfa65..a201c1dbb 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -169,14 +169,19 @@ random_is_faked()
byte *
get_random_bits( size_t nbits, int level, int secure )
{
- byte *buf;
+ byte *buf, *p;
size_t nbytes = (nbits+7)/8;
if( quick_test && level > 1 )
level = 1;
MASK_LEVEL(level);
buf = secure && secure_alloc ? m_alloc_secure( nbytes ) : m_alloc( nbytes );
- read_pool( buf, nbytes, level );
+ for( p = buf; nbytes > 0; ) {
+ size_t n = nbytes > POOLSIZE? POOLSIZE : nbytes;
+ read_pool( p, n, level );
+ nbytes -= n;
+ p += n;
+ }
return buf;
}