aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-04-29 12:11:57 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-04-29 12:17:57 -0400
commit0f2ff267c5b509d697882989341d91b9fb4c249d (patch)
treefb4d3d2f44e5050703bd0fa15084080ece357e66 /src
parent0d8b9b56c5332b8f0205f460d0b23bb7f5620eff (diff)
downloadtor-0f2ff267c5b509d697882989341d91b9fb4c249d.tar.gz
tor-0f2ff267c5b509d697882989341d91b9fb4c249d.zip
sendme: Do not poke at crypto.sendme_digest directly
As per review from nickm, keep as much as we can the relay_crypto_t object opaque. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/crypto/relay_crypto.c8
-rw-r--r--src/core/crypto/relay_crypto.h1
-rw-r--r--src/core/or/sendme.c6
3 files changed, 12 insertions, 3 deletions
diff --git a/src/core/crypto/relay_crypto.c b/src/core/crypto/relay_crypto.c
index 5be45d6c7a..8931163161 100644
--- a/src/core/crypto/relay_crypto.c
+++ b/src/core/crypto/relay_crypto.c
@@ -91,6 +91,14 @@ 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)
diff --git a/src/core/crypto/relay_crypto.h b/src/core/crypto/relay_crypto.h
index 1009f1841b..bcc1531838 100644
--- a/src/core/crypto/relay_crypto.h
+++ b/src/core/crypto/relay_crypto.h
@@ -27,6 +27,7 @@ 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) */
diff --git a/src/core/or/sendme.c b/src/core/or/sendme.c
index ff58c1489d..6f451d38e6 100644
--- a/src/core/or/sendme.c
+++ b/src/core/or/sendme.c
@@ -388,10 +388,10 @@ sendme_circuit_consider_sending(circuit_t *circ, crypt_path_t *layer_hint)
log_debug(LD_CIRC,"Queuing circuit sendme.");
if (layer_hint) {
layer_hint->deliver_window += CIRCWINDOW_INCREMENT;
- digest = layer_hint->crypto.sendme_digest;
+ digest = relay_crypto_get_sendme_digest(&layer_hint->crypto);
} else {
circ->deliver_window += CIRCWINDOW_INCREMENT;
- digest = TO_OR_CIRCUIT(circ)->crypto.sendme_digest;
+ digest = relay_crypto_get_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto);
}
if (send_circuit_level_sendme(circ, layer_hint, digest) < 0) {
return; /* The circuit's closed, don't continue */
@@ -597,7 +597,7 @@ sendme_record_cell_digest(circuit_t *circ)
}
/* Add the digest to the last seen list in the circuit. */
- digest = TO_OR_CIRCUIT(circ)->crypto.sendme_digest;
+ digest = relay_crypto_get_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto);
if (circ->sendme_last_digests == NULL) {
circ->sendme_last_digests = smartlist_new();
}