diff options
author | Micah Elizabeth Scott <beth@torproject.org> | 2023-05-17 18:33:19 -0700 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2023-05-24 11:12:15 -0400 |
commit | 71b2958a624259ac4a10a67b76a12b0064f17616 (patch) | |
tree | b9337ea0958ab78f5f7bc794cdd197ab40560d46 /src/test/hs_test_helpers.c | |
parent | 459b775a7eb5b26fb73b56c1a0f02548e53c45cc (diff) | |
download | tor-71b2958a624259ac4a10a67b76a12b0064f17616.tar.gz tor-71b2958a624259ac4a10a67b76a12b0064f17616.zip |
test_hs_descriptor: Add a test case that fails without the fix for 40793
This adds a bit more to hs_descriptor/test_decode_descriptor, mostly
testing pow-params and triggering the tor_assert() in issue #40793.
There was no mechanism for adding arbitrary test strings to the
encrypted portion of the desc without duplicating encode logic. One
option might be to publicize get_inner_encrypted_layer_plaintext enough
to add a mock implementation. In this patch I opt for what seems like
the simplest solution, at the cost of a small amount of #ifdef noise.
The unpacked descriptor grows a new test-only member that's used for
dropping arbitrary data in at encode time.
Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
Diffstat (limited to 'src/test/hs_test_helpers.c')
-rw-r--r-- | src/test/hs_test_helpers.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/hs_test_helpers.c b/src/test/hs_test_helpers.c index 20b225ba4a..4ef2398095 100644 --- a/src/test/hs_test_helpers.c +++ b/src/test/hs_test_helpers.c @@ -354,6 +354,18 @@ hs_helper_desc_equal(const hs_descriptor_t *desc1, } } + /* Proof of Work DoS mitigation options */ + tt_int_op(!!desc1->encrypted_data.pow_params, OP_EQ, + !!desc2->encrypted_data.pow_params); + if (desc1->encrypted_data.pow_params && desc2->encrypted_data.pow_params) { + hs_pow_desc_params_t *params1 = desc1->encrypted_data.pow_params; + hs_pow_desc_params_t *params2 = desc2->encrypted_data.pow_params; + tt_int_op(params1->type, OP_EQ, params2->type); + tt_mem_op(params1->seed, OP_EQ, params2->seed, HS_POW_SEED_LEN); + tt_int_op(params1->suggested_effort, OP_EQ, params2->suggested_effort); + tt_int_op(params1->expiration_time, OP_EQ, params2->expiration_time); + } + /* Introduction points. */ { tt_assert(desc1->encrypted_data.intro_points); |