summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMicah Elizabeth Scott <beth@torproject.org>2023-03-14 20:45:36 -0700
committerMicah Elizabeth Scott <beth@torproject.org>2023-05-10 07:38:28 -0700
commit00d9e0d252687110189ea5a1ed0dce99a7984681 (patch)
treed1c936037c98231b423ebdfd010a95376dabb63a /src/test
parent209a59face791159e167837214e22b6eaa3375b4 (diff)
downloadtor-00d9e0d252687110189ea5a1ed0dce99a7984681.tar.gz
tor-00d9e0d252687110189ea5a1ed0dce99a7984681.zip
hs_pow: Define seed_head as uint8_t[4] instead of uint32_t
This is more consistent with the specification, and it's much less confusing with endianness. This resolves the underlying cause of the earlier byte-swap. This patch itself does not change the wire protocol at all, it's just tidying up the types we use at the trunnel layer. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_hs_pow.c2
-rw-r--r--src/test/test_hs_pow_slow.c11
2 files changed, 6 insertions, 7 deletions
diff --git a/src/test/test_hs_pow.c b/src/test/test_hs_pow.c
index e2111478fc..877f022a79 100644
--- a/src/test/test_hs_pow.c
+++ b/src/test/test_hs_pow.c
@@ -382,7 +382,7 @@ test_hs_pow_vectors(void *arg)
sol_hex, 2 * sizeof solution.equix_solution),
OP_EQ, HS_POW_EQX_SOL_LEN);
- solution.seed_head = tor_ntohl(get_uint32(pow_state->seed_previous));
+ memcpy(solution.seed_head, pow_state->seed_previous, HS_POW_SEED_HEAD_LEN);
/* Try to encode 'solution' into a relay cell */
diff --git a/src/test/test_hs_pow_slow.c b/src/test/test_hs_pow_slow.c
index 716501dffd..0c83922646 100644
--- a/src/test/test_hs_pow_slow.c
+++ b/src/test/test_hs_pow_slow.c
@@ -26,16 +26,14 @@ testing_one_hs_pow_solution(const hs_pow_solution_t *ref_solution,
int retval = -1;
hs_pow_solution_t sol_buffer;
hs_pow_service_state_t *s = tor_malloc_zero(sizeof(hs_pow_service_state_t));
- uint32_t seed_head;
memcpy(s->seed_previous, seed, HS_POW_SEED_LEN);
- memcpy(&seed_head, seed, sizeof seed_head);
const unsigned num_variants = 10;
const unsigned num_attempts = 3;
for (unsigned variant = 0; variant < num_variants; variant++) {
- hs_pow_remove_seed_from_cache(seed_head);
+ hs_pow_remove_seed_from_cache(seed);
for (unsigned attempt = 0; attempt < num_attempts; attempt++) {
int expected = -1;
@@ -211,15 +209,16 @@ test_hs_pow_vectors(void *arg)
sizeof solution.equix_solution,
sol_hex, 2 * sizeof solution.equix_solution),
OP_EQ, HS_POW_EQX_SOL_LEN);
- solution.seed_head = tor_ntohl(get_uint32(params.seed));
+ memcpy(solution.seed_head, params.seed, HS_POW_SEED_HEAD_LEN);
memset(&output, 0xaa, sizeof output);
testing_enable_prefilled_rng(rng_bytes, HS_POW_NONCE_LEN);
tt_int_op(0, OP_EQ, hs_pow_solve(&params, &output));
testing_disable_prefilled_rng();
- tt_int_op(solution.seed_head, OP_EQ, output.seed_head);
- tt_mem_op(&solution.nonce, OP_EQ, &output.nonce,
+ tt_mem_op(solution.seed_head, OP_EQ, output.seed_head,
+ sizeof output.seed_head);
+ tt_mem_op(solution.nonce, OP_EQ, output.nonce,
sizeof output.nonce);
tt_mem_op(&solution.equix_solution, OP_EQ, &output.equix_solution,
sizeof output.equix_solution);