aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_pow.c
AgeCommit message (Collapse)Author
2023-05-10hs_pow: Modify challenge format, include blinded HS idMicah Elizabeth Scott
This is a protocol breaking change that implements nickm's changes to prop 327 to add an algorithm personalization string and blinded HS id to the EquiX challenge string for our onion service client puzzle. This corresponds with the spec changes in torspec!130, and it fixes a proposed vulnerability documented in ticket tor#40789. Clients and services prior to this patch will no longer be compatible with the proposed "v1" proof-of-work protocol. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10hs_pow: leak fix, free the contents of pqueue entries in ↵Micah Elizabeth Scott
hs_pow_free_service_state Asan catches this pretty readily when ending a service gracefully while a DoS is in progress and the queue is full of items that haven't yet timed out. The module boundaries in hs_circuit are quite fuzzy here, but I'm trying to follow the vibe of the existing hs_pow code. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10hs_pow: Represent equix_solution as a byte arrayMicah Elizabeth Scott
This patch is intended to clarify the points at which we convert between the internal representation of an equix_solution and a portable but opaque byte array representation. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10hs_pow: Fix nonce cache entry leakMicah Elizabeth Scott
This leak was showing up in address sanitizer runs of test_hs_pow, but it will also happen during normal operation as seeds are rotated. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10hs_pow: Define seed_head as uint8_t[4] instead of uint32_tMicah Elizabeth Scott
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>
2023-05-10hs_pow: unswap byte order of seed_head fieldMicah Elizabeth Scott
In proposal 327, "POW_SEED is the first 4 bytes of the seed used". The proposal doesn't specifically mention the data type of this field, and the code in hs_pow so far treats it as an integer but semantically it's more like the first four bytes of an already-encoded little endian blob. This leads to a byte swap, since the type confusion takes place in a little-endian subsystem but the wire encoding of seed_head uses tor's default of big endian. This patch does not address the underlying type confusion, it's a minimal change that only swaps the byte order and updates unit tests accordingly. Further changes will clean up the data types. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10test_hs_pow: add test vectors for our hs_pow client puzzleMicah Elizabeth Scott
This adds test vectors for the overall client puzzle at the hs_pow and hs_cell layers. These are similar to the crypto/equix tests, but they also cover particulars of our hs_pow format like the conversion to byte arrays, the replay cache, the effort test, and the formatting of the equix challenge string. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>