13#define CRYPT_PATH_PRIVATE
22#include "core/crypto/relay_crypto_tor1.h"
25#include "core/or/or_circuit_st.h"
28#define CGO_AES_BITS 128
43 switch (crypto->kind) {
49 return crypto->c.cgo.last_tag;
51 tor_assert_unreached();
59 switch (crypto->kind) {
65 tor_assert_unreached();
75 switch (crypto->kind) {
79 const uint8_t *tag = NULL;
89 tor_assert_unreached();
99 switch (crypto->kind) {
103 const uint8_t *tag = NULL;
113 tor_assert_unreached();
122 switch (crypto->kind) {
166 if (thishop->
state != CPATH_STATE_OPEN) {
168 "Relay cell before first created cell? Closing.");
174 bool rec = relay_crypt_client_backward(&thishop->pvt_crypto, cell);
177 *layer_hint = thishop;
180 thishop = thishop->
next;
181 }
while (thishop != cpath && thishop->
state == CPATH_STATE_OPEN);
183 "Incoming cell at client not recognized. Closing.");
188 relay_crypt_relay_backward(crypto, cell);
194 bool rec = relay_crypt_relay_forward(crypto, cell);
207 switch (crypto->kind) {
212 const uint8_t *tag = NULL;
226 switch (crypto->kind) {
250 relay_crypt_client_originate(&thishop->pvt_crypto, cell);
251 thishop = thishop->
prev;
254 relay_crypt_client_forward(&thishop->pvt_crypto, cell);
255 thishop = thishop->
prev;
271 switch (crypto->kind) {
276 const uint8_t *tag = NULL;
292 switch (crypto->kind) {
294 tor1_crypt_clear(&crypto->c.tor1);
297 cgo_crypt_free(crypto->c.cgo.fwd);
298 cgo_crypt_free(crypto->c.cgo.back);
305 const uint8_t *key_material,
size_t key_data_len)
307 memset(pair, 0,
sizeof(*pair));
308 const int aes_bits = CGO_AES_BITS;
310 if (BUG(key_data_len != single_cgo_len * 2)) {
314 cgo_mode_t fwd_mode, back_mode;
316 fwd_mode = CGO_MODE_RELAY_FORWARD;
317 back_mode = CGO_MODE_RELAY_BACKWARD;
319 fwd_mode = CGO_MODE_CLIENT_FORWARD;
320 back_mode = CGO_MODE_CLIENT_BACKWARD;
324 key_material, single_cgo_len);
326 key_material + single_cgo_len, single_cgo_len);
351 const char *key_data,
size_t key_data_len)
356 crypto->kind = RCK_TOR1;
360 crypto->kind = RCK_TOR1;
364 crypto->kind = RCK_TOR1;
368 crypto->kind = RCK_CGO;
369 return cgo_pair_init(&crypto->c.cgo,
false,
370 (
const uint8_t *)key_data, key_data_len);
372 crypto->kind = RCK_CGO;
373 return cgo_pair_init(&crypto->c.cgo,
true,
374 (
const uint8_t *)key_data, key_data_len);
376 tor_assert_unreached();
404 switch (crypto->kind) {
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.
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]