hs: Add single-onion-service line to v3 descriptor

This field indicates if the service is a Single Onion Service if present in
the descriptor.

Closes #19642

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2016-11-08 13:22:42 -05:00
parent 053cf55cab
commit 34f14a35b6
4 changed files with 18 additions and 0 deletions

View File

@ -26,6 +26,7 @@
/* Constant string value for the encrypted part of the descriptor. */
#define str_create2_formats "create2-formats"
#define str_auth_required "authentication-required"
#define str_single_onion "single-onion-service"
#define str_intro_point "introduction-point"
#define str_ip_auth_key "auth-key"
#define str_ip_enc_key "enc-key"
@ -63,6 +64,7 @@ static token_rule_t hs_desc_v3_token_table[] = {
static token_rule_t hs_desc_encrypted_v3_token_table[] = {
T1_START(str_create2_formats, R3_CREATE2_FORMATS, CONCAT_ARGS, NO_OBJ),
T01(str_auth_required, R3_AUTHENTICATION_REQUIRED, ARGS, NO_OBJ),
T01(str_single_onion, R3_SINGLE_ONION_SERVICE, ARGS, NO_OBJ),
END_OF_TABLE
};
@ -692,6 +694,10 @@ encode_encrypted_data(const hs_descriptor_t *desc,
smartlist_add_asprintf(lines, "%s %s\n", str_auth_required, buf);
tor_free(buf);
}
if (desc->encrypted_data.single_onion_service) {
smartlist_add_asprintf(lines, "%s\n", str_single_onion);
}
}
/* Build the introduction point(s) section. */
@ -1613,6 +1619,13 @@ desc_decode_encrypted_v3(const hs_descriptor_t *desc,
goto err;
}
}
/* Is this service a single onion service? */
tok = find_opt_by_keyword(tokens, R3_SINGLE_ONION_SERVICE);
if (tok) {
desc_encrypted_out->single_onion_service = 1;
}
/* Initialize the descriptor's introduction point list before we start
* decoding. Having 0 intro point is valid. Then decode them all. */
desc_encrypted_out->intro_points = smartlist_new();

View File

@ -128,6 +128,9 @@ typedef struct hs_desc_encrypted_data_t {
* in order to contact the service. Contains NULL terminated strings. */
smartlist_t *auth_types;
/* Is this descriptor a single onion service? */
unsigned int single_onion_service : 1;
/* A list of intro points. Contains hs_desc_intro_point_t objects. */
smartlist_t *intro_points;
} hs_desc_encrypted_data_t;

View File

@ -158,6 +158,7 @@ typedef enum {
R3_SIGNATURE,
R3_CREATE2_FORMATS,
R3_AUTHENTICATION_REQUIRED,
R3_SINGLE_ONION_SERVICE,
R3_INTRODUCTION_POINT,
R3_INTRO_AUTH_KEY,
R3_INTRO_ENC_KEY,

View File

@ -102,6 +102,7 @@ helper_build_hs_desc(unsigned int no_ip)
/* Setup encrypted data section. */
desc->encrypted_data.create2_ntor = 1;
desc->encrypted_data.auth_types = smartlist_new();
desc->encrypted_data.single_onion_service = 1;
smartlist_add(desc->encrypted_data.auth_types, tor_strdup("ed25519"));
desc->encrypted_data.intro_points = smartlist_new();
if (!no_ip) {