blob: ed01bd6a7dc74dd40d8572c1ee6435350893d599 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*
* This contains the definition of the INTRODUCE1 and INTRODUCE_ACK cell for
* onion service version 3 and onward. The following format is specified in
* proposal 224 section 3.2.
*/
/* From cell_common.trunnel. */
extern struct trn_extension;
/* From ed25519_cert.trunnel. */
extern struct link_specifier;
const TRUNNEL_SHA1_LEN = 20;
const TRUNNEL_REND_COOKIE_LEN = 20;
/* Introduce ACK status code. */
const TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS = 0x0000;
const TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID = 0x0001;
const TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT = 0x0002;
/* Authentication key type. */
const TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY0 = 0x00;
const TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY1 = 0x01;
const TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519 = 0x02;
/* Onion key type. */
const TRUNNEL_HS_INTRO_ONION_KEY_TYPE_NTOR = 0x01;
/* INTRODUCE1 payload. See details in section 3.2.1. */
struct trn_cell_introduce1 {
/* Always zeroed. MUST be checked explicitly by the caller. */
u8 legacy_key_id[TRUNNEL_SHA1_LEN];
/* Authentication key material. */
u8 auth_key_type IN [TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY0,
TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_LEGACY1,
TRUNNEL_HS_INTRO_AUTH_KEY_TYPE_ED25519];
u16 auth_key_len;
u8 auth_key[auth_key_len];
/* Extension(s). Reserved fields. */
struct trn_extension extensions;
/* Variable length, up to the end of cell. */
u8 encrypted[];
};
/* INTRODUCE_ACK payload. See details in section 3.2.2. */
struct trn_cell_introduce_ack {
/* Status of introduction. */
u16 status;
/* Extension(s). Reserved fields. */
struct trn_extension extensions;
};
/* Encrypted section of the INTRODUCE1/INTRODUCE2 cell. */
struct trn_cell_introduce_encrypted {
/* Rendezvous cookie. */
u8 rend_cookie[TRUNNEL_REND_COOKIE_LEN];
/* Extension(s). Reserved fields. */
struct trn_extension extensions;
/* Onion key material. */
u8 onion_key_type IN [TRUNNEL_HS_INTRO_ONION_KEY_TYPE_NTOR];
u16 onion_key_len;
u8 onion_key[onion_key_len];
/* Link specifiers(s) */
u8 nspec;
struct link_specifier nspecs[nspec];
/* Optional padding. This might be empty or not. */
u8 pad[];
};
/*
* INTRODUCE1 cell (encrypted section) extensions.
*/
/* Cell extenstion type Congestion Control Request. */
const TRUNNEL_EXT_TYPE_CC_REQUEST = 0x01;
/* Cell extension type PoW. */
const TRUNNEL_EXT_TYPE_POW = 0x02;
/*
* PoW Solution Extension. Proposal 327.
*/
const TRUNNEL_POW_NONCE_LEN = 16;
const TRUNNEL_POW_SOLUTION_LEN = 16;
const TRUNNEL_POW_SEED_HEAD_LEN = 4;
/* Version 1 is based on Equi-X scheme. */
const TRUNNEL_POW_VERSION_EQUIX = 0x01;
struct trn_cell_extension_pow {
/* Type of PoW system used. */
u8 pow_version IN [0x01];
/* Nonce */
u8 pow_nonce[TRUNNEL_POW_NONCE_LEN];
/* Effort */
u32 pow_effort;
/* Identifiable prefix from the seed. */
u8 pow_seed[TRUNNEL_POW_SEED_HEAD_LEN];
/* Solution. */
u8 pow_solution[TRUNNEL_POW_SOLUTION_LEN];
};
|