diff --git a/putty.h b/putty.h index 46c4e54e..ca8ee4a5 100644 --- a/putty.h +++ b/putty.h @@ -1818,9 +1818,14 @@ void random_unref(void); * logical main() no matter whether it needed random numbers or * not. */ void random_clear(void); -/* random_setup_special is used by PuTTYgen. It makes an extra-big - * random number generator. */ -void random_setup_special(void); +/* random_setup_custom sets up the process-global random number + * generator specially, with a hash function of your choice. */ +void random_setup_custom(const ssh_hashalg *hash); +/* random_setup_special() is a macro wrapper on that, which makes an + * extra-big one based on SHA-512. It's defined this way to avoid what + * would otherwise be an unnecessary module dependency from sshrand.c + * to sshsh512.c. */ +#define random_setup_special() random_setup_custom(&ssh_sha512) /* Manually drop a random seed into the random number generator, e.g. * just before generating a key. */ void random_reseed(ptrlen seed); diff --git a/sshrand.c b/sshrand.c index 387a068a..7f3d6411 100644 --- a/sshrand.c +++ b/sshrand.c @@ -19,7 +19,7 @@ int random_active = 0; */ void random_add_noise(NoiseSourceId source, const void *noise, int length) { } void random_ref(void) { } -void random_setup_special(void) { } +void random_setup_custom(const ssh_hashalg *hash) { } void random_unref(void) { } void random_read(void *out, size_t size) { @@ -97,10 +97,10 @@ void random_ref(void) random_create(&ssh_sha256); } -void random_setup_special() +void random_setup_custom(const ssh_hashalg *hash) { random_active++; - random_create(&ssh_sha512); + random_create(hash); } void random_reseed(ptrlen seed)