1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-12 16:47:42 -05:00

Replace all uses of SHA*_Bytes / MD5Update.

In fact, those functions don't even exist any more. The only way to
get data into a primitive hash state is via the new put_* system. Of
course, that means put_data() is a viable replacement for every
previous call to one of the per-hash update functions - but just
mechanically doing that would have missed the opportunity to simplify
a lot of the call sites.
This commit is contained in:
Simon Tatham
2018-05-24 10:03:36 +01:00
parent f1b1b1d260
commit 4988fd410c
15 changed files with 138 additions and 203 deletions

View File

@ -540,7 +540,7 @@ Bignum *dss_gen_k(const char *id_string, Bignum modulus, Bignum private_key,
* Hash some identifying text plus x.
*/
SHA512_Init(&ss);
SHA512_Bytes(&ss, id_string, strlen(id_string) + 1);
put_asciz(&ss, id_string);
put_mp_ssh2(&ss, private_key);
SHA512_Final(&ss, digest512);
@ -548,8 +548,8 @@ Bignum *dss_gen_k(const char *id_string, Bignum modulus, Bignum private_key,
* Now hash that digest plus the message hash.
*/
SHA512_Init(&ss);
SHA512_Bytes(&ss, digest512, sizeof(digest512));
SHA512_Bytes(&ss, digest, digest_len);
put_data(&ss, digest512, sizeof(digest512));
put_data(&ss, digest, digest_len);
while (1) {
SHA512_State ss2 = ss; /* structure copy */
@ -573,7 +573,7 @@ Bignum *dss_gen_k(const char *id_string, Bignum modulus, Bignum private_key,
/* Very unlikely we get here, but if so, k was unsuitable. */
freebn(k);
/* Perturb the hash to think of a different k. */
SHA512_Bytes(&ss, "x", 1);
put_byte(&ss, 'x');
/* Go round and try again. */
}
}