summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/rand
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/rand')
-rw-r--r--crypto/openssl/crypto/rand/Makefile145
-rw-r--r--crypto/openssl/crypto/rand/md_rand.c15
-rw-r--r--crypto/openssl/crypto/rand/rand.h15
-rw-r--r--crypto/openssl/crypto/rand/rand_egd.c10
-rw-r--r--crypto/openssl/crypto/rand/rand_err.c22
-rw-r--r--crypto/openssl/crypto/rand/rand_lib.c12
-rw-r--r--crypto/openssl/crypto/rand/rand_nw.c176
-rw-r--r--crypto/openssl/crypto/rand/rand_unix.c44
-rw-r--r--crypto/openssl/crypto/rand/rand_vms.c5
-rw-r--r--crypto/openssl/crypto/rand/rand_win.c101
-rw-r--r--crypto/openssl/crypto/rand/randfile.c6
-rw-r--r--crypto/openssl/crypto/rand/randtest.c5
12 files changed, 354 insertions, 202 deletions
diff --git a/crypto/openssl/crypto/rand/Makefile b/crypto/openssl/crypto/rand/Makefile
index 4ab4b9c..3c1ab5b 100644
--- a/crypto/openssl/crypto/rand/Makefile
+++ b/crypto/openssl/crypto/rand/Makefile
@@ -1,5 +1,5 @@
#
-# SSLeay/crypto/rand/Makefile
+# OpenSSL/crypto/rand/Makefile
#
DIR= rand
@@ -7,11 +7,6 @@ TOP= ../..
CC= cc
INCLUDES=
CFLAG=-g
-INSTALL_PREFIX=
-OPENSSLDIR= /usr/local/ssl
-INSTALLTOP=/usr/local/ssl
-MAKEDEPPROG= makedepend
-MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
MAKEFILE= Makefile
AR= ar r
@@ -23,9 +18,9 @@ APPS=
LIB=$(TOP)/libcrypto.a
LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \
- rand_win.c rand_unix.c rand_os2.c
+ rand_win.c rand_unix.c rand_os2.c rand_nw.c
LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o \
- rand_win.o rand_unix.o rand_os2.o
+ rand_win.o rand_unix.o rand_os2.o rand_nw.o
SRC= $(LIBSRC)
@@ -53,7 +48,8 @@ links:
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
install:
- @for i in $(EXHEADER) ; \
+ @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
+ @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
do \
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
@@ -68,6 +64,7 @@ lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff
depend:
+ @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
dclean:
@@ -79,26 +76,16 @@ clean:
# DO NOT DELETE THIS LINE -- make depend depends on it.
-md_rand.o: ../../e_os.h ../../include/openssl/aes.h
-md_rand.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-md_rand.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
-md_rand.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
-md_rand.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
-md_rand.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
+md_rand.o: ../../e_os.h ../../include/openssl/asn1.h
+md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
-md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h
-md_rand.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
-md_rand.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
-md_rand.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
+md_rand.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
-md_rand.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h
-md_rand.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h
-md_rand.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-md_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-md_rand.o: ../../include/openssl/ui_compat.h md_rand.c rand_lcl.h
+md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
+md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
+md_rand.o: md_rand.c rand_lcl.h
rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
rand_egd.o: ../../include/openssl/opensslconf.h
rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
@@ -110,83 +97,59 @@ rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rand_err.o: rand_err.c
-rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
-rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
+rand_lib.o: ../../e_os.h ../../include/openssl/bio.h
rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-rand_lib.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
-rand_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
-rand_lib.o: ../../include/openssl/err.h ../../include/openssl/fips.h
-rand_lib.o: ../../include/openssl/fips_rand.h ../../include/openssl/lhash.h
+rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
rand_lib.o: ../../include/openssl/opensslconf.h
rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
-rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-rand_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
-rand_lib.o: ../../include/openssl/ui_compat.h ../cryptlib.h rand_lib.c
-rand_os2.o: ../../e_os.h ../../include/openssl/aes.h
-rand_os2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-rand_os2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
-rand_os2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
-rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-rand_os2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
-rand_os2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
+rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
+rand_lib.o: ../cryptlib.h rand_lib.c
+rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h
+rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
+rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
+rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h
+rand_nw.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
+rand_nw.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
+rand_nw.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
+rand_nw.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_nw.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
+rand_nw.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h rand_nw.c
+rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h
+rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
+rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
-rand_os2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
-rand_os2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
-rand_os2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
-rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-rand_os2.o: ../../include/openssl/opensslconf.h
+rand_os2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
+rand_os2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
-rand_os2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
-rand_os2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
-rand_os2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-rand_os2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-rand_os2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-rand_os2.o: ../cryptlib.h rand_lcl.h rand_os2.c
-rand_unix.o: ../../e_os.h ../../include/openssl/aes.h
-rand_unix.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-rand_unix.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
-rand_unix.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
-rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-rand_unix.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
-rand_unix.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
+rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
+rand_os2.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
+rand_os2.o: rand_os2.c
+rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h
+rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
+rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
-rand_unix.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
-rand_unix.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
-rand_unix.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
-rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
+rand_unix.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
+rand_unix.o: ../../include/openssl/objects.h
rand_unix.o: ../../include/openssl/opensslconf.h
rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
-rand_unix.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
-rand_unix.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
-rand_unix.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-rand_unix.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-rand_unix.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-rand_unix.o: ../cryptlib.h rand_lcl.h rand_unix.c
-rand_win.o: ../../e_os.h ../../include/openssl/aes.h
-rand_win.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
-rand_win.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
-rand_win.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
-rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
-rand_win.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
-rand_win.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
+rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_unix.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
+rand_unix.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
+rand_unix.o: rand_unix.c
+rand_win.o: ../../e_os.h ../../include/openssl/asn1.h
+rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
+rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
-rand_win.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
-rand_win.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
-rand_win.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
-rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
-rand_win.o: ../../include/openssl/opensslconf.h
+rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
+rand_win.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-rand_win.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
-rand_win.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
-rand_win.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
-rand_win.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-rand_win.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
-rand_win.o: ../cryptlib.h rand_lcl.h rand_win.c
+rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
+rand_win.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h
+rand_win.o: rand_win.c
randfile.o: ../../e_os.h ../../include/openssl/buffer.h
randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
randfile.o: ../../include/openssl/opensslconf.h
diff --git a/crypto/openssl/crypto/rand/md_rand.c b/crypto/openssl/crypto/rand/md_rand.c
index c84968d..6e10f6e 100644
--- a/crypto/openssl/crypto/rand/md_rand.c
+++ b/crypto/openssl/crypto/rand/md_rand.c
@@ -126,7 +126,6 @@
#include <openssl/crypto.h>
#include <openssl/err.h>
-#include <openssl/fips.h>
#ifdef BN_DEBUG
# define PREDICT
@@ -301,7 +300,7 @@ static void ssleay_rand_add(const void *buf, int 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];
}
@@ -316,7 +315,7 @@ static void ssleay_rand_add(const void *buf, int num, double add)
static void ssleay_rand_seed(const void *buf, int num)
{
- ssleay_rand_add(buf, num, num);
+ ssleay_rand_add(buf, num, (double)num);
}
static int ssleay_rand_bytes(unsigned char *buf, int num)
@@ -333,14 +332,6 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
#endif
int do_stir_pool = 0;
-#ifdef OPENSSL_FIPS
- if(FIPS_mode())
- {
- FIPSerr(FIPS_F_SSLEAY_RAND_BYTES,FIPS_R_NON_FIPS_METHOD);
- return 0;
- }
-#endif
-
#ifdef PREDICT
if (rand_predictable)
{
@@ -529,7 +520,7 @@ static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
err = ERR_peek_error();
if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
- (void)ERR_get_error();
+ ERR_clear_error();
}
return (ret);
}
diff --git a/crypto/openssl/crypto/rand/rand.h b/crypto/openssl/crypto/rand/rand.h
index 604df9b..ac6c021 100644
--- a/crypto/openssl/crypto/rand/rand.h
+++ b/crypto/openssl/crypto/rand/rand.h
@@ -72,10 +72,13 @@ extern "C" {
#endif
#if defined(OPENSSL_FIPS)
-#define FIPS_RAND_SIZE_T int
+#define FIPS_RAND_SIZE_T size_t
#endif
-typedef struct rand_meth_st
+/* Already defined in ossl_typ.h */
+/* typedef struct rand_meth_st RAND_METHOD; */
+
+struct rand_meth_st
{
void (*seed)(const void *buf, int num);
int (*bytes)(unsigned char *buf, int num);
@@ -83,7 +86,7 @@ typedef struct rand_meth_st
void (*add)(const void *buf, int num, double entropy);
int (*pseudorand)(unsigned char *buf, int num);
int (*status)(void);
- } RAND_METHOD;
+ };
#ifdef BN_DEBUG
extern int rand_predictable;
@@ -125,17 +128,11 @@ void ERR_load_RAND_strings(void);
/* Error codes for the RAND functions. */
/* Function codes. */
-#define RAND_F_FIPS_RAND_BYTES 102
#define RAND_F_RAND_GET_RAND_METHOD 101
#define RAND_F_SSLEAY_RAND_BYTES 100
/* Reason codes. */
-#define RAND_R_NON_FIPS_METHOD 101
-#define RAND_R_PRNG_ASKING_FOR_TOO_MUCH 105
-#define RAND_R_PRNG_NOT_REKEYED 103
-#define RAND_R_PRNG_NOT_RESEEDED 104
#define RAND_R_PRNG_NOT_SEEDED 100
-#define RAND_R_PRNG_STUCK 102
#ifdef __cplusplus
}
diff --git a/crypto/openssl/crypto/rand/rand_egd.c b/crypto/openssl/crypto/rand/rand_egd.c
index 3ec2eab..50bce6c 100644
--- a/crypto/openssl/crypto/rand/rand_egd.c
+++ b/crypto/openssl/crypto/rand/rand_egd.c
@@ -95,7 +95,7 @@
* RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
*/
-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_VOS)
+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS)
int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
{
return(-1);
@@ -216,7 +216,9 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
while (numbytes != 1)
{
num = read(fd, egdbuf, 1);
- if (num >= 0)
+ if (num == 0)
+ goto err; /* descriptor closed */
+ else if (num > 0)
numbytes += num;
else
{
@@ -246,7 +248,9 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
while (numbytes != egdbuf[0])
{
num = read(fd, retrievebuf + numbytes, egdbuf[0] - numbytes);
- if (num >= 0)
+ if (num == 0)
+ goto err; /* descriptor closed */
+ else if (num > 0)
numbytes += num;
else
{
diff --git a/crypto/openssl/crypto/rand/rand_err.c b/crypto/openssl/crypto/rand/rand_err.c
index 9557465..b2f2448 100644
--- a/crypto/openssl/crypto/rand/rand_err.c
+++ b/crypto/openssl/crypto/rand/rand_err.c
@@ -1,6 +1,6 @@
/* crypto/rand/rand_err.c */
/* ====================================================================
- * Copyright (c) 1999-2003 The OpenSSL Project. All rights reserved.
+ * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -64,22 +64,20 @@
/* BEGIN ERROR CODES */
#ifndef OPENSSL_NO_ERR
+
+#define ERR_FUNC(func) ERR_PACK(ERR_LIB_RAND,func,0)
+#define ERR_REASON(reason) ERR_PACK(ERR_LIB_RAND,0,reason)
+
static ERR_STRING_DATA RAND_str_functs[]=
{
-{ERR_PACK(0,RAND_F_FIPS_RAND_BYTES,0), "FIPS_RAND_BYTES"},
-{ERR_PACK(0,RAND_F_RAND_GET_RAND_METHOD,0), "RAND_get_rand_method"},
-{ERR_PACK(0,RAND_F_SSLEAY_RAND_BYTES,0), "SSLEAY_RAND_BYTES"},
+{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"},
+{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"},
{0,NULL}
};
static ERR_STRING_DATA RAND_str_reasons[]=
{
-{RAND_R_NON_FIPS_METHOD ,"non fips method"},
-{RAND_R_PRNG_ASKING_FOR_TOO_MUCH ,"prng asking for too much"},
-{RAND_R_PRNG_NOT_REKEYED ,"prng not rekeyed"},
-{RAND_R_PRNG_NOT_RESEEDED ,"prng not reseeded"},
-{RAND_R_PRNG_NOT_SEEDED ,"PRNG not seeded"},
-{RAND_R_PRNG_STUCK ,"prng stuck"},
+{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"},
{0,NULL}
};
@@ -93,8 +91,8 @@ void ERR_load_RAND_strings(void)
{
init=0;
#ifndef OPENSSL_NO_ERR
- ERR_load_strings(ERR_LIB_RAND,RAND_str_functs);
- ERR_load_strings(ERR_LIB_RAND,RAND_str_reasons);
+ ERR_load_strings(0,RAND_str_functs);
+ ERR_load_strings(0,RAND_str_reasons);
#endif
}
diff --git a/crypto/openssl/crypto/rand/rand_lib.c b/crypto/openssl/crypto/rand/rand_lib.c
index 88f1b56..513e338 100644
--- a/crypto/openssl/crypto/rand/rand_lib.c
+++ b/crypto/openssl/crypto/rand/rand_lib.c
@@ -63,8 +63,6 @@
#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
#endif
-#include <openssl/fips.h>
-#include <openssl/fips_rand.h>
#ifndef OPENSSL_NO_ENGINE
/* non-NULL if default_RAND_meth is ENGINE-provided */
@@ -87,16 +85,6 @@ int RAND_set_rand_method(const RAND_METHOD *meth)
const RAND_METHOD *RAND_get_rand_method(void)
{
-#ifdef OPENSSL_FIPS
- if(FIPS_mode()
- && default_RAND_meth != FIPS_rand_check())
- {
- RANDerr(RAND_F_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD);
- return 0;
- }
-#endif
-
-
if (!default_RAND_meth)
{
#ifndef OPENSSL_NO_ENGINE
diff --git a/crypto/openssl/crypto/rand/rand_nw.c b/crypto/openssl/crypto/rand/rand_nw.c
new file mode 100644
index 0000000..ba57812
--- /dev/null
+++ b/crypto/openssl/crypto/rand/rand_nw.c
@@ -0,0 +1,176 @@
+/* crypto/rand/rand_nw.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#include "cryptlib.h"
+#include <openssl/rand.h>
+#include "rand_lcl.h"
+
+#if defined (OPENSSL_SYS_NETWARE)
+
+#if defined(NETWARE_LIBC)
+#include <nks/thread.h>
+#endif
+
+extern long RunningProcess;
+
+ /* the FAQ indicates we need to provide at least 20 bytes (160 bits) of seed
+ */
+int RAND_poll(void)
+{
+ unsigned long l;
+ unsigned long tsc;
+ int i;
+
+ /* There are several options to gather miscellaneous data
+ * but for now we will loop checking the time stamp counter (rdtsc) and
+ * the SuperHighResolutionTimer. Each iteration will collect 8 bytes
+ * of data but it is treated as only 1 byte of entropy. The call to
+ * ThreadSwitchWithDelay() will introduce additional variability into
+ * the data returned by rdtsc.
+ *
+ * Applications can agument the seed material by adding additional
+ * stuff with RAND_add() and should probably do so.
+ */
+ l = GetProcessSwitchCount();
+ RAND_add(&l,sizeof(l),1);
+
+ l=RunningProcess;
+ RAND_add(&l,sizeof(l),1);
+
+ for( i=2; i<ENTROPY_NEEDED; i++)
+ {
+#ifdef __MWERKS__
+ asm
+ {
+ rdtsc
+ mov tsc, eax
+ }
+#else
+ asm volatile("rdtsc":"=A" (tsc));
+#endif
+
+ RAND_add(&tsc, sizeof(tsc), 1);
+
+ l = GetSuperHighResolutionTimer();
+ RAND_add(&l, sizeof(l), 0);
+
+# if defined(NETWARE_LIBC)
+ NXThreadYield();
+# else /* NETWARE_CLIB */
+ ThreadSwitchWithDelay();
+# endif
+ }
+
+ return 1;
+}
+
+#endif
+
diff --git a/crypto/openssl/crypto/rand/rand_unix.c b/crypto/openssl/crypto/rand/rand_unix.c
index 0599719..5d031d9 100644
--- a/crypto/openssl/crypto/rand/rand_unix.c
+++ b/crypto/openssl/crypto/rand/rand_unix.c
@@ -108,6 +108,7 @@
* Hudson (tjh@cryptsoft.com).
*
*/
+#include <stdio.h>
#define USE_SOCKETS
#include "e_os.h"
@@ -115,11 +116,12 @@
#include <openssl/rand.h>
#include "rand_lcl.h"
-#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS))
+#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE))
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
+#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
@@ -151,9 +153,10 @@ int RAND_poll(void)
int n = 0;
#endif
#ifdef DEVRANDOM
- static const char *randomfiles[] = { DEVRANDOM, NULL };
- const char **randomfile = NULL;
+ static const char *randomfiles[] = { DEVRANDOM };
+ struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])];
int fd;
+ size_t i;
#endif
#ifdef DEVRANDOM_EGD
static const char *egdsockets[] = { DEVRANDOM_EGD, NULL };
@@ -161,26 +164,43 @@ int RAND_poll(void)
#endif
#ifdef DEVRANDOM
+ memset(randomstats,0,sizeof(randomstats));
/* Use a random entropy pool device. Linux, FreeBSD and OpenBSD
* have this. Use /dev/urandom if you can as /dev/random may block
* if it runs out of random entries. */
- for (randomfile = randomfiles; *randomfile && n < ENTROPY_NEEDED; randomfile++)
+ for (i=0; i<sizeof(randomfiles)/sizeof(randomfiles[0]) && n < ENTROPY_NEEDED; i++)
{
- if ((fd = open(*randomfile, O_RDONLY|O_NONBLOCK
+ if ((fd = open(randomfiles[i], O_RDONLY
+#ifdef O_NONBLOCK
+ |O_NONBLOCK
+#endif
+#ifdef O_BINARY
+ |O_BINARY
+#endif
#ifdef O_NOCTTY /* If it happens to be a TTY (god forbid), do not make it
our controlling tty */
|O_NOCTTY
#endif
-#ifdef O_NOFOLLOW /* Fail if the file is a symbolic link */
- |O_NOFOLLOW
-#endif
)) >= 0)
{
struct timeval t = { 0, 10*1000 }; /* Spend 10ms on
each file. */
int r;
+ size_t j;
fd_set fset;
+ struct stat *st=&randomstats[i];
+
+ /* Avoid using same input... Used to be O_NOFOLLOW
+ * above, but it's not universally appropriate... */
+ if (fstat(fd,st) != 0) { close(fd); continue; }
+ for (j=0;j<i;j++)
+ {
+ if (randomstats[j].st_ino==st->st_ino &&
+ randomstats[j].st_dev==st->st_dev)
+ break;
+ }
+ if (j<i) { close(fd); continue; }
do
{
@@ -232,19 +252,19 @@ int RAND_poll(void)
#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
if (n > 0)
{
- RAND_add(tmpbuf,sizeof tmpbuf,n);
+ RAND_add(tmpbuf,sizeof tmpbuf,(double)n);
OPENSSL_cleanse(tmpbuf,n);
}
#endif
/* put in some default random data, we need more than just this */
l=curr_pid;
- RAND_add(&l,sizeof(l),0);
+ RAND_add(&l,sizeof(l),0.0);
l=getuid();
- RAND_add(&l,sizeof(l),0);
+ RAND_add(&l,sizeof(l),0.0);
l=time(NULL);
- RAND_add(&l,sizeof(l),0);
+ RAND_add(&l,sizeof(l),0.0);
#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
return 1;
diff --git a/crypto/openssl/crypto/rand/rand_vms.c b/crypto/openssl/crypto/rand/rand_vms.c
index 29b2d7a..1267a3a 100644
--- a/crypto/openssl/crypto/rand/rand_vms.c
+++ b/crypto/openssl/crypto/rand/rand_vms.c
@@ -101,11 +101,12 @@ int RAND_poll(void)
pitem = item;
/* Setup */
- while (pitems_data->length)
+ while (pitems_data->length
+ && (total_length + pitems_data->length <= 256))
{
pitem->length = pitems_data->length;
pitem->code = pitems_data->code;
- pitem->buffer = (long *)data_buffer[total_length];
+ pitem->buffer = (long *)&data_buffer[total_length];
pitem->retlen = 0;
total_length += pitems_data->length;
pitems_data++;
diff --git a/crypto/openssl/crypto/rand/rand_win.c b/crypto/openssl/crypto/rand/rand_win.c
index aaea92c..00dbe42 100644
--- a/crypto/openssl/crypto/rand/rand_win.c
+++ b/crypto/openssl/crypto/rand/rand_win.c
@@ -121,6 +121,10 @@
#include <wincrypt.h>
#include <tlhelp32.h>
+/* Limit the time spent walking through the heap, processes, threads and modules to
+ a maximum of 1000 miliseconds each, unless CryptoGenRandom failed */
+#define MAXDELAY 1000
+
/* Intel hardware RNG CSP -- available from
* http://developer.intel.com/design/security/rng/redist_license.htm
*/
@@ -152,6 +156,7 @@ typedef struct tagCURSORINFO
#define CURSOR_SHOWING 0x00000001
#endif /* CURSOR_SHOWING */
+#if !defined(OPENSSL_SYS_WINCE)
typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTW)(HCRYPTPROV *, LPCWSTR, LPCWSTR,
DWORD, DWORD);
typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV, DWORD, BYTE *);
@@ -163,7 +168,7 @@ typedef DWORD (WINAPI *GETQUEUESTATUS)(UINT);
typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
typedef BOOL (WINAPI *CLOSETOOLHELP32SNAPSHOT)(HANDLE);
-typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, DWORD);
+typedef BOOL (WINAPI *HEAP32FIRST)(LPHEAPENTRY32, DWORD, size_t);
typedef BOOL (WINAPI *HEAP32NEXT)(LPHEAPENTRY32);
typedef BOOL (WINAPI *HEAP32LIST)(HANDLE, LPHEAPLIST32);
typedef BOOL (WINAPI *PROCESS32)(HANDLE, LPPROCESSENTRY32);
@@ -171,9 +176,7 @@ typedef BOOL (WINAPI *THREAD32)(HANDLE, LPTHREADENTRY32);
typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32);
#include <lmcons.h>
-#ifndef OPENSSL_SYS_WINCE
#include <lmstats.h>
-#endif
#if 1 /* The NET API is Unicode only. It requires the use of the UNICODE
* macro. When UNICODE is defined LPTSTR becomes LPWSTR. LMSTR was
* was added to the Platform SDK to allow the NET API to be used in
@@ -184,26 +187,14 @@ typedef NET_API_STATUS (NET_API_FUNCTION * NETSTATGET)
(LPWSTR, LPWSTR, DWORD, DWORD, LPBYTE*);
typedef NET_API_STATUS (NET_API_FUNCTION * NETFREE)(LPBYTE);
#endif /* 1 */
+#endif /* !OPENSSL_SYS_WINCE */
int RAND_poll(void)
{
MEMORYSTATUS m;
HCRYPTPROV hProvider = 0;
- BYTE buf[64];
DWORD w;
- HWND h;
-
- HMODULE advapi, kernel, user, netapi;
- CRYPTACQUIRECONTEXTW acquire = 0;
- CRYPTGENRANDOM gen = 0;
- CRYPTRELEASECONTEXT release = 0;
-#if 1 /* There was previously a problem with NETSTATGET. Currently, this
- * section is still experimental, but if all goes well, this conditional
- * will be removed
- */
- NETSTATGET netstatget = 0;
- NETFREE netfree = 0;
-#endif /* 1 */
+ int good = 0;
/* Determine the OS version we are on so we can turn off things
* that do not work properly.
@@ -212,21 +203,24 @@ int RAND_poll(void)
osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
GetVersionEx( &osverinfo ) ;
-#if defined(OPENSSL_SYS_WINCE) && WCEPLATFORM!=MS_HPC_PRO
-#ifndef CryptAcquireContext
-#define CryptAcquireContext CryptAcquireContextW
-#endif
+#if defined(OPENSSL_SYS_WINCE)
+# if defined(_WIN32_WCE) && _WIN32_WCE>=300
+/* Even though MSDN says _WIN32_WCE>=210, it doesn't seem to be available
+ * in commonly available implementations prior 300... */
+ {
+ BYTE buf[64];
/* poll the CryptoAPI PRNG */
/* The CryptoAPI returns sizeof(buf) bytes of randomness */
- if (CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+ if (CryptAcquireContextW(&hProvider, NULL, NULL, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT))
{
if (CryptGenRandom(hProvider, sizeof(buf), buf))
RAND_add(buf, sizeof(buf), sizeof(buf));
CryptReleaseContext(hProvider, 0);
}
-#endif
-
-#ifndef OPENSSL_SYS_WINCE
+ }
+# endif
+#else /* OPENSSL_SYS_WINCE */
/*
* None of below libraries are present on Windows CE, which is
* why we #ifndef the whole section. This also excuses us from
@@ -240,17 +234,19 @@ int RAND_poll(void)
* implement own shim routine, which would accept ANSI argument
* and expand it to Unicode.
*/
-
+ {
/* load functions dynamically - not available on all systems */
- advapi = LoadLibrary(TEXT("ADVAPI32.DLL"));
- kernel = LoadLibrary(TEXT("KERNEL32.DLL"));
- user = LoadLibrary(TEXT("USER32.DLL"));
- netapi = LoadLibrary(TEXT("NETAPI32.DLL"));
-
-#if 1 /* There was previously a problem with NETSTATGET. Currently, this
- * section is still experimental, but if all goes well, this conditional
- * will be removed
- */
+ HMODULE advapi = LoadLibrary(TEXT("ADVAPI32.DLL"));
+ HMODULE kernel = LoadLibrary(TEXT("KERNEL32.DLL"));
+ HMODULE user = NULL;
+ HMODULE netapi = LoadLibrary(TEXT("NETAPI32.DLL"));
+ CRYPTACQUIRECONTEXTW acquire = NULL;
+ CRYPTGENRANDOM gen = NULL;
+ CRYPTRELEASECONTEXT release = NULL;
+ NETSTATGET netstatget = NULL;
+ NETFREE netfree = NULL;
+ BYTE buf[64];
+
if (netapi)
{
netstatget = (NETSTATGET) GetProcAddress(netapi,"NetStatisticsGet");
@@ -280,7 +276,6 @@ int RAND_poll(void)
if (netapi)
FreeLibrary(netapi);
-#endif /* 1 */
/* It appears like this can cause an exception deep within ADVAPI32.DLL
* at random times on Windows 2000. Reported by Jeffrey Altman.
@@ -356,12 +351,13 @@ int RAND_poll(void)
{
/* poll the CryptoAPI PRNG */
/* The CryptoAPI returns sizeof(buf) bytes of randomness */
- if (acquire(&hProvider, 0, 0, PROV_RSA_FULL,
+ if (acquire(&hProvider, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT))
{
if (gen(hProvider, sizeof(buf), buf) != 0)
{
RAND_add(buf, sizeof(buf), 0);
+ good = 1;
#if 0
printf("randomness from PROV_RSA_FULL\n");
#endif
@@ -375,6 +371,7 @@ int RAND_poll(void)
if (gen(hProvider, sizeof(buf), buf) != 0)
{
RAND_add(buf, sizeof(buf), sizeof(buf));
+ good = 1;
#if 0
printf("randomness from PROV_INTEL_SEC\n");
#endif
@@ -386,7 +383,9 @@ int RAND_poll(void)
if (advapi)
FreeLibrary(advapi);
- if (user)
+ if ((osverinfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+ !OPENSSL_isservice()) &&
+ (user = LoadLibrary(TEXT("USER32.DLL"))))
{
GETCURSORINFO cursor;
GETFOREGROUNDWINDOW win;
@@ -399,7 +398,7 @@ int RAND_poll(void)
if (win)
{
/* window handle */
- h = win();
+ HWND h = win();
RAND_add(&h, sizeof(h), 0);
}
if (cursor)
@@ -464,6 +463,7 @@ int RAND_poll(void)
PROCESSENTRY32 p;
THREADENTRY32 t;
MODULEENTRY32 m;
+ DWORD stoptime = 0;
snap = (CREATETOOLHELP32SNAPSHOT)
GetProcAddress(kernel, "CreateToolhelp32Snapshot");
@@ -495,6 +495,7 @@ int RAND_poll(void)
* of entropy.
*/
hlist.dwSize = sizeof(HEAPLIST32);
+ if (good) stoptime = GetTickCount() + MAXDELAY;
if (heaplist_first(handle, &hlist))
do
{
@@ -512,18 +513,20 @@ int RAND_poll(void)
&& --entrycnt > 0);
}
} while (heaplist_next(handle,
- &hlist));
-
+ &hlist) && GetTickCount() < stoptime);
+
/* process walking */
/* PROCESSENTRY32 contains 9 fields that will change
* with each entry. Consider each field a source of
* 1 byte of entropy.
*/
p.dwSize = sizeof(PROCESSENTRY32);
+
+ if (good) stoptime = GetTickCount() + MAXDELAY;
if (process_first(handle, &p))
do
RAND_add(&p, p.dwSize, 9);
- while (process_next(handle, &p));
+ while (process_next(handle, &p) && GetTickCount() < stoptime);
/* thread walking */
/* THREADENTRY32 contains 6 fields that will change
@@ -531,10 +534,11 @@ int RAND_poll(void)
* 1 byte of entropy.
*/
t.dwSize = sizeof(THREADENTRY32);
+ if (good) stoptime = GetTickCount() + MAXDELAY;
if (thread_first(handle, &t))
do
RAND_add(&t, t.dwSize, 6);
- while (thread_next(handle, &t));
+ while (thread_next(handle, &t) && GetTickCount() < stoptime);
/* module walking */
/* MODULEENTRY32 contains 9 fields that will change
@@ -542,18 +546,22 @@ int RAND_poll(void)
* 1 byte of entropy.
*/
m.dwSize = sizeof(MODULEENTRY32);
+ if (good) stoptime = GetTickCount() + MAXDELAY;
if (module_first(handle, &m))
do
RAND_add(&m, m.dwSize, 9);
- while (module_next(handle, &m));
+ while (module_next(handle, &m)
+ && (GetTickCount() < stoptime));
if (close_snap)
close_snap(handle);
else
CloseHandle(handle);
+
}
FreeLibrary(kernel);
}
+ }
#endif /* !OPENSSL_SYS_WINCE */
/* timer data */
@@ -680,7 +688,7 @@ static void readtimer(void)
static void readscreen(void)
{
-#ifndef OPENSSL_SYS_WINCE
+#if !defined(OPENSSL_SYS_WINCE) && !defined(OPENSSL_SYS_WIN32_CYGWIN)
HDC hScrDC; /* screen DC */
HDC hMemDC; /* memory DC */
HBITMAP hBitmap; /* handle for our bitmap */
@@ -693,6 +701,9 @@ static void readscreen(void)
int y; /* y-coordinate of screen lines to grab */
int n = 16; /* number of screen lines to grab at a time */
+ if (GetVersion() >= 0x80000000 || !OPENSSL_isservice())
+ return;
+
/* Create a screen DC and a memory DC compatible to screen DC */
hScrDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
hMemDC = CreateCompatibleDC(hScrDC);
diff --git a/crypto/openssl/crypto/rand/randfile.c b/crypto/openssl/crypto/rand/randfile.c
index c7fba49..d69bdf8 100644
--- a/crypto/openssl/crypto/rand/randfile.c
+++ b/crypto/openssl/crypto/rand/randfile.c
@@ -57,7 +57,7 @@
*/
/* We need to define this to get macros like S_IFBLK and S_IFCHR */
-#define _XOPEN_SOURCE 1
+#define _XOPEN_SOURCE 500
#include <errno.h>
#include <stdio.h>
@@ -104,7 +104,7 @@ int RAND_load_file(const char *file, long bytes)
i=stat(file,&sb);
/* If the state fails, put some crap in anyway */
- RAND_add(&sb,sizeof(sb),0);
+ RAND_add(&sb,sizeof(sb),0.0);
if (i < 0) return(0);
if (bytes == 0) return(ret);
@@ -129,7 +129,7 @@ int RAND_load_file(const char *file, long bytes)
i=fread(buf,1,n,in);
if (i <= 0) break;
/* even if n != i, use the full array */
- RAND_add(buf,n,i);
+ RAND_add(buf,n,(double)i);
ret+=i;
if (bytes > 0)
{
diff --git a/crypto/openssl/crypto/rand/randtest.c b/crypto/openssl/crypto/rand/randtest.c
index 701932e..9e92a70 100644
--- a/crypto/openssl/crypto/rand/randtest.c
+++ b/crypto/openssl/crypto/rand/randtest.c
@@ -65,7 +65,7 @@
/* some FIPS 140-1 random number test */
/* some simple tests */
-int main()
+int main(int argc,char **argv)
{
unsigned char buf[2500];
int i,j,k,s,sign,nsign,err=0;
@@ -211,6 +211,9 @@ int main()
printf("test 4 done\n");
err:
err=((err)?1:0);
+#ifdef OPENSSL_SYS_NETWARE
+ if (err) printf("ERROR: %d\n", err);
+#endif
EXIT(err);
return(err);
}
OpenPOWER on IntegriCloud