aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2014-12-17 19:39:18 +0100
committerAndreas Schneider <asn@cryptomilk.org>2014-12-17 19:40:57 +0100
commit055f102601c201463d628d910c2f9dfe0e91d075 (patch)
tree1fc30b9e58cb9ab2dd8e06f2eb3289be113655bc
parent2d6862ddb90c6d617021fd36371fdaf31c507660 (diff)
downloadlibssh-055f102601c201463d628d910c2f9dfe0e91d075.tar.gz
libssh-055f102601c201463d628d910c2f9dfe0e91d075.tar.xz
libssh-055f102601c201463d628d910c2f9dfe0e91d075.zip
libcrypto: Fix Windows build with ssh_reseed().
gettimeofday() is not available on Windows and we need it only in case of forking. Signed-off-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit b7b535816d5fa49b0d1783f4cb42086f4169b1da)
-rw-r--r--ConfigureChecks.cmake1
-rw-r--r--config.h.cmake3
-rw-r--r--src/libcrypto.c5
3 files changed, 9 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 8f76af82..d9ef5a76 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -51,6 +51,7 @@ check_include_file(pty.h HAVE_PTY_H)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(util.h HAVE_UTIL_H)
+check_include_file(sys/time.h HAVE_SYS_TIME_H)
if (WIN32)
check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
diff --git a/config.h.cmake b/config.h.cmake
index 7e8cb6a8..396656d2 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -23,6 +23,9 @@
/* Define to 1 if you have the <util.h> header file. */
#cmakedefine HAVE_UTIL_H 1
+/* Define to 1 if you have the <sys/time.h> header file. */
+#cmakedefine HAVE_SYS_TIME_H 1
+
/* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H 1
diff --git a/src/libcrypto.c b/src/libcrypto.c
index 174b0c64..afa8bdc9 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -19,11 +19,14 @@
* MA 02111-1307, USA.
*/
+#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include "libssh/priv.h"
#include "libssh/session.h"
@@ -78,9 +81,11 @@ static int alloc_key(struct ssh_cipher_struct *cipher) {
}
void ssh_reseed(void){
+#ifndef _WIN32
struct timeval tv;
gettimeofday(&tv, NULL);
RAND_add(&tv, sizeof(tv), 0.0);
+#endif
}
SHACTX sha1_init(void) {