1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
diff -rupN a/include/libssh/wrapper.h b/include/libssh/wrapper.h
--- a/include/libssh/wrapper.h 2013-07-26 06:39:39.000000000 +0000
+++ b/include/libssh/wrapper.h 2014-03-09 16:38:49.807812235 +0000
@@ -44,5 +44,6 @@ int crypt_set_algorithms_server(ssh_sess
struct ssh_crypto_struct *crypto_new(void);
void crypto_free(struct ssh_crypto_struct *crypto);
+void ssh_reseed(void);
#endif /* WRAPPER_H_ */
diff -rupN a/src/bind.c b/src/bind.c
--- a/src/bind.c 2013-07-26 06:39:39.000000000 +0000
+++ b/src/bind.c 2014-03-09 16:39:00.571080087 +0000
@@ -375,6 +375,7 @@ int ssh_bind_accept(ssh_bind sshbind, ss
session->dsa_key = dsa;
session->rsa_key = rsa;
+ ssh_reseed();
return SSH_OK;
}
diff -rupN a/src/libcrypto.c b/src/libcrypto.c
--- a/src/libcrypto.c 2013-07-26 06:39:39.000000000 +0000
+++ b/src/libcrypto.c 2014-03-09 16:40:07.807331327 +0000
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <sys/time.h>
#include "libssh/priv.h"
#include "libssh/session.h"
@@ -38,6 +39,8 @@
#include <openssl/rsa.h>
#include <openssl/hmac.h>
#include <openssl/opensslv.h>
+#include <openssl/rand.h>
+
#ifdef HAVE_OPENSSL_AES_H
#define HAS_AES
#include <openssl/aes.h>
@@ -66,6 +69,12 @@ static int alloc_key(struct crypto_struc
return 0;
}
+void ssh_reseed(void) {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ RAND_add(&tv, sizeof(tv), 0.0);
+}
+
SHACTX sha1_init(void) {
SHACTX c = malloc(sizeof(*c));
if (c == NULL) {
diff -rupN a/src/libgcrypt.c b/src/libgcrypt.c
--- a/src/libgcrypt.c 2013-07-26 06:39:39.000000000 +0000
+++ b/src/libgcrypt.c 2014-03-09 16:40:51.730392881 +0000
@@ -41,6 +41,9 @@ static int alloc_key(struct crypto_struc
return 0;
}
+void ssh_reseed(void) {
+ }
+
SHACTX sha1_init(void) {
SHACTX ctx = NULL;
gcry_md_open(&ctx, GCRY_MD_SHA1, 0);
|