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