diff options
author | Suphanat Chunhapanya <haxx.pop@gmail.com> | 2017-08-13 16:56:10 +0700 |
---|---|---|
committer | Suphanat Chunhapanya <haxx.pop@gmail.com> | 2017-08-13 17:50:51 +0700 |
commit | 97347b1109fcbb9b7d6eb74624748c5e6f560b77 (patch) | |
tree | 141c83f761403af65359c19389763a3d4c901ac0 /src/test/fuzz/fuzz_hsdescv3.c | |
parent | c860282fc0ca068b1e5c210130979823ee799636 (diff) | |
download | tor-97347b1109fcbb9b7d6eb74624748c5e6f560b77.tar.gz tor-97347b1109fcbb9b7d6eb74624748c5e6f560b77.zip |
Fuzz outer layer of hsv3 descriptor
The code in fuzz_hsdescv3.c fuzzes the unencrypted layer of the hsv3
descriptor. We need to fuzz the encrypted layer later.
Diffstat (limited to 'src/test/fuzz/fuzz_hsdescv3.c')
-rw-r--r-- | src/test/fuzz/fuzz_hsdescv3.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/test/fuzz/fuzz_hsdescv3.c b/src/test/fuzz/fuzz_hsdescv3.c new file mode 100644 index 0000000000..855c0674e5 --- /dev/null +++ b/src/test/fuzz/fuzz_hsdescv3.c @@ -0,0 +1,71 @@ +/* Copyright (c) 2017, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#define ROUTERPARSE_PRIVATE +#define HS_DESCRIPTOR_PRIVATE + +#include "crypto_ed25519.h" +#include "hs_descriptor.h" +#include "routerparse.h" +#include "util.h" +#include "torcert.h" + +#include "fuzzing.h" + +static void +mock_dump_desc__nodump(const char *desc, const char *type) +{ + (void)desc; + (void)type; +} + +static int +mock_rsa_ed25519_crosscert_check(const uint8_t *crosscert, + const size_t crosscert_len, + const crypto_pk_t *rsa_id_key, + const ed25519_public_key_t *master_key, + const time_t reject_if_expired_before) +{ + (void) crosscert; + (void) crosscert_len; + (void) rsa_id_key; + (void) master_key; + (void) reject_if_expired_before; + return 0; +} + +int +fuzz_init(void) +{ + disable_signature_checking(); + MOCK(dump_desc, mock_dump_desc__nodump); + MOCK(rsa_ed25519_crosscert_check, mock_rsa_ed25519_crosscert_check); + ed25519_init(); + return 0; +} + +int +fuzz_cleanup(void) +{ + return 0; +} + +int +fuzz_main(const uint8_t *data, size_t sz) +{ + hs_descriptor_t *desc = NULL; + + char *fuzzing_data = tor_memdup_nulterm(data, sz); + + hs_desc_decode_descriptor(fuzzing_data, NULL, &desc); + if (desc) { + log_debug(LD_GENERAL, "Decoding okay"); + hs_descriptor_free(desc); + } else { + log_debug(LD_GENERAL, "Decoding failed"); + } + + tor_free(fuzzing_data); + return 0; +} + |