summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-04-29sendme: Better handle the random paddingDavid Goulet
We add random padding to every cell if there is room. This commit not only fixes how we compute that random padding length/offset but also improves its safety with helper functions and a unit test. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Keep cell digest only if a SENDME is nextDavid Goulet
This way, we reduce the load by only hashing when we absolutely must. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Add helper to note the cell digestDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Helper to know if next cell is a SENDMEDavid Goulet
We'll use it this in order to know when to hash the cell for the SENDME instead of doing it at every cell. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Add documentation for the circuit FIFO listDavid Goulet
Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Skip the first 4 unused bytes in a cellDavid Goulet
When adding random to a cell, skip the first 4 bytes and leave them zeroed. It has been very useful in the past for us to keep bytes like this. Some code trickery was added to make sure we have enough room for this 4 bytes offset when adding random. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Keep the digest bytes, not the objectDavid Goulet
The digest object is as large as the entire internal digest object's state, which is often much larger than the actual set of bytes you're transmitting. This commit makes it that we keep the digest itself which is 20 bytes. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Move digest matching in its own functionDavid Goulet
No behavior change but code had to be refactored a bit. Also, the tor_memcmp() was changed to tor_memneq(). Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Rename packaged functions with better nameDavid Goulet
The circuit and stream level functions that update the package window have been renamed to have a "_note_" in them to make their purpose more clear. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Move SENDME cell processing in a separate functionDavid Goulet
No behavior change. Only moving code and fixing part of it in order to use the parameters passed as pointers. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Use a 20 bytes digest instead of 4David Goulet
To achieve such, this commit also changes the trunnel declaration to use a union instead of a seperate object for the v1 data. A constant is added for the digest length so we can use it within the SENDME code giving us a single reference. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29tests: Implement unit tests for SENDME v1David Goulet
Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Add random bytes to the unused portion of the cellDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Remember the last cell digest for v1 SENDMEsDavid Goulet
In order to do so, depending on where the cell is going, we'll keep the last cell digest that is either received inbound or sent outbound. Then it can be used for validation. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Match the SENDME digestDavid Goulet
Now that we keep the last seen cell digests on the Exit side on the circuit object, use that to match the SENDME v1 transforming this whole process into a real authenticated SENDME mechanism. Part of #26841 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Keep track of the last seen cell digestsDavid Goulet
This makes tor remember the last seen digest of a cell if that cell is the last one before a SENDME on the Exit side. Closes #26839 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Support SENDME v1 cell parsingDavid Goulet
This commit makes tor able to parse and handle a SENDME version 1. It will look at the consensus parameter "sendme_accept_min_version" to know what is the minimum version it should look at. IMPORTANT: At this commit, the validation of the cell is not fully implemented. For this, we need #26839 to be completed that is to match the SENDME digest with the last cell digest. Closes #26841 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Support sending SENDME version 1David Goulet
This code will obey the consensus parameter "sendme_emit_min_version" to know which SENDME version it should send. For now, the default is 0 and the parameter is not yet used in the consensus. This commit adds the support to send version 1 SENDMEs but aren't sent on the wire at this commit. Closes #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Add SENDME trunnel declarationDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Add two consensus parametersDavid Goulet
In order to be able to deploy the authenticated SENDMEs, these two consensus parameters are needed to control the minimum version that we can emit and accept. See section 4 in prop289 for more details. Note that at this commit, the functions that return the values aren't used so compilation fails if warnings are set to errors. Closes #26842 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Always close stream if deliver window is negativeDavid Goulet
Previously, we would only close the stream when our deliver window was negative at the circuit-level but _not_ at the stream-level when receiving a DATA cell. This commit adds an helper function connection_edge_end_close() which sends an END and then mark the stream for close for a given reason. That function is now used both in case the deliver window goes below zero for both circuit and stream level. Part of #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Add helper functions for DATA cell packagingDavid Goulet
When we are about to send a DATA cell, we have to decrement the package window for both the circuit and stream level. This commit adds helper functions to handle the package window decrement. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Add helper functions for DATA cell deliveryDavid Goulet
When we get a relay DATA cell delivered, we have to decrement the deliver window on both the circuit and stream level. This commit adds helper functions to handle the deliver window decrement. Part of #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Refactor SENDME cell processingDavid Goulet
This is a bit of a complicated commit. It moves code but also refactors part of it. No behavior change, the idea is to split things up so we can better handle and understand how SENDME cells are processed where ultimately it will be easier to handle authenticated SENDMEs (prop289) using the intermediate functions added in this commit. The entry point for the cell arriving at the edge (Client or Exit), is connection_edge_process_relay_cell() for which we look if it is a circuit or stream level SENDME. This commit refactors that part where two new functions are introduced to process each of the SENDME types. The sendme_process_circuit_level() has basically two code paths. If we are a Client (the circuit is origin) or we are an Exit. Depending on which, the package window is updated accordingly. Then finally, we resume the reading on every edge streams on the circuit. The sendme_process_stream_level() applies on the edge connection which will update the package window if needed and then will try to empty the inbuf if need be because we can now deliver more cells. Again, no behavior change but in order to split that code properly into their own functions and outside the relay.c file, code modification was needed. Part of #26840. Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Modernize and cleanup old moved codeDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Move code to the new files sendme.{c|h}David Goulet
Take apart the SENDME cell specific code and put it in sendme.{c|h}. This is part of prop289 that implements authenticated SENDMEs. Creating those new files allow for the already huge relay.c to not grow in LOC and makes it easier to handle and test the SENDME cells in an isolated way. This commit only moves code. No behavior change. Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29Merge branch 'maint-0.4.0'Nick Mathewson
2019-04-29Merge remote-tracking branch 'tor-github/pr/974' into maint-0.4.0Nick Mathewson
2019-04-25Merge remote-tracking branch 'tor-github/pr/889'Nick Mathewson
2019-04-25Merge remote-tracking branch 'tor-github/pr/922'Nick Mathewson
2019-04-25Merge branch 'maint-0.4.0'George Kadianakis
2019-04-25Merge branch 'tor-github/pr/960' into maint-0.4.0George Kadianakis
2019-04-25Merge branch 'tor-github/pr/953'George Kadianakis
2019-04-24Merge remote-tracking branch 'tor-github/pr/942'Nick Mathewson
2019-04-24Merge remote-tracking branch 'tor-github/pr/964'Nick Mathewson
2019-04-24Allow do_resolve() to be longer.Nick Mathewson
2019-04-24Merge branch 'tor-github/pr/951'David Goulet
2019-04-24Merge branch 'tor-github/pr/943'David Goulet
2019-04-24Merge branch 'tor-github/pr/955'David Goulet
2019-04-24Merge branch 'tor-github/pr/939'David Goulet
2019-04-24Merge branch 'tor-github/pr/930'David Goulet
2019-04-23Merge remote-tracking branch 'tor-github/pr/944'Nick Mathewson
2019-04-23Rename outvar to follow _out convention.Nick Mathewson
2019-04-23Merge remote-tracking branch 'tor-github/pr/935'Nick Mathewson
2019-04-23Merge remote-tracking branch 'tor-github/pr/971'Nick Mathewson
2019-04-23Merge branch 'ticket30051_take2_squashed'Nick Mathewson
2019-04-23Add changes filerl1987
2019-04-23Call practracker from pre-push and pre-commit hooksrl1987
2019-04-23Merge remote-tracking branch 'tor-github/pr/962'Nick Mathewson
2019-04-23Stop looking for scripts in the build directory during "make shellcheck"teor
Fixes bug 30263; bugfix on 0.4.0.1-alpha.