diff options
author | Geoff Thorpe <geoff@openssl.org> | 2003-11-30 21:21:30 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2003-11-30 21:21:30 +0000 |
commit | 5734bebe05949bf1e7b94dcf225d297389347bb2 (patch) | |
tree | 235c2b4fa4c52d3ed919f6a04cc56b68aa3d4f3c /crypto/bn | |
parent | 657a9195983badf9f0a45d32bd8199bab27f0e01 (diff) |
Make BN_DEBUG_RAND less painfully slow by only consuming one byte of
pseudo-random data for each bn_pollute().
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index 326aeca9f9..5f16fbad00 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -635,12 +635,14 @@ int RAND_pseudo_bytes(unsigned char *buf,int num); do { \ const BIGNUM *_bnum1 = (a); \ if(_bnum1->top < _bnum1->dmax) { \ + unsigned char _tmp_char; \ /* We cast away const without the compiler knowing, any \ * *genuinely* constant variables that aren't mutable \ * wouldn't be constructed with top!=dmax. */ \ BN_ULONG *_not_const; \ memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ - RAND_pseudo_bytes((unsigned char *)(_not_const + _bnum1->top), \ + RAND_pseudo_bytes(&_tmp_char, 1); \ + memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ } \ } while(0) |