]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a BASE32_DIGEST_LEN define
authorDavid Goulet <dgoulet@torproject.org>
Tue, 19 Sep 2017 16:33:04 +0000 (12:33 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 19 Sep 2017 16:33:04 +0000 (12:33 -0400)
Use this value instead of hardcoded values of 32 everywhere. This also
addresses the use of REND_DESC_ID_V2_LEN_BASE32 in
hs_lookup_last_hid_serv_request() for the HSDir encoded identity digest length
which is accurate but semantically wrong.

Fixes #23305.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/common/crypto.h
src/or/hs_common.c
src/or/or.h

index 6f5e13a8dec6d5f8ab32c1f9276b98f93e398b6a..f9aeeee2c07cd6331b8305d5b7d76c10c6e95ec8 100644 (file)
@@ -73,6 +73,9 @@
 /** Length of our DH keys. */
 #define DH_BYTES (1024/8)
 
+/** Length of a sha1 message digest when encoded in base32 with trailing =
+ * signs removed. */
+#define BASE32_DIGEST_LEN 32
 /** Length of a sha1 message digest when encoded in base64 with trailing =
  * signs removed. */
 #define BASE64_DIGEST_LEN 27
index 2cdfe57cd6fc45302f6fe037e5f8668e39d8827d..42c15c80d3383f984055038010f509d5d87635e3 100644 (file)
@@ -1453,7 +1453,7 @@ hs_lookup_last_hid_serv_request(routerstatus_t *hs_dir,
                                 const char *req_key_str,
                                 time_t now, int set)
 {
-  char hsdir_id_base32[REND_DESC_ID_V2_LEN_BASE32 + 1];
+  char hsdir_id_base32[BASE32_DIGEST_LEN + 1];
   char *hsdir_desc_comb_id = NULL;
   time_t *last_request_ptr;
   strmap_t *last_hid_serv_requests = get_last_hid_serv_requests();
index 4fc0e788a041ad144c4a1789b0db64d19fea57dc..c23054c3b79b13dd66dae05cc349cf5b374bdeea 100644 (file)
@@ -747,15 +747,15 @@ typedef enum {
 #define REND_NUMBER_OF_CONSECUTIVE_REPLICAS 3
 
 /** Length of v2 descriptor ID (32 base32 chars = 160 bits). */
-#define REND_DESC_ID_V2_LEN_BASE32 32
+#define REND_DESC_ID_V2_LEN_BASE32 BASE32_DIGEST_LEN
 
 /** Length of the base32-encoded secret ID part of versioned hidden service
  * descriptors. */
-#define REND_SECRET_ID_PART_LEN_BASE32 32
+#define REND_SECRET_ID_PART_LEN_BASE32 BASE32_DIGEST_LEN
 
 /** Length of the base32-encoded hash of an introduction point's
  * identity key. */
-#define REND_INTRO_POINT_ID_LEN_BASE32 32
+#define REND_INTRO_POINT_ID_LEN_BASE32 BASE32_DIGEST_LEN
 
 /** Length of the descriptor cookie that is used for client authorization
  * to hidden services. */