13#define CRYPT_PATH_PRIVATE
22#include "core/crypto/relay_crypto_tor1.h"
25#include "core/or/or_circuit_st.h"
29#define CGO_AES_BITS 128
44 switch (crypto->kind) {
50 return crypto->c.cgo.last_tag;
52 tor_assert_unreached();
60 switch (crypto->kind) {
66 tor_assert_unreached();
76 switch (crypto->kind) {
80 const uint8_t *tag = NULL;
90 tor_assert_unreached();
100 switch (crypto->kind) {
104 const uint8_t *tag = NULL;
114 tor_assert_unreached();
123 switch (crypto->kind) {
167 if (thishop->
state != CPATH_STATE_OPEN) {
169 "Relay cell before first created cell? Closing.");
175 bool rec = relay_crypt_client_backward(&thishop->pvt_crypto, cell);
178 *layer_hint = thishop;
181 thishop = thishop->
next;
182 }
while (thishop != cpath && thishop->
state == CPATH_STATE_OPEN);
184 "Incoming cell at client not recognized. Closing.");
189 relay_crypt_relay_backward(crypto, cell);
195 bool rec = relay_crypt_relay_forward(crypto, cell);
208 switch (crypto->kind) {
213 const uint8_t *tag = NULL;
227 switch (crypto->kind) {
251 relay_crypt_client_originate(&thishop->pvt_crypto, cell);
252 thishop = thishop->
prev;
255 relay_crypt_client_forward(&thishop->pvt_crypto, cell);
256 thishop = thishop->
prev;
274 switch (crypto->kind) {
279 const uint8_t *tag = NULL;
290 memwipe(cell, 0,
sizeof(*cell));
302 switch (crypto->kind) {
304 tor1_crypt_clear(&crypto->c.tor1);
307 cgo_crypt_free(crypto->c.cgo.fwd);
308 cgo_crypt_free(crypto->c.cgo.back);
315 const uint8_t *key_material,
size_t key_data_len)
317 memset(pair, 0,
sizeof(*pair));
318 const int aes_bits = CGO_AES_BITS;
320 if (BUG(key_data_len != single_cgo_len * 2)) {
324 cgo_mode_t fwd_mode, back_mode;
326 fwd_mode = CGO_MODE_RELAY_FORWARD;
327 back_mode = CGO_MODE_RELAY_BACKWARD;
329 fwd_mode = CGO_MODE_CLIENT_FORWARD;
330 back_mode = CGO_MODE_CLIENT_BACKWARD;
334 key_material, single_cgo_len);
336 key_material + single_cgo_len, single_cgo_len);
361 const char *key_data,
size_t key_data_len)
366 crypto->kind = RCK_TOR1;
370 crypto->kind = RCK_TOR1;
374 crypto->kind = RCK_TOR1;
378 crypto->kind = RCK_CGO;
379 return cgo_pair_init(&crypto->c.cgo,
false,
380 (
const uint8_t *)key_data, key_data_len);
382 crypto->kind = RCK_CGO;
383 return cgo_pair_init(&crypto->c.cgo,
true,
384 (
const uint8_t *)key_data, key_data_len);
386 tor_assert_unreached();
414 switch (crypto->kind) {
Fixed-size cell structure.
origin_circuit_t * TO_ORIGIN_CIRCUIT(circuit_t *x)
or_circuit_t * TO_OR_CIRCUIT(circuit_t *x)
Header file for circuitlist.c.
#define CIRCUIT_IS_ORIGIN(c)
Header file for config.c.
Header file for crypt_path.c.
Headers for crypto_cipher.c.
void memwipe(void *mem, uint8_t byte, size_t sz)
Common functions for cryptographic routines.
#define log_fn(severity, domain, args,...)
Master header file for Tor-specific functionality.
#define SENDME_TAG_LEN_TOR1
#define SENDME_TAG_LEN_CGO
Origin circuit structure.
Header for relay_crypto.c.
@ RELAY_CRYPTO_ALG_TOR1_HSS
@ RELAY_CRYPTO_ALG_TOR1_HSC
@ RELAY_CRYPTO_ALG_CGO_RELAY
@ RELAY_CRYPTO_ALG_CGO_CLIENT
void cgo_crypt_relay_originate(cgo_crypt_t *cgo, cell_t *cell, const uint8_t **tag_out)
void cgo_crypt_client_forward(cgo_crypt_t *cgo, cell_t *cell)
void cgo_crypt_relay_backward(cgo_crypt_t *cgo, cell_t *cell)
size_t cgo_key_material_len(int aesbits)
void cgo_crypt_relay_forward(cgo_crypt_t *cgo, cell_t *cell, const uint8_t **recognized_tag_out)
cgo_crypt_t * cgo_crypt_new(cgo_mode_t mode, int aesbits, const uint8_t *keys, size_t keylen)
void cgo_crypt_client_originate(cgo_crypt_t *cgo, cell_t *cell, const uint8_t **tag_out)
void cgo_crypt_client_backward(cgo_crypt_t *cgo, cell_t *cell, const uint8_t **recognized_tag_out)
void tor1_crypt_client_forward(tor1_crypt_t *tor1, cell_t *cell)
void tor1_crypt_assert_ok(const tor1_crypt_t *crypto)
void tor1_crypt_relay_backward(tor1_crypt_t *tor1, cell_t *cell)
void tor1_crypt_relay_originate(tor1_crypt_t *tor1, cell_t *cell)
int tor1_crypt_init(tor1_crypt_t *crypto, const char *key_data, size_t key_data_len, int reverse, int is_hs_v3)
void tor1_crypt_client_originate(tor1_crypt_t *tor1, cell_t *cell)
bool tor1_crypt_client_backward(tor1_crypt_t *tor1, cell_t *cell)
size_t tor1_key_material_len(bool is_hs)
bool tor1_crypt_relay_forward(tor1_crypt_t *tor1, cell_t *cell)
Header file for sendme.c.
struct crypt_path_t * prev
struct crypt_path_t * next
uint8_t sendme_digest[DIGEST_LEN]
#define tor_fragile_assert()