summaryrefslogtreecommitdiff
path: root/src/or/rendcommon.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-09-24 14:44:29 +0000
committerNick Mathewson <nickm@torproject.org>2008-09-24 14:44:29 +0000
commit8bc1536a9e83f68f7aeed34714a8b05deb2aabe9 (patch)
tree52bb1ed6f364e11eef201ed0224ffc46b70e39eb /src/or/rendcommon.c
parent982a22a1214f2394c9a8cd2099b749f3e780ab87 (diff)
downloadtor-8bc1536a9e83f68f7aeed34714a8b05deb2aabe9.tar.gz
tor-8bc1536a9e83f68f7aeed34714a8b05deb2aabe9.zip
Add patch 4 from Karsten for proposal 121, slightly modified. Karsten should definitely re-review the bits I changed.
svn:r16955
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r--src/or/rendcommon.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 49a21f63ae..343c43d7d6 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -1243,7 +1243,7 @@ rend_cache_store_v2_desc_as_dir(const char *desc)
*/
int
rend_cache_store_v2_desc_as_client(const char *desc,
- const char *descriptor_cookie)
+ const rend_data_t *rend_query)
{
/*XXXX this seems to have a bit of duplicate code with
* rend_cache_store_v2_desc_as_dir(). Fix that. */
@@ -1272,7 +1272,6 @@ rend_cache_store_v2_desc_as_client(const char *desc,
rend_cache_entry_t *e;
tor_assert(rend_cache);
tor_assert(desc);
- (void) descriptor_cookie; /* We don't use it, yet. */
/* Parse the descriptor. */
if (rend_parse_v2_service_descriptor(&parsed, desc_id, &intro_content,
&intro_size, &encoded_size,
@@ -1291,14 +1290,37 @@ rend_cache_store_v2_desc_as_client(const char *desc,
}
/* Decode/decrypt introduction points. */
if (intro_content) {
+ if (rend_query->auth_type != REND_NO_AUTH &&
+ rend_query->descriptor_cookie) {
+ char *ipos_decrypted;
+ size_t ipos_decrypted_size;
+ if (rend_decrypt_introduction_points(&ipos_decrypted,
+ &ipos_decrypted_size,
+ rend_query->descriptor_cookie,
+ intro_content,
+ intro_size) < 0) {
+ log_warn(LD_REND, "Failed to decrypt introduction points. We are "
+ "probably unable to parse the encoded introduction points.");
+ } else {
+ /* Replace encrypted with decrypted introduction points. */
+ log_info(LD_REND, "Successfully decrypted introduction points.");
+ tor_free(intro_content);
+ intro_content = ipos_decrypted;
+ intro_size = ipos_decrypted_size;
+ }
+ }
if (rend_parse_introduction_points(parsed, intro_content,
- intro_size) < 0) {
- log_warn(LD_PROTOCOL,"Couldn't decode/decrypt introduction points.");
- rend_service_descriptor_free(parsed);
+ intro_size) <= 0) {
+ log_warn(LD_REND, "Failed to parse introduction points. Either the "
+ "service has published a corrupt descriptor or you have "
+ "provided invalid authorization data.");
+ if (parsed)
+ rend_service_descriptor_free(parsed);
tor_free(intro_content);
return -2;
}
} else {
+ log_info(LD_REND, "Descriptor does not contain any introduction points.");
parsed->intro_nodes = smartlist_create();
}
/* We don't need the encoded/encrypted introduction points any longer. */
@@ -1426,3 +1448,12 @@ rend_cache_size(void)
return strmap_size(rend_cache);
}
+/** Allocate and return a new rend_data_t with the same
+ * contents as <b>query</b>. */
+rend_data_t *
+rend_data_dup(const rend_data_t *data)
+{
+ tor_assert(data);
+ return tor_memdup(data, sizeof(rend_data_t));
+}
+