summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2008-11-01 16:40:37 +0000
committerBen Laurie <ben@openssl.org>2008-11-01 16:40:37 +0000
commit5e4430e70df0020f5f1517249851696cb9ac4ad2 (patch)
tree95dcbc73bcd99b725664324db882b4a388d0d4cb /crypto/rand
parent4d6e1e4f29de455b5e644ea9cae5d5f5a2dbef33 (diff)
More size_tification.
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/md_rand.c22
-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, 37 insertions, 33 deletions
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index 810b4c2d4a..e4a24c26db 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, 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 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 int ssleay_rand_status(void);
RAND_METHOD rand_ssleay_meth={
@@ -187,9 +187,10 @@ static void ssleay_rand_cleanup(void)
initialized=0;
}
-static void ssleay_rand_add(const void *buf, int num, double add)
+static void ssleay_rand_add(const void *buf, size_t num, double add)
{
- int i,j,k,st_idx;
+ int i,st_idx;
+ size_t j,k;
long md_c[2];
unsigned char local_md[MD_DIGEST_LENGTH];
EVP_MD_CTX m;
@@ -315,15 +316,16 @@ static void ssleay_rand_add(const void *buf, int num, double add)
#endif
}
-static void ssleay_rand_seed(const void *buf, int num)
+static void ssleay_rand_seed(const void *buf, size_t num)
{
ssleay_rand_add(buf, num, (double)num);
}
-static int ssleay_rand_bytes(unsigned char *buf, int num)
+static int ssleay_rand_bytes(unsigned char *buf, size_t num)
{
static volatile int stirred_pool = 0;
- int i,j,k,st_num,st_idx;
+ int i,st_num,st_idx;
+ size_t j,k;
int num_ceil;
int ok;
long md_c[2];
@@ -511,7 +513,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
/* pseudo-random bytes that are guaranteed to be unique but not
unpredictable */
-static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
+static int ssleay_rand_pseudo_bytes(unsigned char *buf, size_t num)
{
int ret;
unsigned long err;
diff --git a/crypto/rand/rand.h b/crypto/rand/rand.h
index ac6c021763..82a6bec148 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, int num);
- int (*bytes)(unsigned char *buf, int num);
+ void (*seed)(const void *buf, size_t num);
+ int (*bytes)(unsigned char *buf, size_t num);
void (*cleanup)(void);
- void (*add)(const void *buf, int num, double entropy);
- int (*pseudorand)(unsigned char *buf, int num);
+ void (*add)(const void *buf, size_t num, double entropy);
+ int (*pseudorand)(unsigned char *buf, size_t 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,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_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_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, int bytes);
+int RAND_query_egd_bytes(const char *path, unsigned char *buf, size_t bytes);
int RAND_egd(const char *path);
-int RAND_egd_bytes(const char *path,int bytes);
+int RAND_egd_bytes(const char *path, size_t 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 d53b916ebe..97334a92e1 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, int bytes)
+int RAND_query_egd_bytes(const char *path, unsigned char *buf, size_t bytes)
{
int ret = 0;
struct sockaddr_un addr;
- int len, num, numbytes;
+ size_t 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, int bytes)
}
-int RAND_egd_bytes(const char *path, int bytes)
+int RAND_egd_bytes(const char *path, size_t bytes)
{
int num, ret = 0;
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index 513e338985..2aa2e86545 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, int num)
+void RAND_seed(const void *buf, size_t num)
{
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth && meth->seed)
meth->seed(buf,num);
}
-void RAND_add(const void *buf, int num, double entropy)
+void RAND_add(const void *buf, size_t 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, int num)
+int RAND_bytes(unsigned char *buf, size_t num)
{
const RAND_METHOD *meth = RAND_get_rand_method();
if (meth && meth->bytes)
@@ -159,7 +159,7 @@ int RAND_bytes(unsigned char *buf, int num)
return(-1);
}
-int RAND_pseudo_bytes(unsigned char *buf, int num)
+int RAND_pseudo_bytes(unsigned char *buf, size_t 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 e978c4a930..e9cba6479d 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];
- int n = 0;
+ size_t n = 0;
#endif
#ifdef DEVRANDOM
static const char *randomfiles[] = { DEVRANDOM };
@@ -261,7 +261,7 @@ int RAND_poll(void)
if (try_read)
{
- r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n);
+ r = read(fd,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 c4e6160779..c345d08541 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -105,7 +105,8 @@ int RAND_load_file(const char *file, long bytes)
#ifndef OPENSSL_NO_POSIX_IO
struct stat sb;
#endif
- int i,ret=0,n;
+ int i,ret=0;
+ size_t n;
FILE *in;
if (file == NULL) return(0);
@@ -162,7 +163,8 @@ err:
int RAND_write_file(const char *file)
{
unsigned char buf[BUFSIZE];
- int i,ret=0,rand_err=0;
+ int ret=0,rand_err=0;
+ size_t i;
FILE *out = NULL;
int n;
#ifndef OPENSSL_NO_POSIX_IO
@@ -226,7 +228,7 @@ int RAND_write_file(const char *file)
if (out == NULL) goto err;
#ifndef NO_CHMOD
- chmod(file,0600);
+ chmod(file,(mode_t)0600);
#endif
n=RAND_DATA;
for (;;)
@@ -236,7 +238,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;