1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6
7 /**
8 * @file relay_handshake.h
9 * @brief Header for feature/relay/relay_handshake.c
10 **/
11
12 #ifndef TOR_CORE_OR_RELAY_HANDSHAKE_H
13 #define TOR_CORE_OR_RELAY_HANDSHAKE_H
14
15 #ifdef HAVE_MODULE_RELAY
16 struct ed25519_keypair_t;
17
18 int connection_or_send_certs_cell(or_connection_t *conn);
19 int connection_or_send_auth_challenge_cell(or_connection_t *conn);
20
21 var_cell_t *connection_or_compute_authenticate_cell_body(
22 or_connection_t *conn,
23 const int authtype,
24 crypto_pk_t *signing_key,
25 const struct ed25519_keypair_t *ed_signing_key,
26 int server);
27
28 int authchallenge_type_is_supported(uint16_t challenge_type);
29 int authchallenge_type_is_better(uint16_t challenge_type_a,
30 uint16_t challenge_type_b);
31
32 MOCK_DECL(int,connection_or_send_authenticate_cell,
33 (or_connection_t *conn, int type));
34
35 #ifdef TOR_UNIT_TESTS
36 extern int certs_cell_ed25519_disabled_for_testing;
37 #endif
38 #else /* !defined(HAVE_MODULE_RELAY) */
39
40 static inline int
connection_or_send_certs_cell(or_connection_t * conn)41 connection_or_send_certs_cell(or_connection_t *conn)
42 {
43 (void)conn;
44 tor_assert_nonfatal_unreached();
45 return -1;
46 }
47 static inline int
connection_or_send_auth_challenge_cell(or_connection_t * conn)48 connection_or_send_auth_challenge_cell(or_connection_t *conn)
49 {
50 (void)conn;
51 tor_assert_nonfatal_unreached();
52 return -1;
53 }
54
55 static inline var_cell_t *
connection_or_compute_authenticate_cell_body(or_connection_t * conn,const int authtype,crypto_pk_t * signing_key,const struct ed25519_keypair_t * ed_signing_key,int server)56 connection_or_compute_authenticate_cell_body(
57 or_connection_t *conn,
58 const int authtype,
59 crypto_pk_t *signing_key,
60 const struct ed25519_keypair_t *ed_signing_key,
61 int server)
62 {
63 (void)conn;
64 (void)authtype;
65 (void)signing_key;
66 (void)ed_signing_key;
67 (void)server;
68 tor_assert_nonfatal_unreached();
69 return NULL;
70 }
71
72 #define authchallenge_type_is_supported(t) (0)
73 #define authchallenge_type_is_better(a, b) (0)
74
75 static inline int
connection_or_send_authenticate_cell(or_connection_t * conn,int type)76 connection_or_send_authenticate_cell(or_connection_t *conn, int type)
77 {
78 (void)conn;
79 (void)type;
80 tor_assert_nonfatal_unreached();
81 return -1;
82 }
83
84 #ifdef TOR_UNIT_TESTS
85 extern int certs_cell_ed25519_disabled_for_testing;
86 #endif
87
88 #endif /* defined(HAVE_MODULE_RELAY) */
89
90 #endif /* !defined(TOR_CORE_OR_RELAY_HANDSHAKE_H) */
91