# HG changeset patch # User Matt Johnston # Date 1604210497 -28800 # Node ID c3ca130d193a2f4c816cdca2237ec112bc6e10c0 # Parent 0cc85b4a4abba2e9dfc7909f77e7f6af36e4b6df fuzzing - avoid sha1 for random seed every iteration diff -r 0cc85b4a4abb -r c3ca130d193a dbrandom.c --- a/dbrandom.c Thu Oct 29 23:00:52 2020 +0800 +++ b/dbrandom.c Sun Nov 01 14:01:37 2020 +0800 @@ -151,12 +151,17 @@ #if DROPBEAR_FUZZ void fuzz_seed(const unsigned char* dat, unsigned int len) { - hash_state hs; - sha1_init(&hs); - sha1_process(&hs, "fuzzfuzzfuzz", strlen("fuzzfuzzfuzz")); - sha1_process(&hs, dat, len); - sha1_done(&hs, hashpool); - + static unsigned char keep_pool[SHA1_HASH_SIZE]; + static int once = 0; + if (!once) { + once = 1; + hash_state hs; + sha1_init(&hs); + sha1_process(&hs, "fuzzfuzzfuzz", strlen("fuzzfuzzfuzz")); + sha1_process(&hs, dat, len); + sha1_done(&hs, keep_pool); + } + memcpy(hashpool, keep_pool, sizeof(keep_pool)); counter = 0; donerandinit = 1; }