Loading scripts/codegen/fuzzing_include_am.py +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ FUZZERS = """ diff-apply extrainfo hsdescv2 hsdescv3 http iptsv2 microdesc Loading src/or/torcert.c +6 −6 Original line number Diff line number Diff line Loading @@ -356,12 +356,12 @@ tor_make_rsa_ed25519_crosscert(const ed25519_public_key_t *ed_key, * * Return 0 on success, negative on failure. */ int rsa_ed25519_crosscert_check(const uint8_t *crosscert, MOCK_IMPL(int, 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) const time_t reject_if_expired_before)) { rsa_ed_crosscert_t *cc = NULL; int rv; Loading src/or/torcert.h +6 −5 Original line number Diff line number Diff line Loading @@ -75,11 +75,12 @@ ssize_t tor_make_rsa_ed25519_crosscert(const ed25519_public_key_t *ed_key, const crypto_pk_t *rsa_key, time_t expires, uint8_t **cert); int rsa_ed25519_crosscert_check(const uint8_t *crosscert, MOCK_DECL(int, 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); const time_t reject_if_expired_before)); or_handshake_certs_t *or_handshake_certs_new(void); void or_handshake_certs_free(or_handshake_certs_t *certs); Loading src/test/fuzz/dict/hsdescv3 0 → 100644 +6 −0 Original line number Diff line number Diff line "hs-descriptor" "descriptor-lifetime" "descriptor-signing-key-cert" "revision-counter" "superencrypted" "signature" src/test/fuzz/fuzz_hsdescv3.c 0 → 100644 +71 −0 Original line number Diff line number Diff line /* 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; } Loading
scripts/codegen/fuzzing_include_am.py +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ FUZZERS = """ diff-apply extrainfo hsdescv2 hsdescv3 http iptsv2 microdesc Loading
src/or/torcert.c +6 −6 Original line number Diff line number Diff line Loading @@ -356,12 +356,12 @@ tor_make_rsa_ed25519_crosscert(const ed25519_public_key_t *ed_key, * * Return 0 on success, negative on failure. */ int rsa_ed25519_crosscert_check(const uint8_t *crosscert, MOCK_IMPL(int, 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) const time_t reject_if_expired_before)) { rsa_ed_crosscert_t *cc = NULL; int rv; Loading
src/or/torcert.h +6 −5 Original line number Diff line number Diff line Loading @@ -75,11 +75,12 @@ ssize_t tor_make_rsa_ed25519_crosscert(const ed25519_public_key_t *ed_key, const crypto_pk_t *rsa_key, time_t expires, uint8_t **cert); int rsa_ed25519_crosscert_check(const uint8_t *crosscert, MOCK_DECL(int, 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); const time_t reject_if_expired_before)); or_handshake_certs_t *or_handshake_certs_new(void); void or_handshake_certs_free(or_handshake_certs_t *certs); Loading
src/test/fuzz/dict/hsdescv3 0 → 100644 +6 −0 Original line number Diff line number Diff line "hs-descriptor" "descriptor-lifetime" "descriptor-signing-key-cert" "revision-counter" "superencrypted" "signature"
src/test/fuzz/fuzz_hsdescv3.c 0 → 100644 +71 −0 Original line number Diff line number Diff line /* 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; }