Mercurial > dropbear
comparison fuzz-common.c @ 1348:5c2899e35b63 fuzz
fuzz harness
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 13 May 2017 22:50:54 +0800 |
parents | |
children | 2722f2347a48 |
comparison
equal
deleted
inserted
replaced
1347:b28624698130 | 1348:5c2899e35b63 |
---|---|
1 #include "includes.h" | |
2 | |
3 #ifdef DROPBEAR_FUZZ | |
4 | |
5 #include "includes.h" | |
6 #include "fuzz.h" | |
7 #include "dbutil.h" | |
8 #include "runopts.h" | |
9 | |
10 struct dropbear_fuzz_options fuzz; | |
11 | |
12 static void load_fixed_hostkeys(void); | |
13 | |
14 static void common_setup_fuzzer(void) { | |
15 fuzz.fuzzing = 1; | |
16 } | |
17 | |
18 void svr_setup_fuzzer(void) { | |
19 struct passwd *pw; | |
20 | |
21 common_setup_fuzzer(); | |
22 | |
23 char *argv[] = { | |
24 "-E", | |
25 }; | |
26 | |
27 int argc = sizeof(argv) / sizeof(*argv); | |
28 svr_getopts(argc, argv); | |
29 | |
30 /* user lookups might be slow, cache it */ | |
31 pw = getpwuid(getuid()); | |
32 dropbear_assert(pw); | |
33 fuzz.pw_name = m_strdup(pw->pw_name); | |
34 fuzz.pw_dir = m_strdup(pw->pw_dir); | |
35 fuzz.pw_shell = m_strdup(pw->pw_shell); | |
36 fuzz.pw_passwd = m_strdup("!!zzznope"); | |
37 | |
38 load_fixed_hostkeys(); | |
39 } | |
40 | |
41 static void load_fixed_hostkeys(void) { | |
42 #include "fuzz-hostkeys.c" | |
43 | |
44 buffer *b = buf_new(3000); | |
45 enum signkey_type type; | |
46 | |
47 TRACE(("load fixed hostkeys")) | |
48 | |
49 svr_opts.hostkey = new_sign_key(); | |
50 | |
51 buf_setlen(b, 0); | |
52 buf_putbytes(b, keyr, keyr_len); | |
53 buf_setpos(b, 0); | |
54 type = DROPBEAR_SIGNKEY_RSA; | |
55 if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { | |
56 dropbear_exit("failed fixed rsa hostkey"); | |
57 } | |
58 | |
59 buf_setlen(b, 0); | |
60 buf_putbytes(b, keyd, keyd_len); | |
61 buf_setpos(b, 0); | |
62 type = DROPBEAR_SIGNKEY_DSS; | |
63 if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { | |
64 dropbear_exit("failed fixed dss hostkey"); | |
65 } | |
66 | |
67 buf_setlen(b, 0); | |
68 buf_putbytes(b, keye, keye_len); | |
69 buf_setpos(b, 0); | |
70 type = DROPBEAR_SIGNKEY_ECDSA_NISTP256; | |
71 if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { | |
72 dropbear_exit("failed fixed ecdsa hostkey"); | |
73 } | |
74 | |
75 buf_free(b); | |
76 } | |
77 | |
78 #endif /* DROPBEAR_FUZZ */ |