summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2008-11-12 03:58:08 +0000
committerGeoff Thorpe <geoff@openssl.org>2008-11-12 03:58:08 +0000
commit6343829a391df59e46e513c84b6264ee71ad9518 (patch)
tree9823103bf5828e47081ac906203516bdc332f577 /crypto/rand
parent2401debe83e8df930907a39065ebf9a54354f123 (diff)
Revert the size_t modifications from HEAD that had led to more
knock-on work than expected - they've been extracted into a patch series that can be completed elsewhere, or in a different branch, before merging back to HEAD.
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/md_rand.c28
-rw-r--r--crypto/rand/rand.h20
-rw-r--r--crypto/rand/rand_egd.c6
-rw-r--r--crypto/rand/rand_lib.c8
-rw-r--r--crypto/rand/rand_unix.c4
-rw-r--r--crypto/rand/randfile.c10
6 files changed, 35 insertions, 41 deletions
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index 48cc2e84a8..810b4c2d4a 100644
--- a/crypto/rand/md_rand.c
+++ b/crypto/rand/md_rand.c
@@ -155,10 +155,10 @@ int rand_predictable=0;
const char RAND_version[]="RAND" OPENSSL_VERSION_PTEXT;
static void ssleay_rand_cleanup(void);
-static void ssleay_rand_seed(const void *buf, size_t num);
-static void ssleay_rand_add(const void *buf, size_t num, double add_entropy);
-static int ssleay_rand_bytes(unsigned char *buf, size_t num);
-static int ssleay_rand_pseudo_bytes(unsigned char *buf, size_t num);
+static void ssleay_rand_seed(const void *buf, int num);
+static void ssleay_rand_add(const void *buf, int num, double add_entropy);
+static int ssleay_rand_bytes(unsigned char *buf, int num);
+static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
static int ssleay_rand_status(void);
RAND_METHOD rand_ssleay_meth={
@@ -187,11 +187,9 @@ static void ssleay_rand_cleanup(void)
initialized=0;
}
-static void ssleay_rand_add(const void *buf, size_t num, double add)
+static void ssleay_rand_add(const void *buf, int num, double add)
{
- int i,st_idx;
- size_t j;
- ssize_t k;
+ int i,j,k,st_idx;
long md_c[2];
unsigned char local_md[MD_DIGEST_LENGTH];
EVP_MD_CTX m;
@@ -304,7 +302,7 @@ static void ssleay_rand_add(const void *buf, size_t num, double add)
* other thread's seeding remains without effect (except for
* the incremented counter). By XORing it we keep at least as
* much entropy as fits into md. */
- for (k = 0; k < sizeof(md); k++)
+ for (k = 0; k < (int)sizeof(md); k++)
{
md[k] ^= local_md[k];
}
@@ -317,17 +315,15 @@ static void ssleay_rand_add(const void *buf, size_t num, double add)
#endif
}
-static void ssleay_rand_seed(const void *buf, size_t num)
+static void ssleay_rand_seed(const void *buf, int num)
{
ssleay_rand_add(buf, num, (double)num);
}
-static int ssleay_rand_bytes(unsigned char *buf, size_t num)
+static int ssleay_rand_bytes(unsigned char *buf, int num)
{
static volatile int stirred_pool = 0;
- int i,st_num,st_idx;
- size_t j;
- ssize_t k;
+ int i,j,k,st_num,st_idx;
int num_ceil;
int ok;
long md_c[2];
@@ -494,7 +490,7 @@ static int ssleay_rand_bytes(unsigned char *buf, size_t num)
}
MD_Init(&m);
- MD_Update(&m,&(md_c[0]),sizeof(md_c));
+ MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
MD_Update(&m,local_md,MD_DIGEST_LENGTH);
CRYPTO_w_lock(CRYPTO_LOCK_RAND);
MD_Update(&m,md,MD_DIGEST_LENGTH);
@@ -515,7 +511,7 @@ static int ssleay_rand_bytes(unsigned char *buf, size_t num)
/* pseudo-random bytes that are guaranteed to be unique but not
unpredictable */
-static int ssleay_rand_pseudo_bytes(unsigned char *buf, size_t num)
+static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
{
int ret;
unsigned long err;
diff --git a/crypto/rand/rand.h b/crypto/rand/rand.h
index 82a6bec148..ac6c021763 100644
--- a/crypto/rand/rand.h
+++ b/crypto/rand/rand.h
@@ -80,11 +80,11 @@ extern "C" {
struct rand_meth_st
{
- void (*seed)(const void *buf, size_t num);
- int (*bytes)(unsigned char *buf, size_t num);
+ void (*seed)(const void *buf, int num);
+ int (*bytes)(unsigned char *buf, int num);
void (*cleanup)(void);
- void (*add)(const void *buf, size_t num, double entropy);
- int (*pseudorand)(unsigned char *buf, size_t num);
+ void (*add)(const void *buf, int num, double entropy);
+ int (*pseudorand)(unsigned char *buf, int num);
int (*status)(void);
};
@@ -99,17 +99,17 @@ int RAND_set_rand_engine(ENGINE *engine);
#endif
RAND_METHOD *RAND_SSLeay(void);
void RAND_cleanup(void );
-int RAND_bytes(unsigned char *buf,size_t num);
-int RAND_pseudo_bytes(unsigned char *buf,size_t num);
-void RAND_seed(const void *buf,size_t num);
-void RAND_add(const void *buf,size_t num,double entropy);
+int RAND_bytes(unsigned char *buf,int num);
+int RAND_pseudo_bytes(unsigned char *buf,int num);
+void RAND_seed(const void *buf,int num);
+void RAND_add(const void *buf,int num,double entropy);
int RAND_load_file(const char *file,long max_bytes);
int RAND_write_file(const char *file);
const char *RAND_file_name(char *file,size_t num);
int RAND_status(void);
-int RAND_query_egd_bytes(const char *path, unsigned char *buf, size_t bytes);
+int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
int RAND_egd(const char *path);
-int RAND_egd_bytes(const char *path, size_t bytes);
+int RAND_egd_bytes(const char *path,int bytes);
int RAND_poll(void);
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c
index 4e8daad804..17373f7d98 100644
--- a/crypto/rand/rand_egd.c
+++ b/crypto/rand/rand_egd.c
@@ -133,11 +133,11 @@ struct sockaddr_un {
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
-int RAND_query_egd_bytes(const char *path, unsigned char *buf, size_t bytes)
+int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
{
int ret = 0;
struct sockaddr_un addr;
- size_t len, num, numbytes;
+ int len, num, numbytes;
int fd = -1;
int success;
unsigned char egdbuf[2], tempbuf[255], *retrievebuf;
@@ -281,7 +281,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, size_t bytes)
}
-int RAND_egd_bytes(const char *path, size_t bytes)
+int RAND_egd_bytes(const char *path, int bytes)
{
int num, ret = 0;
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index 2aa2e86545..513e338985 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -137,21 +137,21 @@ void RAND_cleanup(void)
RAND_set_rand_method(NULL);
}
-void RAND_seed(const void *buf, size_t num)
+void RAND_seed(const void *buf, int num)
{
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth && meth->seed)
meth->seed(buf,num);
}
-void RAND_add(const void *buf, size_t num, double entropy)
+void RAND_add(const void *buf, int num, double entropy)
{
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth && meth->add)
meth->add(buf,num,entropy);
}
-int RAND_bytes(unsigned char *buf, size_t num)
+int RAND_bytes(unsigned char *buf, int num)
{
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth && meth->bytes)
@@ -159,7 +159,7 @@ int RAND_bytes(unsigned char *buf, size_t num)
return(-1);
}
-int RAND_pseudo_bytes(unsigned char *buf, size_t num)
+int RAND_pseudo_bytes(unsigned char *buf, int num)
{
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth && meth->pseudorand)
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
index e9cba6479d..e978c4a930 100644
--- a/crypto/rand/rand_unix.c
+++ b/crypto/rand/rand_unix.c
@@ -157,7 +157,7 @@ int RAND_poll(void)
pid_t curr_pid = getpid();
#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
unsigned char tmpbuf[ENTROPY_NEEDED];
- size_t n = 0;
+ int n = 0;
#endif
#ifdef DEVRANDOM
static const char *randomfiles[] = { DEVRANDOM };
@@ -261,7 +261,7 @@ int RAND_poll(void)
if (try_read)
{
- r = read(fd,tmpbuf+n,ENTROPY_NEEDED-n);
+ r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n);
if (r > 0)
n += r;
#if defined(OPENSSL_SYS_BEOS_R5)
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index c345d08541..c4e6160779 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -105,8 +105,7 @@ int RAND_load_file(const char *file, long bytes)
#ifndef OPENSSL_NO_POSIX_IO
struct stat sb;
#endif
- int i,ret=0;
- size_t n;
+ int i,ret=0,n;
FILE *in;
if (file == NULL) return(0);
@@ -163,8 +162,7 @@ err:
int RAND_write_file(const char *file)
{
unsigned char buf[BUFSIZE];
- int ret=0,rand_err=0;
- size_t i;
+ int i,ret=0,rand_err=0;
FILE *out = NULL;
int n;
#ifndef OPENSSL_NO_POSIX_IO
@@ -228,7 +226,7 @@ int RAND_write_file(const char *file)
if (out == NULL) goto err;
#ifndef NO_CHMOD
- chmod(file,(mode_t)0600);
+ chmod(file,0600);
#endif
n=RAND_DATA;
for (;;)
@@ -238,7 +236,7 @@ int RAND_write_file(const char *file)
if (RAND_bytes(buf,i) <= 0)
rand_err=1;
i=fwrite(buf,1,i,out);
- if (i == 0)
+ if (i <= 0)
{
ret=0;
break;