tor_free(ip);
}
-/* Build a fake client info for the descriptor */
-void
-hs_desc_build_fake_authorized_client(hs_desc_authorized_client_t *client_out)
-{
- tor_assert(client_out);
-
- crypto_rand((char *) client_out->client_id,
- sizeof(client_out->client_id));
- crypto_rand((char *) client_out->iv,
- sizeof(client_out->iv));
- crypto_rand((char *) client_out->encrypted_cookie,
- sizeof(client_out->encrypted_cookie));
+/* Allocate and build a new fake client info for the descriptor. Return a
+ * newly allocated object. This can't fail. */
+hs_desc_authorized_client_t *
+hs_desc_build_fake_authorized_client(void)
+{
+ hs_desc_authorized_client_t *client_auth =
+ tor_malloc_zero(sizeof(*client_auth));
+
+ crypto_rand((char *) client_auth->client_id,
+ sizeof(client_auth->client_id));
+ crypto_rand((char *) client_auth->iv,
+ sizeof(client_auth->iv));
+ crypto_rand((char *) client_auth->encrypted_cookie,
+ sizeof(client_auth->encrypted_cookie));
+
+ return client_auth;
}
/* Using the client public key, auth ephemeral secret key, and descriptor
link_specifier_t *hs_desc_lspec_to_trunnel(
const hs_desc_link_specifier_t *spec);
-void
-hs_desc_build_fake_authorized_client(hs_desc_authorized_client_t *client_out);
+hs_desc_authorized_client_t *hs_desc_build_fake_authorized_client(void);
void hs_desc_build_authorized_client(const curve25519_public_key_t *
client_auth_pk,
const curve25519_secret_key_t *
}
for (i = 0; i < num_clients_to_add; i++) {
- hs_desc_authorized_client_t *desc_client;
- desc_client = tor_malloc_zero(sizeof(hs_desc_authorized_client_t));
-
- hs_desc_build_fake_authorized_client(desc_client);
+ hs_desc_authorized_client_t *desc_client =
+ hs_desc_build_fake_authorized_client();
smartlist_add(superencrypted->clients, desc_client);
}
desc->superencrypted_data.clients = smartlist_new();
for (i = 0; i < HS_DESC_AUTH_CLIENT_MULTIPLE; i++) {
- hs_desc_authorized_client_t *desc_client;
- desc_client = tor_malloc_zero(sizeof(hs_desc_authorized_client_t));
-
- hs_desc_build_fake_authorized_client(desc_client);
+ hs_desc_authorized_client_t *desc_client =
+ hs_desc_build_fake_authorized_client();
smartlist_add(desc->superencrypted_data.clients, desc_client);
}
/* We need to add fake auth clients here. */
for (i=0; i < 15; ++i) {
- fake_client = tor_malloc_zero(sizeof(hs_desc_authorized_client_t));
- hs_desc_build_fake_authorized_client(fake_client);
+ fake_client = hs_desc_build_fake_authorized_client();
smartlist_add(clients, fake_client);
}
desc->superencrypted_data.clients = clients;