Commit b2c2cb92 authored by George Kadianakis's avatar George Kadianakis
Browse files

Merge branch 'tor-github/pr/986'

parents 4d461e20 562bcbcf
Loading
Loading
Loading
Loading

changes/ticket26288

0 → 100644
+6 −0
Original line number Diff line number Diff line
  o Major features (flow control):
    - Implement authenticated SENDMEs detailed in proposal 289. A SENDME cell
      now includes the digest of the last cell received so once the end point
      receives the SENDME, it can confirm the other side's knowledge of the
      previous cells that were sent. This behavior is controlled by two new
      consensus parameters, see proposal for more details. Fixes ticket 26288.
+5 −5
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ problem function-size /src/core/or/circuitbuild.c:circuit_extend() 147
problem function-size /src/core/or/circuitbuild.c:choose_good_exit_server_general() 206
problem include-count /src/core/or/circuitlist.c 54
problem function-size /src/core/or/circuitlist.c:HT_PROTOTYPE() 128
problem function-size /src/core/or/circuitlist.c:circuit_free_() 137
problem function-size /src/core/or/circuitlist.c:circuit_free_() 143
problem function-size /src/core/or/circuitlist.c:circuit_find_to_cannibalize() 102
problem function-size /src/core/or/circuitlist.c:circuit_about_to_free() 120
problem function-size /src/core/or/circuitlist.c:circuits_handle_oom() 117
@@ -102,8 +102,8 @@ problem function-size /src/core/or/circuituse.c:circuit_get_open_circ_or_launch(
problem function-size /src/core/or/circuituse.c:connection_ap_handshake_attach_circuit() 244
problem function-size /src/core/or/command.c:command_process_create_cell() 156
problem function-size /src/core/or/command.c:command_process_relay_cell() 132
problem file-size /src/core/or/connection_edge.c 4575
problem include-count /src/core/or/connection_edge.c 64
problem file-size /src/core/or/connection_edge.c 4595
problem include-count /src/core/or/connection_edge.c 65
problem function-size /src/core/or/connection_edge.c:connection_ap_expire_beginning() 117
problem function-size /src/core/or/connection_edge.c:connection_ap_handshake_rewrite() 192
problem function-size /src/core/or/connection_edge.c:connection_ap_handle_onion() 188
@@ -122,11 +122,11 @@ problem function-size /src/core/or/policies.c:policy_summarize() 107
problem function-size /src/core/or/protover.c:protover_all_supported() 117
problem file-size /src/core/or/relay.c 3173
problem function-size /src/core/or/relay.c:circuit_receive_relay_cell() 123
problem function-size /src/core/or/relay.c:relay_send_command_from_edge_() 101
problem function-size /src/core/or/relay.c:relay_send_command_from_edge_() 112
problem function-size /src/core/or/relay.c:connection_ap_process_end_not_open() 194
problem function-size /src/core/or/relay.c:connection_edge_process_relay_cell_not_open() 139
problem function-size /src/core/or/relay.c:connection_edge_process_relay_cell() 520
problem function-size /src/core/or/relay.c:connection_edge_package_raw_inbuf() 130
problem function-size /src/core/or/relay.c:connection_edge_package_raw_inbuf() 132
problem function-size /src/core/or/relay.c:circuit_resume_edge_reading_helper() 148
problem function-size /src/core/or/scheduler_kist.c:kist_scheduler_run() 171
problem function-size /src/core/or/scheduler_vanilla.c:vanilla_scheduler_run() 109
+30 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "core/crypto/hs_ntor.h" // for HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN
#include "core/or/relay.h"
#include "core/crypto/relay_crypto.h"
#include "core/or/sendme.h"

#include "core/or/cell_st.h"
#include "core/or/or_circuit_st.h"
@@ -90,6 +91,23 @@ relay_crypt_one_payload(crypto_cipher_t *cipher, uint8_t *in)
  crypto_cipher_crypt_inplace(cipher, (char*) in, CELL_PAYLOAD_SIZE);
}

/** Return the sendme_digest within the <b>crypto</b> object. */
uint8_t *
relay_crypto_get_sendme_digest(relay_crypto_t *crypto)
{
  tor_assert(crypto);
  return crypto->sendme_digest;
}

/** Record the b_digest from <b>crypto</b> and put it in the sendme_digest. */
void
relay_crypto_record_sendme_digest(relay_crypto_t *crypto)
{
  tor_assert(crypto);
  crypto_digest_get_digest(crypto->b_digest, (char *) crypto->sendme_digest,
                           sizeof(crypto->sendme_digest));
}

/** Do the appropriate en/decryptions for <b>cell</b> arriving on
 * <b>circ</b> in direction <b>cell_direction</b>.
 *
@@ -142,6 +160,11 @@ relay_decrypt_cell(circuit_t *circ, cell_t *cell,
          if (relay_digest_matches(thishop->crypto.b_digest, cell)) {
            *recognized = 1;
            *layer_hint = thishop;
            /* This cell is for us. Keep a record of this cell because we will
             * use it in the next SENDME cell. */
            if (sendme_circuit_cell_is_next(thishop->deliver_window)) {
              sendme_circuit_record_inbound_cell(thishop);
            }
            return 0;
          }
        }
@@ -212,6 +235,13 @@ relay_encrypt_cell_inbound(cell_t *cell,
                           or_circuit_t *or_circ)
{
  relay_set_digest(or_circ->crypto.b_digest, cell);

  /* We are about to send this cell outbound on the circuit. Keep a record of
   * this cell if we are expecting that the next cell is a SENDME. */
  if (sendme_circuit_cell_is_next(TO_CIRCUIT(or_circ)->package_window)) {
    sendme_circuit_record_outbound_cell(or_circ);
  }

  /* encrypt one layer */
  relay_crypt_one_payload(or_circ->crypto.b_crypto, cell->payload);
}
+3 −0
Original line number Diff line number Diff line
@@ -27,5 +27,8 @@ void relay_crypto_clear(relay_crypto_t *crypto);

void relay_crypto_assert_ok(const relay_crypto_t *crypto);

uint8_t *relay_crypto_get_sendme_digest(relay_crypto_t *crypto);
void relay_crypto_record_sendme_digest(relay_crypto_t *crypto);

#endif /* !defined(TOR_RELAY_CRYPTO_H) */
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ LIBTOR_APP_A_SOURCES = \
	src/core/or/scheduler.c			\
	src/core/or/scheduler_kist.c		\
	src/core/or/scheduler_vanilla.c		\
	src/core/or/sendme.c			\
	src/core/or/status.c			\
	src/core/or/versions.c			\
	src/core/proto/proto_cell.c		\
@@ -274,6 +275,7 @@ noinst_HEADERS += \
	src/core/or/relay.h				\
	src/core/or/relay_crypto_st.h			\
	src/core/or/scheduler.h				\
	src/core/or/sendme.h				\
	src/core/or/server_port_cfg_st.h		\
	src/core/or/socks_request_st.h			\
	src/core/or/status.h				\
Loading