]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs-v3: Function to re-parse unencrypted descriptor
authorDavid Goulet <dgoulet@torproject.org>
Fri, 31 May 2019 13:27:36 +0000 (09:27 -0400)
committerGeorge Kadianakis <desnacked@riseup.net>
Mon, 18 Nov 2019 17:06:43 +0000 (19:06 +0200)
We now keep descriptor that we can't decode due to missing client
authorization in the cache.

This new function is used when new client authorization are added and to tell
the client cache to retry decoding.

Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/feature/hs/hs_cache.c
src/feature/hs/hs_cache.h

index 59b05d8f0acd765545be34780a21b2b2d81496ee..49d5ade419f2de9910dc895629c9e1774cff6cf0 100644 (file)
@@ -942,6 +942,34 @@ hs_cache_client_intro_state_purge(void)
                     "cache purged.");
 }
 
+/* This is called when new client authorization was added to the global state.
+ * It attemps to decode the descriptor of the given service identity key.
+ *
+ * Return true if decoding was successful else false. */
+bool
+hs_cache_client_new_auth_parse(const ed25519_public_key_t *service_pk)
+{
+  bool ret = false;
+  hs_cache_client_descriptor_t *cached_desc = NULL;
+
+  tor_assert(service_pk);
+
+  cached_desc = lookup_v3_desc_as_client(service_pk->pubkey);
+  if (cached_desc == NULL || cached_desc->desc != NULL) {
+    /* No entry for that service or the descriptor is already decoded. */
+    goto end;
+  }
+
+  /* Attempt a decode. If we are successful, inform the caller. */
+  if (hs_client_decode_descriptor(cached_desc->encoded_desc, service_pk,
+                                  &cached_desc->desc) == HS_DESC_DECODE_OK) {
+    ret = true;
+  }
+
+ end:
+  return ret;
+}
+
 /**************** Generics *********************************/
 
 /** Do a round of OOM cleanup on all directory caches. Return the amount of
index e7729f2041362b57c02a549af5ae7b11b5c1d3bf..4fd9ac54459d63d28574fa629f6d30f68b889397 100644 (file)
@@ -99,6 +99,8 @@ const hs_cache_intro_state_t *hs_cache_client_intro_state_find(
 void hs_cache_client_intro_state_clean(time_t now);
 void hs_cache_client_intro_state_purge(void);
 
+bool hs_cache_client_new_auth_parse(const ed25519_public_key_t *service_pk);
+
 #ifdef HS_CACHE_PRIVATE
 #include "lib/crypt_ops/crypto_ed25519.h"