projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New functions BN_CTX_start(), BN_CTX_get(), BN_CTX_end() to access
[oweals/openssl.git]
/
crypto
/
bn
/
bn_rand.c
diff --git
a/crypto/bn/bn_rand.c
b/crypto/bn/bn_rand.c
index 75b6b0493b1015da080b9c93cf81733737d77417..943712c15b8f2e31b374f4e9af98000cfc43225b 100644
(file)
--- a/
crypto/bn/bn_rand.c
+++ b/
crypto/bn/bn_rand.c
@@
-60,13
+60,9
@@
#include <time.h>
#include "cryptlib.h"
#include "bn_lcl.h"
#include <time.h>
#include "cryptlib.h"
#include "bn_lcl.h"
-#include
"rand.h"
+#include
<openssl/rand.h>
-int BN_rand(rnd, bits, top, bottom)
-BIGNUM *rnd;
-int bits;
-int top;
-int bottom;
+static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
{
unsigned char *buf=NULL;
int ret=0,bit,bytes,mask;
{
unsigned char *buf=NULL;
int ret=0,bit,bytes,mask;
@@
-85,9
+81,19
@@
int bottom;
/* make a random number and set the top and bottom bits */
time(&tim);
/* make a random number and set the top and bottom bits */
time(&tim);
- RAND_seed((unsigned char *)&tim,sizeof(tim));
+ RAND_add(&tim,sizeof(tim),0);
+
+ if (pseudorand)
+ {
+ if (RAND_pseudo_bytes(buf, bytes) == -1)
+ goto err;
+ }
+ else
+ {
+ if (RAND_bytes(buf, bytes) <= 0)
+ goto err;
+ }
- RAND_bytes(buf,(int)bytes);
if (top)
{
if (bit == 0)
if (top)
{
if (bit == 0)
@@
-119,3
+125,12
@@
err:
return(ret);
}
return(ret);
}
+int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ return bnrand(0, rnd, bits, top, bottom);
+ }
+
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ return bnrand(1, rnd, bits, top, bottom);
+ }