Mercurial > dropbear
annotate fuzz.h @ 1741:d1b279aa5ed1 fuzz
Get client fuzzer building and starting (fails straight away)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 18 Oct 2020 12:17:39 +0800 |
parents | dfbe947bdf0d |
children | 28ab2cdb84bf |
rev | line source |
---|---|
1348 | 1 #ifndef DROPBEAR_FUZZ_H |
2 #define DROPBEAR_FUZZ_H | |
3 | |
1357 | 4 #include "config.h" |
1559
92c93b4a3646
Fix to be able to compile normal(ish) binaries with --enable-fuzz
Matt Johnston <matt@ucc.asn.au>
parents:
1558
diff
changeset
|
5 |
1558
2f64cb3d3007
- #if not #ifdef for DROPBEAR_FUZZ
Matt Johnston <matt@ucc.asn.au>
parents:
1456
diff
changeset
|
6 #if DROPBEAR_FUZZ |
1357 | 7 |
1348 | 8 #include "includes.h" |
9 #include "buffer.h" | |
1357 | 10 #include "algo.h" |
11 #include "fuzz-wrapfd.h" | |
1348 | 12 |
1356
3677a510f545
add wrapfd. improve fuzzer in makefile
Matt Johnston <matt@ucc.asn.au>
parents:
1348
diff
changeset
|
13 // once per process |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
14 void fuzz_common_setup(void); |
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
15 void fuzz_svr_setup(void); |
1741
d1b279aa5ed1
Get client fuzzer building and starting (fails straight away)
Matt Johnston <matt@ucc.asn.au>
parents:
1740
diff
changeset
|
16 void fuzz_cli_setup(void); |
1348 | 17 |
1377
d4cc85e6c569
rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents:
1369
diff
changeset
|
18 // must be called once per fuzz iteration. |
d4cc85e6c569
rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents:
1369
diff
changeset
|
19 // returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
20 int fuzz_set_input(const uint8_t *Data, size_t Size); |
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
21 |
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
22 int fuzz_run_preauth(const uint8_t *Data, size_t Size, int skip_kexmaths); |
1589
35af85194268
Add kexdh and kexecdh fuzzers
Matt Johnston <matt@ucc.asn.au>
parents:
1561
diff
changeset
|
23 const void* fuzz_get_algo(const algo_type *algos, const char* name); |
1356
3677a510f545
add wrapfd. improve fuzzer in makefile
Matt Johnston <matt@ucc.asn.au>
parents:
1348
diff
changeset
|
24 |
1369 | 25 // fuzzer functions that intrude into general code |
1357 | 26 void fuzz_kex_fakealgos(void); |
1369 | 27 int fuzz_checkpubkey_line(buffer* line, int line_num, char* filename, |
28 const char* algo, unsigned int algolen, | |
29 const unsigned char* keyblob, unsigned int keybloblen); | |
30 extern const char * const * fuzz_signkey_names; | |
31 void fuzz_seed(void); | |
1741
d1b279aa5ed1
Get client fuzzer building and starting (fails straight away)
Matt Johnston <matt@ucc.asn.au>
parents:
1740
diff
changeset
|
32 |
d1b279aa5ed1
Get client fuzzer building and starting (fails straight away)
Matt Johnston <matt@ucc.asn.au>
parents:
1740
diff
changeset
|
33 // helpers |
1383
f03cfe9c76ac
Disable setnonblocking(), get_socket_address(), set_sock_priority()
Matt Johnston <matt@ucc.asn.au>
parents:
1377
diff
changeset
|
34 void fuzz_get_socket_address(int fd, char **local_host, char **local_port, |
f03cfe9c76ac
Disable setnonblocking(), get_socket_address(), set_sock_priority()
Matt Johnston <matt@ucc.asn.au>
parents:
1377
diff
changeset
|
35 char **remote_host, char **remote_port, int host_lookup); |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
36 void fuzz_fake_send_kexdh_reply(void); |
1740
dfbe947bdf0d
Make wrapfd share a common buffer for all FDs
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
37 int fuzz_spawn_command(int *ret_writefd, int *ret_readfd, int *ret_errfd, pid_t *ret_pid); |
1357 | 38 |
39 // fake IO wrappers | |
40 #ifndef FUZZ_SKIP_WRAP | |
41 #define select(nfds, readfds, writefds, exceptfds, timeout) \ | |
42 wrapfd_select(nfds, readfds, writefds, exceptfds, timeout) | |
43 #define write(fd, buf, count) wrapfd_write(fd, buf, count) | |
44 #define read(fd, buf, count) wrapfd_read(fd, buf, count) | |
1358
6b89eb92f872
glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents:
1357
diff
changeset
|
45 #define close(fd) wrapfd_close(fd) |
1357 | 46 #endif // FUZZ_SKIP_WRAP |
47 | |
1348 | 48 struct dropbear_fuzz_options { |
49 int fuzzing; | |
50 | |
51 // fuzzing input | |
1356
3677a510f545
add wrapfd. improve fuzzer in makefile
Matt Johnston <matt@ucc.asn.au>
parents:
1348
diff
changeset
|
52 buffer *input; |
1357 | 53 struct dropbear_cipher recv_cipher; |
54 struct dropbear_hash recv_mac; | |
55 int wrapfds; | |
1348 | 56 |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
57 // whether to skip slow bignum maths |
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
58 int skip_kexmaths; |
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1385
diff
changeset
|
59 |
1348 | 60 // dropbear_exit() jumps back |
1385
6c92e97553f1
Add a flag whether to longjmp, missed that last commit
Matt Johnston <matt@ucc.asn.au>
parents:
1383
diff
changeset
|
61 int do_jmp; |
1348 | 62 sigjmp_buf jmp; |
63 }; | |
64 | |
65 extern struct dropbear_fuzz_options fuzz; | |
66 | |
1357 | 67 #endif // DROPBEAR_FUZZ |
1348 | 68 |
69 #endif /* DROPBEAR_FUZZ_H */ |