1. 29 Apr, 2019 10 commits
    • David Goulet's avatar
      prop289: Match the SENDME digest · bb473a80
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      bb473a80
    • David Goulet's avatar
      prop289: Keep track of the last seen cell digests · 93f9fbbd
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      93f9fbbd
    • David Goulet's avatar
      prop289: Support SENDME v1 cell parsing · 81706d84
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      81706d84
    • David Goulet's avatar
      prop289: Support sending SENDME version 1 · 023a70da
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      023a70da
    • David Goulet's avatar
      prop289: Add two consensus parameters · c38d46bf
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      c38d46bf
    • David Goulet's avatar
      sendme: Add helper functions for DATA cell packaging · 8e38791b
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      8e38791b
    • David Goulet's avatar
      sendme: Add helper functions for DATA cell delivery · 2d3c6009
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      2d3c6009
    • David Goulet's avatar
      sendme: Refactor SENDME cell processing · 9c42cc1e
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      9c42cc1e
    • David Goulet's avatar
      ed8593b9
    • David Goulet's avatar
      sendme: Move code to the new files sendme.{c|h} · e5806dce
      David Goulet authored
      
      
      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's avatarDavid Goulet <dgoulet@torproject.org>
      e5806dce