crypto_cipher_crypt_inplace(cipher, (char*) in, CELL_PAYLOAD_SIZE);
}
-/** Return the sendme_digest within the <b>crypto</b> object. */
+/** Return the sendme_digest within the <b>crypto</b> object.
+ *
+ * Before calling this function, you must call relay_crypto_save_sendme_digest.
+ */
uint8_t *
relay_crypto_get_sendme_digest(relay_crypto_t *crypto)
{
return crypto->sendme_digest;
}
-/** Record the cell digest, indicated by is_foward_digest or not, as the
- * SENDME cell digest. */
+/** Save the cell digest, indicated by is_foward_digest or not, as the
+ * SENDME cell digest inside this relay_crypto_t.
+ *
+ * This function must be called before relay_crypto_get_sendme_digest
+ * will work correctly.
+ */
void
-relay_crypto_record_sendme_digest(relay_crypto_t *crypto,
- bool is_foward_digest)
+tor1_save_sendme_digest(relay_crypto_t *crypto,
+ bool is_foward_digest)
{
struct crypto_digest_t *digest;
cpath_set_cell_forward_digest(layer_hint, cell);
/* Record cell digest as the SENDME digest if need be. */
- sendme_record_sending_cell_digest(TO_CIRCUIT(circ), layer_hint);
+ sendme_save_sending_cell_digest(TO_CIRCUIT(circ), layer_hint);
thishop = layer_hint;
/* moving from farthest to nearest hop */
tor1_set_digest_v0(or_circ->crypto.b_digest, cell);
/* Record cell digest as the SENDME digest if need be. */
- sendme_record_sending_cell_digest(TO_CIRCUIT(or_circ), NULL);
+ sendme_save_sending_cell_digest(TO_CIRCUIT(or_circ), NULL);
/* encrypt one layer */
tor1_crypt_one_payload(or_circ->crypto.b_crypto, cell->payload);
uint8_t *relay_crypto_get_sendme_digest(relay_crypto_t *crypto);
-void relay_crypto_record_sendme_digest(relay_crypto_t *crypto,
- bool is_foward_digest);
+void tor1_save_sendme_digest(relay_crypto_t *crypto,
+ bool is_foward_digest);
void
tor1_crypt_one_payload(crypto_cipher_t *cipher, uint8_t *in);
return relay_crypto_get_sendme_digest(&cpath->pvt_crypto);
}
-/** Record the cell digest, indicated by is_foward_digest or not, as the
- * SENDME cell digest. */
+/** Save the cell digest, indicated by is_foward_digest or not, as the
+ * SENDME cell digest inside the cpath's relay_crypto_t.
+ */
void
-cpath_sendme_record_cell_digest(crypt_path_t *cpath, bool is_foward_digest)
+cpath_sendme_save_cell_digest(crypt_path_t *cpath, bool is_foward_digest)
{
tor_assert(cpath);
- relay_crypto_record_sendme_digest(&cpath->pvt_crypto, is_foward_digest);
+ tor1_save_sendme_digest(&cpath->pvt_crypto, is_foward_digest);
}
/************ other cpath functions ***************************/
struct crypto_digest_t *
cpath_get_incoming_digest(const crypt_path_t *cpath);
-void cpath_sendme_record_cell_digest(crypt_path_t *cpath,
+void cpath_sendme_save_cell_digest(crypt_path_t *cpath,
bool is_foward_digest);
void
/* Recognized cell, the cell digest has been updated, we'll record it for
* the SENDME if need be. */
- sendme_record_received_cell_digest(circ, layer_hint);
+ sendme_save_received_cell_digest(circ, layer_hint);
relay_msg_t msg_buf;
if (relay_msg_decode_cell_in_place(format, cell, &msg_buf) < 0) {
record_cell_digest_on_circ(circ, sendme_digest);
}
-/* Called once we decrypted a cell and recognized it. Record the cell digest
- * as the next sendme digest only if the next cell we'll send on the circuit
+/* Called once we decrypted a cell and recognized it. Save the cell digest
+ * as the next sendme digest in the cpath's relay_crypto_t,
+ * only if the next cell we'll send on the circuit
* is expected to be a SENDME. */
void
-sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath)
+sendme_save_received_cell_digest(circuit_t *circ, crypt_path_t *cpath)
{
tor_assert(circ);
if (cpath) {
/* Record incoming digest. */
- cpath_sendme_record_cell_digest(cpath, false);
+ cpath_sendme_save_cell_digest(cpath, false);
} else {
/* Record forward digest. */
- relay_crypto_record_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, true);
+ tor1_save_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, true);
}
}
-/* Called once we encrypted a cell. Record the cell digest as the next sendme
- * digest only if the next cell we expect to receive is a SENDME so we can
- * match the digests. */
+/* Called once we encrypted a cell. Save the cell digest as the next sendme
+ * as the next sendme digest in the cpath's relay_crypto_t
+ * only if the we expect to receive a SENDME matching this cell's digest.
+ */
void
-sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath)
+sendme_save_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath)
{
tor_assert(circ);
if (cpath) {
/* Record the forward digest. */
- cpath_sendme_record_cell_digest(cpath, true);
+ cpath_sendme_save_cell_digest(cpath, true);
} else {
/* Record the incoming digest. */
- relay_crypto_record_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, false);
+ tor1_save_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, false);
}
end:
/* Record cell digest on circuit. */
void sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath);
/* Record cell digest as the SENDME digest. */
-void sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
-void sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
+void sendme_save_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
+void sendme_save_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
/* Private section starts. */
#ifdef SENDME_PRIVATE