summaryrefslogtreecommitdiff
path: root/src/or/rendcache.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2016-05-31 14:51:30 -0400
committerDavid Goulet <dgoulet@torproject.org>2016-11-04 10:29:26 -0400
commit8293356ad993e06c66e6b56534be91fb912c9b5a (patch)
treeb7d5154e060674365df36be054b6112364f66432 /src/or/rendcache.c
parent8fe410e875343a4c134ddbe0db6da3d38865deee (diff)
downloadtor-8293356ad993e06c66e6b56534be91fb912c9b5a.tar.gz
tor-8293356ad993e06c66e6b56534be91fb912c9b5a.zip
hs: Refactor rend_data_t for multi version support
In order to implement proposal 224, we need the data structure rend_data_t to be able to accomodate versionning that is the current version of hidden service (2) and the new version (3) and future version. For that, we implement a series of accessors and a downcast function to get the v2 data structure. rend_data_t becomes a top level generic place holder. The entire rend_data_t API has been moved to hs_common.{c|h} in order to seperate code that is shared from between HS versions and unshared code (in rendcommon.c). Closes #19024 Signed-off-by: David Goulet <dgoulet@torproject.org> Signed-off-by: George Kadianakis <desnacked@riseup.net>
Diffstat (limited to 'src/or/rendcache.c')
-rw-r--r--src/or/rendcache.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index e61a96b677..709aaffdee 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -849,6 +849,8 @@ rend_cache_store_v2_desc_as_client(const char *desc,
char want_desc_id[DIGEST_LEN];
rend_cache_entry_t *e;
int retval = -1;
+ rend_data_v2_t *rend_data = TO_REND_DATA_V2(rend_query);
+
tor_assert(rend_cache);
tor_assert(desc);
tor_assert(desc_id_base32);
@@ -874,11 +876,11 @@ rend_cache_store_v2_desc_as_client(const char *desc,
log_warn(LD_REND, "Couldn't compute service ID.");
goto err;
}
- if (rend_query->onion_address[0] != '\0' &&
- strcmp(rend_query->onion_address, service_id)) {
+ if (rend_data->onion_address[0] != '\0' &&
+ strcmp(rend_data->onion_address, service_id)) {
log_warn(LD_REND, "Received service descriptor for service ID %s; "
"expected descriptor for service ID %s.",
- service_id, safe_str(rend_query->onion_address));
+ service_id, safe_str(rend_data->onion_address));
goto err;
}
if (tor_memneq(desc_id, want_desc_id, DIGEST_LEN)) {
@@ -890,14 +892,14 @@ rend_cache_store_v2_desc_as_client(const char *desc,
/* Decode/decrypt introduction points. */
if (intro_content && intro_size > 0) {
int n_intro_points;
- if (rend_query->auth_type != REND_NO_AUTH &&
- !tor_mem_is_zero(rend_query->descriptor_cookie,
- sizeof(rend_query->descriptor_cookie))) {
+ if (rend_data->auth_type != REND_NO_AUTH &&
+ !tor_mem_is_zero(rend_data->descriptor_cookie,
+ sizeof(rend_data->descriptor_cookie))) {
char *ipos_decrypted = NULL;
size_t ipos_decrypted_size;
if (rend_decrypt_introduction_points(&ipos_decrypted,
&ipos_decrypted_size,
- rend_query->descriptor_cookie,
+ rend_data->descriptor_cookie,
intro_content,
intro_size) < 0) {
log_warn(LD_REND, "Failed to decrypt introduction points. We are "