mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-31 02:32:49 -05:00
Remove dependency of sshrand.c on SHA-512.
Rather like some of the tricks I did in mpint.h, this replaces the unparametrised function random_setup_special() with one called random_setup_custom() taking a hash-algorithm parameter. The old syntax random_setup_special() still exists, and is a macro wrapper on random_setup_custom() that passes ssh_sha512 as an argument. This means I can keep the choice of hash function consistent between the key generation front ends. This adds potential flexibility: now, anyone wanting a different kind of special RNG can make it out of whatever primitive they like. But a more immediate point is to remove an inter-module dependency: sshrand.c now doesn't need to be linked against the SHA-512 code.
This commit is contained in:
parent
132d48b8f3
commit
3daa36293e
11
putty.h
11
putty.h
@ -1818,9 +1818,14 @@ void random_unref(void);
|
|||||||
* logical main() no matter whether it needed random numbers or
|
* logical main() no matter whether it needed random numbers or
|
||||||
* not. */
|
* not. */
|
||||||
void random_clear(void);
|
void random_clear(void);
|
||||||
/* random_setup_special is used by PuTTYgen. It makes an extra-big
|
/* random_setup_custom sets up the process-global random number
|
||||||
* random number generator. */
|
* generator specially, with a hash function of your choice. */
|
||||||
void random_setup_special(void);
|
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.
|
/* Manually drop a random seed into the random number generator, e.g.
|
||||||
* just before generating a key. */
|
* just before generating a key. */
|
||||||
void random_reseed(ptrlen seed);
|
void random_reseed(ptrlen seed);
|
||||||
|
@ -19,7 +19,7 @@ int random_active = 0;
|
|||||||
*/
|
*/
|
||||||
void random_add_noise(NoiseSourceId source, const void *noise, int length) { }
|
void random_add_noise(NoiseSourceId source, const void *noise, int length) { }
|
||||||
void random_ref(void) { }
|
void random_ref(void) { }
|
||||||
void random_setup_special(void) { }
|
void random_setup_custom(const ssh_hashalg *hash) { }
|
||||||
void random_unref(void) { }
|
void random_unref(void) { }
|
||||||
void random_read(void *out, size_t size)
|
void random_read(void *out, size_t size)
|
||||||
{
|
{
|
||||||
@ -97,10 +97,10 @@ void random_ref(void)
|
|||||||
random_create(&ssh_sha256);
|
random_create(&ssh_sha256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void random_setup_special()
|
void random_setup_custom(const ssh_hashalg *hash)
|
||||||
{
|
{
|
||||||
random_active++;
|
random_active++;
|
||||||
random_create(&ssh_sha512);
|
random_create(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void random_reseed(ptrlen seed)
|
void random_reseed(ptrlen seed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user