2017-05-13 14:50:54 +00:00
|
|
|
#ifndef DROPBEAR_FUZZ_H
|
|
|
|
#define DROPBEAR_FUZZ_H
|
|
|
|
|
2017-05-20 05:23:16 +00:00
|
|
|
#include "config.h"
|
|
|
|
#ifdef DROPBEAR_FUZZ
|
|
|
|
|
2017-05-13 14:50:54 +00:00
|
|
|
#include "includes.h"
|
|
|
|
#include "buffer.h"
|
2017-05-20 05:23:16 +00:00
|
|
|
#include "algo.h"
|
|
|
|
#include "fuzz-wrapfd.h"
|
2017-05-13 14:50:54 +00:00
|
|
|
|
2017-05-18 16:48:46 +00:00
|
|
|
// once per process
|
2018-01-23 15:05:47 +00:00
|
|
|
void fuzz_common_setup(void);
|
|
|
|
void fuzz_svr_setup(void);
|
2017-05-13 14:50:54 +00:00
|
|
|
|
2017-05-25 14:21:49 +00:00
|
|
|
// must be called once per fuzz iteration.
|
|
|
|
// returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE
|
2018-01-23 15:05:47 +00:00
|
|
|
int fuzz_set_input(const uint8_t *Data, size_t Size);
|
|
|
|
|
|
|
|
int fuzz_run_preauth(const uint8_t *Data, size_t Size, int skip_kexmaths);
|
2017-05-18 16:48:46 +00:00
|
|
|
|
2017-05-23 14:43:34 +00:00
|
|
|
// fuzzer functions that intrude into general code
|
2017-05-20 05:23:16 +00:00
|
|
|
void fuzz_kex_fakealgos(void);
|
2017-05-23 14:43:34 +00:00
|
|
|
int fuzz_checkpubkey_line(buffer* line, int line_num, char* filename,
|
|
|
|
const char* algo, unsigned int algolen,
|
|
|
|
const unsigned char* keyblob, unsigned int keybloblen);
|
|
|
|
extern const char * const * fuzz_signkey_names;
|
|
|
|
void fuzz_seed(void);
|
2017-05-26 14:10:51 +00:00
|
|
|
void fuzz_get_socket_address(int fd, char **local_host, char **local_port,
|
|
|
|
char **remote_host, char **remote_port, int host_lookup);
|
2018-01-23 15:05:47 +00:00
|
|
|
void fuzz_fake_send_kexdh_reply(void);
|
2017-05-20 05:23:16 +00:00
|
|
|
|
|
|
|
// fake IO wrappers
|
|
|
|
#ifndef FUZZ_SKIP_WRAP
|
|
|
|
#define select(nfds, readfds, writefds, exceptfds, timeout) \
|
|
|
|
wrapfd_select(nfds, readfds, writefds, exceptfds, timeout)
|
|
|
|
#define write(fd, buf, count) wrapfd_write(fd, buf, count)
|
|
|
|
#define read(fd, buf, count) wrapfd_read(fd, buf, count)
|
2017-05-20 14:47:19 +00:00
|
|
|
#define close(fd) wrapfd_close(fd)
|
2017-05-20 05:23:16 +00:00
|
|
|
#endif // FUZZ_SKIP_WRAP
|
|
|
|
|
2017-05-13 14:50:54 +00:00
|
|
|
struct dropbear_fuzz_options {
|
|
|
|
int fuzzing;
|
|
|
|
|
|
|
|
// to record an unencrypted stream
|
|
|
|
FILE* recordf;
|
|
|
|
|
|
|
|
// fuzzing input
|
2017-05-18 16:48:46 +00:00
|
|
|
buffer *input;
|
2017-05-20 05:23:16 +00:00
|
|
|
struct dropbear_cipher recv_cipher;
|
|
|
|
struct dropbear_hash recv_mac;
|
|
|
|
int wrapfds;
|
2017-05-13 14:50:54 +00:00
|
|
|
|
2018-01-23 15:05:47 +00:00
|
|
|
// whether to skip slow bignum maths
|
|
|
|
int skip_kexmaths;
|
|
|
|
|
2017-05-13 14:50:54 +00:00
|
|
|
// dropbear_exit() jumps back
|
2017-06-01 13:30:26 +00:00
|
|
|
int do_jmp;
|
2017-05-13 14:50:54 +00:00
|
|
|
sigjmp_buf jmp;
|
|
|
|
|
|
|
|
uid_t pw_uid;
|
|
|
|
gid_t pw_gid;
|
|
|
|
char* pw_name;
|
|
|
|
char* pw_dir;
|
|
|
|
char* pw_shell;
|
|
|
|
char* pw_passwd;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct dropbear_fuzz_options fuzz;
|
|
|
|
|
2017-05-20 05:23:16 +00:00
|
|
|
#endif // DROPBEAR_FUZZ
|
2017-05-13 14:50:54 +00:00
|
|
|
|
|
|
|
#endif /* DROPBEAR_FUZZ_H */
|