Mercurial > dropbear
comparison dbrandom.c @ 1773:c3ca130d193a
fuzzing - avoid sha1 for random seed every iteration
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 01 Nov 2020 14:01:37 +0800 |
parents | 517fb7b62438 |
children | 833bf9947603 |
comparison
equal
deleted
inserted
replaced
1772:0cc85b4a4abb | 1773:c3ca130d193a |
---|---|
149 #endif | 149 #endif |
150 } | 150 } |
151 | 151 |
152 #if DROPBEAR_FUZZ | 152 #if DROPBEAR_FUZZ |
153 void fuzz_seed(const unsigned char* dat, unsigned int len) { | 153 void fuzz_seed(const unsigned char* dat, unsigned int len) { |
154 hash_state hs; | 154 static unsigned char keep_pool[SHA1_HASH_SIZE]; |
155 sha1_init(&hs); | 155 static int once = 0; |
156 sha1_process(&hs, "fuzzfuzzfuzz", strlen("fuzzfuzzfuzz")); | 156 if (!once) { |
157 sha1_process(&hs, dat, len); | 157 once = 1; |
158 sha1_done(&hs, hashpool); | 158 hash_state hs; |
159 | 159 sha1_init(&hs); |
160 sha1_process(&hs, "fuzzfuzzfuzz", strlen("fuzzfuzzfuzz")); | |
161 sha1_process(&hs, dat, len); | |
162 sha1_done(&hs, keep_pool); | |
163 } | |
164 memcpy(hashpool, keep_pool, sizeof(keep_pool)); | |
160 counter = 0; | 165 counter = 0; |
161 donerandinit = 1; | 166 donerandinit = 1; |
162 } | 167 } |
163 #endif | 168 #endif |
164 | 169 |