#include "e_os.h"
+#if !(defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYSNAME_DSPBIOS))
+# include <sys/time.h>
+#endif
+#if defined(OPENSSL_SYS_VXWORKS)
+# include <time.h>
+#endif
+
+#include <openssl/crypto.h>
#include <openssl/rand.h>
#include "rand_lcl.h"
-#include <openssl/crypto.h>
#include <openssl/err.h>
#ifdef OPENSSL_FIPS
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
static int ssleay_rand_status(void);
-RAND_METHOD rand_ssleay_meth={
+static RAND_METHOD rand_ssleay_meth={
ssleay_rand_seed,
ssleay_rand_nopseudo_bytes,
ssleay_rand_cleanup,
#ifndef GETPID_IS_MEANINGLESS
pid_t curr_pid = getpid();
#endif
+ time_t curr_time = time(NULL);
int do_stir_pool = 0;
+/* time value for various platforms */
+#ifdef OPENSSL_SYS_WIN32
+ FILETIME tv;
+# ifdef _WIN32_WCE
+ SYSTEMTIME t;
+ GetSystemTime(&t);
+ SystemTimeToFileTime(&t, &tv);
+# else
+ GetSystemTimeAsFileTime(&tv);
+# endif
+#elif defined(OPENSSL_SYS_VXWORKS)
+ struct timespec tv;
+ clock_gettime(CLOCK_REALTIME, &ts);
+#elif defined(OPENSSL_SYSNAME_DSPBIOS)
+ unsigned long long tv, OPENSSL_rdtsc();
+ tv = OPENSSL_rdtsc();
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+#endif
#ifdef PREDICT
if (rand_predictable)
#ifndef GETPID_IS_MEANINGLESS
if (curr_pid) /* just in the first iteration to save time */
{
- if (!MD_Update(&m,(unsigned char*)&curr_pid,sizeof curr_pid))
+ if (!MD_Update(&m,(unsigned char*)&curr_pid,
+ sizeof curr_pid))
goto err;
curr_pid = 0;
}
#endif
+ if (curr_time) /* just in the first iteration to save time */
+ {
+ if (!MD_Update(&m,(unsigned char*)&curr_time,
+ sizeof curr_time))
+ goto err;
+ if (!MD_Update(&m,(unsigned char*)&tv,
+ sizeof tv))
+ goto err;
+ curr_time = 0;
+ }
if (!MD_Update(&m,local_md,MD_DIGEST_LENGTH))
goto err;
if (!MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)))