[tor-commits] [tor] branch main updated: Add more test-vectors for key blinding.

gitolite role git at cupani.torproject.org
Thu Jan 19 17:55:51 UTC 2023


This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

The following commit(s) were added to refs/heads/main by this push:
     new ee153db5a1 Add more test-vectors for key blinding.
ee153db5a1 is described below

commit ee153db5a17e2825077a255c4e3bb345f2351806
Author: Nick Mathewson <nickm at torproject.org>
AuthorDate: Thu Jan 19 12:23:47 2023 -0500

    Add more test-vectors for key blinding.
    
    These are verified-as-correct against the current C implementation;
    adding them here gives us something to copy into Arti.
---
 src/feature/hs/hs_common.c |  2 +-
 src/feature/hs/hs_common.h |  7 ++++++
 src/test/test_hs_common.c  | 56 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/src/feature/hs/hs_common.c b/src/feature/hs/hs_common.c
index e326581dd1..6547372161 100644
--- a/src/feature/hs/hs_common.c
+++ b/src/feature/hs/hs_common.c
@@ -432,7 +432,7 @@ get_second_cached_disaster_srv(void)
  * thus will be ignored for the param construction.
  *
  * The result is put in param_out. */
-static void
+STATIC void
 build_blinded_key_param(const ed25519_public_key_t *pubkey,
                         const uint8_t *secret, size_t secret_len,
                         uint64_t period_num, uint64_t period_length,
diff --git a/src/feature/hs/hs_common.h b/src/feature/hs/hs_common.h
index a7a8f23a3c..48c112110c 100644
--- a/src/feature/hs/hs_common.h
+++ b/src/feature/hs/hs_common.h
@@ -256,7 +256,14 @@ link_specifier_t *link_specifier_dup(const link_specifier_t *src);
 
 #ifdef HS_COMMON_PRIVATE
 
+struct ed25519_public_key_t;
+
 STATIC void get_disaster_srv(uint64_t time_period_num, uint8_t *srv_out);
+STATIC void build_blinded_key_param(
+                        const struct ed25519_public_key_t *pubkey,
+                        const uint8_t *secret, size_t secret_len,
+                        uint64_t period_num, uint64_t period_length,
+                        uint8_t *param_out);
 
 /** The period for which a hidden service directory cannot be queried for
  * the same descriptor ID again. */
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index 347a5b7174..e58945a8c3 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -1509,6 +1509,61 @@ test_reachability(void *arg)
   }
 }
 
+static void
+test_blinding_basics(void *arg)
+{
+  (void)arg;
+  char *mem_op_hex_tmp = NULL;
+  uint64_t time_period = 1234;
+  ed25519_keypair_t keypair;
+  const char pubkey_hex[] =
+    "833990B085C1A688C1D4C8B1F6B56AFAF5A2ECA674449E1D704F83765CCB7BC6";
+  const char seckey_hex[] =
+    "D8C7FF0E31295B66540D789AF3E3DF992038A9592EEA01D8B7CBA06D6E66D159"
+    "4D6167696320576F7264733A20737065697373636F62616C742062697669756D";
+  base16_decode((char*)keypair.pubkey.pubkey, sizeof(keypair.pubkey.pubkey),
+                pubkey_hex, strlen(pubkey_hex));
+  base16_decode((char*)keypair.seckey.seckey, sizeof(keypair.seckey.seckey),
+                seckey_hex, strlen(seckey_hex));
+
+  uint64_t period_len = get_time_period_length();
+  tt_u64_op(period_len, OP_EQ, 1440);
+  uint8_t params[32];
+  build_blinded_key_param(&keypair.pubkey, NULL, 0,
+                          time_period, 1440,
+                          params);
+  test_memeq_hex(params,
+                 "379E50DB31FEE6775ABD0AF6FB7C371E"
+                 "060308F4F847DB09FE4CFE13AF602287");
+
+  ed25519_public_key_t blinded_public;
+  hs_build_blinded_pubkey(&keypair.pubkey, NULL, 0, time_period,
+                          &blinded_public);
+  hs_subcredential_t subcred;
+  hs_get_subcredential(&keypair.pubkey, &blinded_public, &subcred);
+
+  test_memeq_hex(blinded_public.pubkey,
+                 "3A50BF210E8F9EE955AE0014F7A6917F"
+                 "B65EBF098A86305ABB508D1A7291B6D5");
+  test_memeq_hex(subcred.subcred,
+                 "635D55907816E8D76398A675A50B1C2F"
+                 "3E36B42A5CA77BA3A0441285161AE07D");
+
+  ed25519_keypair_t blinded_keypair;
+  hs_build_blinded_keypair(&keypair, NULL, 0, time_period,
+                           &blinded_keypair);
+  tt_mem_op(blinded_public.pubkey, OP_EQ, blinded_keypair.pubkey.pubkey,
+            ED25519_PUBKEY_LEN);
+  test_memeq_hex(blinded_keypair.seckey.seckey,
+                 "A958DC83AC885F6814C67035DE817A2C"
+                 "604D5D2F715282079448F789B656350B"
+                 "4540FE1F80AA3F7E91306B7BF7A8E367"
+                 "293352B14A29FDCC8C19F3558075524B");
+
+ done:
+  tor_free(mem_op_hex_tmp);
+}
+
 /** Pick an HSDir for service with <b>onion_identity_pk</b> as a client. Put
  *  its identity digest in <b>hsdir_digest_out</b>. */
 static void
@@ -1843,6 +1898,7 @@ test_client_service_hsdir_set_sync(void *arg)
 }
 
 struct testcase_t hs_common_tests[] = {
+  { "blinding_basics", test_blinding_basics, TT_FORK, NULL, NULL },
   { "build_address", test_build_address, TT_FORK,
     NULL, NULL },
   { "validate_address", test_validate_address, TT_FORK,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list