summaryrefslogtreecommitdiff
path: root/entropy.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2005-09-27 22:46:32 +1000
committerDarren Tucker <dtucker@zip.com.au>2005-09-27 22:46:32 +1000
commitc6f8219e0d4ee1f64fb7b4da88523c951a03c68a (patch)
treed861d4cbccee17f7de7c864e1d26634c0174741d /entropy.c
parentf1377bdeed3ca7268c6a5d3fa171a09df7be9064 (diff)
- (dtucker) [entropy.c entropy.h sshd.c] Pass RNG seed to the reexec'ed
process when sshd relies on ssh-random-helper. Should result in faster logins on systems without a real random device or prngd. ok djm@
Diffstat (limited to 'entropy.c')
-rw-r--r--entropy.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/entropy.c b/entropy.c
index 7f4a30783..ff97415a9 100644
--- a/entropy.c
+++ b/entropy.c
@@ -26,6 +26,7 @@
26 26
27#include <openssl/rand.h> 27#include <openssl/rand.h>
28#include <openssl/crypto.h> 28#include <openssl/crypto.h>
29#include <openssl/err.h>
29 30
30#include "ssh.h" 31#include "ssh.h"
31#include "misc.h" 32#include "misc.h"
@@ -33,6 +34,8 @@
33#include "atomicio.h" 34#include "atomicio.h"
34#include "pathnames.h" 35#include "pathnames.h"
35#include "log.h" 36#include "log.h"
37#include "buffer.h"
38#include "bufaux.h"
36 39
37/* 40/*
38 * Portable OpenSSH PRNG seeding: 41 * Portable OpenSSH PRNG seeding:
@@ -45,7 +48,7 @@
45 * XXX: we should tell the child how many bytes we need. 48 * XXX: we should tell the child how many bytes we need.
46 */ 49 */
47 50
48RCSID("$Id: entropy.c,v 1.50 2005/09/27 09:50:25 dtucker Exp $"); 51RCSID("$Id: entropy.c,v 1.51 2005/09/27 12:46:32 dtucker Exp $");
49 52
50#ifndef OPENSSL_PRNG_ONLY 53#ifndef OPENSSL_PRNG_ONLY
51#define RANDOM_SEED_SIZE 48 54#define RANDOM_SEED_SIZE 48
@@ -150,3 +153,30 @@ init_rng(void)
150#endif 153#endif
151} 154}
152 155
156#ifndef OPENSSL_PRNG_ONLY
157void
158rexec_send_rng_seed(Buffer *m)
159{
160 u_char buf[RANDOM_SEED_SIZE];
161
162 if (RAND_bytes(buf, sizeof(buf)) <= 0) {
163 error("Couldn't obtain random bytes (error %ld)",
164 ERR_get_error());
165 buffer_put_string(m, "", 0);
166 } else
167 buffer_put_string(m, buf, sizeof(buf));
168}
169
170void
171rexec_recv_rng_seed(Buffer *m)
172{
173 char *buf;
174 u_int len;
175
176 buf = buffer_get_string_ret(m, &len);
177 if (buf != NULL) {
178 debug3("rexec_recv_rng_seed: seeding rng with %u bytes", len);
179 RAND_add(buf, len, len);
180 }
181}
182#endif