aboutsummaryrefslogtreecommitdiff
path: root/src/core/crypto
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-03-07 12:30:13 -0500
committerDavid Goulet <dgoulet@torproject.org>2019-04-29 12:17:57 -0400
commit77d560af64226eaa0fde157d7a6607791975a7a9 (patch)
tree3c9b521535aa4cc9a4c7414b3deacc481fc7b878 /src/core/crypto
parent4efe9d653aa1d375d77d6dca83ca63787d6599d7 (diff)
downloadtor-77d560af64226eaa0fde157d7a6607791975a7a9.tar.gz
tor-77d560af64226eaa0fde157d7a6607791975a7a9.zip
prop289: Keep the digest bytes, not the object
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>
Diffstat (limited to 'src/core/crypto')
-rw-r--r--src/core/crypto/relay_crypto.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/core/crypto/relay_crypto.c b/src/core/crypto/relay_crypto.c
index d4116d47ab..94e9060651 100644
--- a/src/core/crypto/relay_crypto.c
+++ b/src/core/crypto/relay_crypto.c
@@ -143,12 +143,9 @@ relay_decrypt_cell(circuit_t *circ, cell_t *cell,
*recognized = 1;
*layer_hint = thishop;
/* Keep current digest of this cell for the possible SENDME. */
- if (thishop->crypto.sendme_digest) {
- crypto_digest_free(thishop->crypto.sendme_digest);
- }
- thishop->crypto.sendme_digest =
- crypto_digest_dup(thishop->crypto.b_digest);
-
+ crypto_digest_get_digest(thishop->crypto.b_digest,
+ (char *) thishop->crypto.sendme_digest,
+ sizeof(thishop->crypto.sendme_digest));
return 0;
}
}
@@ -220,10 +217,9 @@ relay_encrypt_cell_inbound(cell_t *cell,
{
relay_set_digest(or_circ->crypto.b_digest, cell);
/* Keep a record of this cell, we might use it for validating the SENDME. */
- if (or_circ->crypto.sendme_digest) {
- crypto_digest_free(or_circ->crypto.sendme_digest);
- }
- or_circ->crypto.sendme_digest = crypto_digest_dup(or_circ->crypto.b_digest);
+ crypto_digest_get_digest(or_circ->crypto.b_digest,
+ (char *) or_circ->crypto.sendme_digest,
+ sizeof(or_circ->crypto.sendme_digest));
/* encrypt one layer */
relay_crypt_one_payload(or_circ->crypto.b_crypto, cell->payload);
}
@@ -241,7 +237,6 @@ relay_crypto_clear(relay_crypto_t *crypto)
crypto_cipher_free(crypto->b_crypto);
crypto_digest_free(crypto->f_digest);
crypto_digest_free(crypto->b_digest);
- crypto_digest_free(crypto->sendme_digest);
}
/** Initialize <b>crypto</b> from the key material in key_data.