|
@@ -6,6 +6,7 @@
|
|
|
#include "test.h"
|
|
|
#include "torcert.h"
|
|
|
|
|
|
+#include "hs_common.h"
|
|
|
#include "hs_test_helpers.h"
|
|
|
|
|
|
hs_desc_intro_point_t *
|
|
@@ -93,8 +94,7 @@ static hs_descriptor_t *
|
|
|
hs_helper_build_hs_desc_impl(unsigned int no_ip,
|
|
|
const ed25519_keypair_t *signing_kp)
|
|
|
{
|
|
|
- int ret;
|
|
|
- time_t now = time(NULL);
|
|
|
+ time_t now = approx_time();
|
|
|
ed25519_keypair_t blinded_kp;
|
|
|
hs_descriptor_t *descp = NULL, *desc = tor_malloc_zero(sizeof(*desc));
|
|
|
|
|
@@ -104,8 +104,9 @@ hs_helper_build_hs_desc_impl(unsigned int no_ip,
|
|
|
memcpy(&desc->plaintext_data.signing_pubkey, &signing_kp->pubkey,
|
|
|
sizeof(ed25519_public_key_t));
|
|
|
|
|
|
- ret = ed25519_keypair_generate(&blinded_kp, 0);
|
|
|
- tt_int_op(ret, ==, 0);
|
|
|
+ uint64_t current_time_period = hs_get_time_period_num(approx_time());
|
|
|
+ hs_build_blinded_keypair(signing_kp, NULL, 0,
|
|
|
+ current_time_period, &blinded_kp);
|
|
|
/* Copy only the public key into the descriptor. */
|
|
|
memcpy(&desc->plaintext_data.blinded_pubkey, &blinded_kp.pubkey,
|
|
|
sizeof(ed25519_public_key_t));
|
|
@@ -118,6 +119,9 @@ hs_helper_build_hs_desc_impl(unsigned int no_ip,
|
|
|
desc->plaintext_data.revision_counter = 42;
|
|
|
desc->plaintext_data.lifetime_sec = 3 * 60 * 60;
|
|
|
|
|
|
+ hs_get_subcredential(&signing_kp->pubkey, &blinded_kp.pubkey,
|
|
|
+ desc->subcredential);
|
|
|
+
|
|
|
/* Setup encrypted data section. */
|
|
|
desc->encrypted_data.create2_ntor = 1;
|
|
|
desc->encrypted_data.intro_auth_types = smartlist_new();
|
|
@@ -141,6 +145,21 @@ hs_helper_build_hs_desc_impl(unsigned int no_ip,
|
|
|
return descp;
|
|
|
}
|
|
|
|
|
|
+/** Helper function to get the HS subcredential using the identity keypair of
|
|
|
+ * an HS. Used to decrypt descriptors in unittests. */
|
|
|
+void
|
|
|
+hs_helper_get_subcred_from_identity_keypair(ed25519_keypair_t *signing_kp,
|
|
|
+ uint8_t *subcred_out)
|
|
|
+{
|
|
|
+ ed25519_keypair_t blinded_kp;
|
|
|
+ uint64_t current_time_period = hs_get_time_period_num(approx_time());
|
|
|
+ hs_build_blinded_keypair(signing_kp, NULL, 0,
|
|
|
+ current_time_period, &blinded_kp);
|
|
|
+
|
|
|
+ hs_get_subcredential(&signing_kp->pubkey, &blinded_kp.pubkey,
|
|
|
+ subcred_out);
|
|
|
+}
|
|
|
+
|
|
|
/* Build a descriptor with introduction points. */
|
|
|
hs_descriptor_t *
|
|
|
hs_helper_build_hs_desc_with_ip(const ed25519_keypair_t *signing_kp)
|