timing.c, and hence takes its own responsibility for calling
noise_regular() at regular intervals. Again, this means it will be
called consistently in _all_ the SSH-speaking tools, not just those
in which I remembered to call it!
git-svn-id: http://svn.tartarus.org/sgt/putty@4913
cda61777-01e9-0310-a592-
d414129be87e
puttygen : [G] winpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand winnoise sshsha winstore misc winctrls sshrsa sshdss winmisc
puttygen : [G] winpgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand winnoise sshsha winstore misc winctrls sshrsa sshdss winmisc
- + sshpubk sshaes sshsh512 import winutils puttygen.res tree234 LIBS
+ + sshpubk sshaes sshsh512 import winutils puttygen.res tree234
+ + notiming LIBS
pterm : [X] UXTERM uxmisc misc ldisc settings pty uxsel BE_NONE uxstore
+ signal CHARSET cmdline ptermm version
pterm : [X] UXTERM uxmisc misc ldisc settings pty uxsel BE_NONE uxstore
+ signal CHARSET cmdline ptermm version
puttygen : [U] cmdgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand uxnoise sshsha misc sshrsa sshdss uxcons uxstore uxmisc
puttygen : [U] cmdgen sshrsag sshdssg sshprime sshdes sshbn sshmd5 version
+ sshrand uxnoise sshsha misc sshrsa sshdss uxcons uxstore uxmisc
- + sshpubk sshaes sshsh512 import puttygen.res tree234 uxgen
+ + sshpubk sshaes sshsh512 import puttygen.res tree234 uxgen notiming
pscp : [U] scp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC
psftp : [U] psftp uxsftp uxcons UXSSH BE_SSH SFTP UXMISC
pscp : [U] scp uxsftp uxcons UXSSH BE_SSH SFTP wildcard UXMISC
psftp : [U] psftp uxsftp uxcons UXSSH BE_SSH SFTP UXMISC
void noise_ultralight(unsigned long data)
{
}
void noise_ultralight(unsigned long data)
{
}
-
-void noise_regular(void)
-{
-}
else
strftime(default_comment, 30, "rsa-key-%Y%m%d", tm);
else
strftime(default_comment, 30, "rsa-key-%Y%m%d", tm);
entropy = get_random_data(bits / 8);
random_add_heavynoise(entropy, bits / 8);
memset(entropy, 0, bits/8);
entropy = get_random_data(bits / 8);
random_add_heavynoise(entropy, bits / 8);
memset(entropy, 0, bits/8);
*/
void random_add_noise(void *noise, int length);
*/
void random_add_noise(void *noise, int length);
int random_byte(void);
void random_get_savedata(void **data, int *len);
extern int random_active;
int random_byte(void);
void random_get_savedata(void **data, int *len);
extern int random_active;
+/* The random number subsystem is activated if at least one other entity
+ * within the program expresses an interest in it. So each SSH session
+ * calls random_ref on startup and random_unref on shutdown. */
+void random_ref(void);
+void random_unref(void);
/*
* Exports from pinger.c.
/*
* Exports from pinger.c.
crBegin(ssh->do_ssh1_login_crstate);
crBegin(ssh->do_ssh1_login_crstate);
if (!pktin)
crWaitUntil(pktin);
if (!pktin)
crWaitUntil(pktin);
s->csmac_tobe = s->scmac_tobe = NULL;
s->cscomp_tobe = s->sccomp_tobe = NULL;
s->csmac_tobe = s->scmac_tobe = NULL;
s->cscomp_tobe = s->sccomp_tobe = NULL;
sfree(ssh);
if (ssh->pinger)
pinger_free(ssh->pinger);
sfree(ssh);
if (ssh->pinger)
pinger_free(ssh->pinger);
#include "putty.h"
#include "ssh.h"
#include "putty.h"
#include "ssh.h"
+/* Collect environmental noise every 5 minutes */
+#define NOISE_REGULAR_INTERVAL (5*60*TICKSPERSEC)
+
void noise_get_heavy(void (*func) (void *, int));
void noise_get_light(void (*func) (void *, int));
void noise_get_heavy(void (*func) (void *, int));
void noise_get_light(void (*func) (void *, int));
static struct RandPool pool;
int random_active = 0;
static struct RandPool pool;
int random_active = 0;
+long next_noise_collection;
static void random_stir(void)
{
static void random_stir(void)
{
+static void random_timer(void *ctx, long now)
+{
+ if (random_active > 0 && now - next_noise_collection >= 0) {
+ noise_regular();
+ next_noise_collection =
+ schedule_timer(NOISE_REGULAR_INTERVAL, random_timer, &pool);
+ }
+}
+
+void random_ref(void)
{
if (!random_active) {
memset(&pool, 0, sizeof(pool)); /* just to start with */
{
if (!random_active) {
memset(&pool, 0, sizeof(pool)); /* just to start with */
noise_get_heavy(random_add_heavynoise_bitbybit);
random_stir();
noise_get_heavy(random_add_heavynoise_bitbybit);
random_stir();
+
+ next_noise_collection =
+ schedule_timer(NOISE_REGULAR_INTERVAL, random_timer, &pool);
+
+ random_active++;
+}
+
+void random_unref(void)
+{
+ random_active--;
return DialogBox(hinst, MAKEINTRESOURCE(201), NULL,
MainDlgProc) != IDOK;
}
return DialogBox(hinst, MAKEINTRESOURCE(201), NULL,
MainDlgProc) != IDOK;
}