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