annotate fuzzer-pubkey.c @ 1672:3a97f14c0235

Add Chacha20-Poly1305, AES128-GCM and AES256-GCM support (#93) * Add Chacha20-Poly1305 authenticated encryption * Add general AEAD approach. * Add [email protected] algo using LibTomCrypt chacha and poly1305 routines. Chacha20-Poly1305 is generally faster than AES256 on CPU w/o dedicated AES instructions, having the same key size. Compiling in will add ~5,5kB to binary size on x86-64. function old new delta chacha_crypt - 1397 +1397 _poly1305_block - 608 +608 poly1305_done - 595 +595 dropbear_chachapoly_crypt - 457 +457 .rodata 26976 27392 +416 poly1305_process - 290 +290 poly1305_init - 221 +221 chacha_setup - 218 +218 encrypt_packet 1068 1270 +202 dropbear_chachapoly_getlength - 147 +147 decrypt_packet 756 897 +141 chacha_ivctr64 - 137 +137 read_packet 543 637 +94 dropbear_chachapoly_start - 94 +94 read_kex_algos 792 880 +88 chacha_keystream - 69 +69 dropbear_mode_chachapoly - 48 +48 sshciphers 280 320 +40 dropbear_mode_none 24 48 +24 dropbear_mode_ctr 24 48 +24 dropbear_mode_cbc 24 48 +24 dropbear_chachapoly_mac - 24 +24 dropbear_chachapoly - 24 +24 gen_new_keys 848 854 +6 ------------------------------------------------------------------------------ (add/remove: 14/0 grow/shrink: 10/0 up/down: 5388/0) Total: 5388 bytes * Add AES128-GCM and AES256-GCM authenticated encryption * Add general AES-GCM mode. * Add [email protected] and [email protected] algo using LibTomCrypt gcm routines. AES-GCM is combination of AES CTR mode and GHASH, slower than AES-CTR on CPU w/o dedicated AES/GHASH instructions therefore disabled by default. Compiling in will add ~6kB to binary size on x86-64. function old new delta gcm_process - 1060 +1060 .rodata 26976 27808 +832 gcm_gf_mult - 820 +820 gcm_add_aad - 660 +660 gcm_shift_table - 512 +512 gcm_done - 471 +471 gcm_add_iv - 384 +384 gcm_init - 347 +347 dropbear_gcm_crypt - 309 +309 encrypt_packet 1068 1270 +202 decrypt_packet 756 897 +141 gcm_reset - 118 +118 read_packet 543 637 +94 read_kex_algos 792 880 +88 sshciphers 280 360 +80 gcm_mult_h - 80 +80 dropbear_gcm_start - 62 +62 dropbear_mode_gcm - 48 +48 dropbear_mode_none 24 48 +24 dropbear_mode_ctr 24 48 +24 dropbear_mode_cbc 24 48 +24 dropbear_ghash - 24 +24 dropbear_gcm_getlength - 24 +24 gen_new_keys 848 854 +6 ------------------------------------------------------------------------------ (add/remove: 14/0 grow/shrink: 10/0 up/down: 6434/0) Total: 6434 bytes
author Vladislav Grishenko <themiron@users.noreply.github.com>
date Mon, 25 May 2020 20:50:25 +0500
parents 252b406d0e9a
children ba6fc7afe1c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 #include "fuzz.h"
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 #include "session.h"
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 #include "fuzz-wrapfd.h"
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 #include "debug.h"
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 static void setup_fuzzer(void) {
1456
a90fdd2d2ed8 add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents: 1383
diff changeset
7 fuzz_common_setup();
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 }
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 static int once = 0;
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 if (!once) {
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 setup_fuzzer();
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 once = 1;
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 }
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16
1456
a90fdd2d2ed8 add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents: 1383
diff changeset
17 if (fuzz_set_input(Data, Size) == DROPBEAR_FAILURE) {
1377
d4cc85e6c569 rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents: 1369
diff changeset
18 return 0;
d4cc85e6c569 rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents: 1369
diff changeset
19 }
d4cc85e6c569 rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents: 1369
diff changeset
20
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 m_malloc_set_epoch(1);
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22
1584
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
23 if (setjmp(fuzz.jmp) == 0) {
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
24 buffer *line = buf_getstringbuf(fuzz.input);
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
25 buffer *keyblob = buf_getstringbuf(fuzz.input);
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
26
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
27 unsigned int algolen;
1586
e6a5e51a29c9 - fuzzer-pubkey needs to free algoname, fix build
Matt Johnston <matt@ucc.asn.au>
parents: 1584
diff changeset
28 char* algoname = buf_getstring(keyblob, &algolen);
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29
1586
e6a5e51a29c9 - fuzzer-pubkey needs to free algoname, fix build
Matt Johnston <matt@ucc.asn.au>
parents: 1584
diff changeset
30 if (have_algo(algoname, algolen, sshhostkey) == DROPBEAR_FAILURE) {
1584
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
31 dropbear_exit("fuzzer imagined a bogus algorithm");
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
32 }
1598
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
33
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
34 int ret = fuzz_checkpubkey_line(line, 5, "/home/me/authorized_keys",
1584
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
35 algoname, algolen,
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
36 keyblob->data, keyblob->len);
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
37
1598
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
38 if (ret == DROPBEAR_SUCCESS) {
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
39 /* fuzz_checkpubkey_line() should have cleaned up for failure */
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
40 svr_pubkey_options_cleanup();
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
41 }
252b406d0e9a avoid leak of pubkey_options
Matt Johnston <matt@ucc.asn.au>
parents: 1586
diff changeset
42
1584
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
43 buf_free(line);
cdfab509c392 use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
44 buf_free(keyblob);
1586
e6a5e51a29c9 - fuzzer-pubkey needs to free algoname, fix build
Matt Johnston <matt@ucc.asn.au>
parents: 1584
diff changeset
45 m_free(algoname);
1383
f03cfe9c76ac Disable setnonblocking(), get_socket_address(), set_sock_priority()
Matt Johnston <matt@ucc.asn.au>
parents: 1378
diff changeset
46 m_malloc_free_epoch(1, 0);
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 } else {
1378
7209a6e30932 linked list dbmalloc now
Matt Johnston <matt@ucc.asn.au>
parents: 1377
diff changeset
48 m_malloc_free_epoch(1, 1);
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 TRACE(("dropbear_exit longjmped"))
1559
92c93b4a3646 Fix to be able to compile normal(ish) binaries with --enable-fuzz
Matt Johnston <matt@ucc.asn.au>
parents: 1456
diff changeset
50 /* dropbear_exit jumped here */
1369
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 }
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 return 0;
ddfcadca3c4c fuzzer-pubkey
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 }