1348
|
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" |
1353
|
9 #include "crypto_desc.h" |
|
10 #include "session.h" |
1348
|
11 |
|
12 struct dropbear_fuzz_options fuzz; |
|
13 |
|
14 static void load_fixed_hostkeys(void); |
|
15 |
|
16 static void common_setup_fuzzer(void) { |
|
17 fuzz.fuzzing = 1; |
1350
|
18 crypto_init(); |
1348
|
19 } |
|
20 |
|
21 void svr_setup_fuzzer(void) { |
|
22 struct passwd *pw; |
|
23 |
|
24 common_setup_fuzzer(); |
1353
|
25 |
|
26 _dropbear_exit = svr_dropbear_exit; |
|
27 _dropbear_log = svr_dropbear_log; |
1348
|
28 |
|
29 char *argv[] = { |
|
30 "-E", |
|
31 }; |
|
32 |
|
33 int argc = sizeof(argv) / sizeof(*argv); |
|
34 svr_getopts(argc, argv); |
|
35 |
|
36 /* user lookups might be slow, cache it */ |
|
37 pw = getpwuid(getuid()); |
|
38 dropbear_assert(pw); |
|
39 fuzz.pw_name = m_strdup(pw->pw_name); |
|
40 fuzz.pw_dir = m_strdup(pw->pw_dir); |
|
41 fuzz.pw_shell = m_strdup(pw->pw_shell); |
|
42 fuzz.pw_passwd = m_strdup("!!zzznope"); |
|
43 |
|
44 load_fixed_hostkeys(); |
|
45 } |
|
46 |
|
47 static void load_fixed_hostkeys(void) { |
|
48 #include "fuzz-hostkeys.c" |
|
49 |
|
50 buffer *b = buf_new(3000); |
|
51 enum signkey_type type; |
|
52 |
|
53 TRACE(("load fixed hostkeys")) |
|
54 |
|
55 svr_opts.hostkey = new_sign_key(); |
|
56 |
|
57 buf_setlen(b, 0); |
|
58 buf_putbytes(b, keyr, keyr_len); |
|
59 buf_setpos(b, 0); |
|
60 type = DROPBEAR_SIGNKEY_RSA; |
|
61 if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { |
|
62 dropbear_exit("failed fixed rsa hostkey"); |
|
63 } |
|
64 |
|
65 buf_setlen(b, 0); |
|
66 buf_putbytes(b, keyd, keyd_len); |
|
67 buf_setpos(b, 0); |
|
68 type = DROPBEAR_SIGNKEY_DSS; |
|
69 if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { |
|
70 dropbear_exit("failed fixed dss hostkey"); |
|
71 } |
|
72 |
|
73 buf_setlen(b, 0); |
|
74 buf_putbytes(b, keye, keye_len); |
|
75 buf_setpos(b, 0); |
|
76 type = DROPBEAR_SIGNKEY_ECDSA_NISTP256; |
|
77 if (buf_get_priv_key(b, svr_opts.hostkey, &type) == DROPBEAR_FAILURE) { |
|
78 dropbear_exit("failed fixed ecdsa hostkey"); |
|
79 } |
|
80 |
|
81 buf_free(b); |
|
82 } |
|
83 |
|
84 #endif /* DROPBEAR_FUZZ */ |