9 #ifndef TOR_HS_DESCRIPTOR_H 10 #define TOR_HS_DESCRIPTOR_H 16 #include "container.h" 18 #include "crypto_ed25519.h" 19 #include "ed25519_cert.h" 26 #define HS_DESC_SUPPORTED_FORMAT_VERSION_MIN 3 28 #define HS_DESC_SUPPORTED_FORMAT_VERSION_MAX 3 32 #define HS_DESC_DEFAULT_LIFETIME (3 * 60 * 60) 35 #define HS_DESC_MAX_LIFETIME (12 * 60 * 60) 41 #define HS_DESC_CERT_LIFETIME (54 * 60 * 60) 43 #define HS_DESC_ENCRYPTED_SALT_LEN 16 48 #define HS_DESC_ENCRYPTED_SECRET_INPUT_LEN \ 49 ED25519_PUBKEY_LEN + DIGEST256_LEN + sizeof(uint64_t) 52 #define HS_DESC_ENCRYPTED_KDF_OUTPUT_LEN \ 53 CIPHER256_KEY_LEN + CIPHER_IV_LEN + DIGEST256_LEN 56 #define HS_DESC_SUPERENC_PLAINTEXT_PAD_MULTIPLE 10000 58 #define HS_DESC_MAX_LEN 50000 63 #define HS_DESC_ENCRYPTED_KEY_LEN CIPHER256_KEY_LEN 64 #define HS_DESC_ENCRYPTED_BIT_SIZE (HS_DESC_ENCRYPTED_KEY_LEN * 8) 68 HS_DESC_AUTH_ED25519 = 1
69 } hs_desc_auth_type_t;
85 uint8_t ed25519_id[ED25519_PUBKEY_LEN];
130 unsigned int cross_certified : 1;
138 unsigned int create2_ntor : 1;
145 unsigned int single_onion_service : 1;
158 uint32_t lifetime_sec;
175 uint64_t revision_counter;
178 uint8_t *superencrypted_blob;
181 size_t superencrypted_blob_size;
201 hs_desc_is_supported_version(uint32_t version)
203 if (version < HS_DESC_SUPPORTED_FORMAT_VERSION_MIN ||
204 version > HS_DESC_SUPPORTED_FORMAT_VERSION_MAX) {
213 #define hs_descriptor_free(desc) \ 214 FREE_AND_NULL(hs_descriptor_t, hs_descriptor_free_, (desc)) 216 #define hs_desc_plaintext_data_free(desc) \ 217 FREE_AND_NULL(hs_desc_plaintext_data_t, hs_desc_plaintext_data_free_, (desc)) 219 #define hs_desc_encrypted_data_free(desc) \ 220 FREE_AND_NULL(hs_desc_encrypted_data_t, hs_desc_encrypted_data_free_, (desc)) 223 #define hs_desc_link_specifier_free(ls) \ 224 FREE_AND_NULL(hs_desc_link_specifier_t, hs_desc_link_specifier_free_, (ls)) 233 char **encoded_out));
235 int hs_desc_decode_descriptor(
const char *encoded,
236 const uint8_t *subcredential,
238 int hs_desc_decode_plaintext(
const char *encoded,
248 #define hs_desc_intro_point_free(ip) \ 249 FREE_AND_NULL(hs_desc_intro_point_t, hs_desc_intro_point_free_, (ip)) 254 #ifdef HS_DESCRIPTOR_PRIVATE 257 STATIC
char *encode_link_specifiers(
const smartlist_t *specs);
258 STATIC
size_t build_plaintext_padding(
const char *plaintext,
259 size_t plaintext_len,
260 uint8_t **padded_out);
262 STATIC
smartlist_t *decode_link_specifiers(
const char *encoded);
266 STATIC
int encrypted_data_length_is_valid(
size_t len);
267 STATIC
int cert_is_valid(
tor_cert_t *cert, uint8_t type,
268 const char *log_obj_type);
269 STATIC
int desc_sig_is_valid(
const char *b64_sig,
271 const char *encoded_desc,
size_t encoded_len);
272 STATIC
size_t decode_superencrypted(
const char *message,
size_t message_len,
273 uint8_t **encrypted_out);
277 const uint8_t *encrypted_blob,
278 size_t encrypted_blob_size,
279 int is_superencrypted_layer,
280 char **decrypted_out));
Definition: hs_descriptor.h:73
Definition: crypto_ed25519.h:39
Definition: hs_descriptor.h:152
#define DIGEST_LEN
Definition: crypto_digest.h:22
Definition: crypto_ed25519.h:23
Definition: hs_descriptor.h:90
Definition: hs_descriptor.h:185
Definition: ed25519_cert.h:48
MOCK_DECL(int, router_have_minimum_dir_info,(void))
Definition: container.h:18
Definition: hs_descriptor.h:135
Master header file for Tor-specific functionality.
#define DIGEST256_LEN
Definition: crypto_digest.h:25
Definition: crypto_curve25519.h:24
Definition: crypto_rsa.c:41