summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2020-11-01 14:01:37 +0800
committerMatt Johnston <matt@ucc.asn.au>2020-11-01 14:01:37 +0800
commit1b6e16ae7c9105e35dd14464b8ce785c613ab6e2 (patch)
tree5d963531efe9397b81a6abba53b82e2d5f43e093
parentb8352f81642ef4e0bd3c256e091f70a6723bdb24 (diff)
fuzzing - avoid sha1 for random seed every iteration
-rw-r--r--dbrandom.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/dbrandom.c b/dbrandom.c
index faada2a..7aaa42b 100644
--- a/dbrandom.c
+++ b/dbrandom.c
@@ -151,12 +151,17 @@ static void write_urandom()
#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;
}