aboutsummaryrefslogtreecommitdiff
path: root/src/feature/hs/hs_client.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-06-03 16:18:32 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2019-11-18 19:21:34 +0200
commitce422a9d4a6f170b35f54545eface216f87c7089 (patch)
tree06954d88b9bce089526468bac7a050ee56f77b6f /src/feature/hs/hs_client.c
parent53ac9a9a91a8f2ab45c75550456716074911e685 (diff)
downloadtor-ce422a9d4a6f170b35f54545eface216f87c7089.tar.gz
tor-ce422a9d4a6f170b35f54545eface216f87c7089.zip
hs-v3: Decrypt pending descriptors when we get new client auth creds.
Diffstat (limited to 'src/feature/hs/hs_client.c')
-rw-r--r--src/feature/hs/hs_client.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/feature/hs/hs_client.c b/src/feature/hs/hs_client.c
index 9edfd13673..34574e4bd4 100644
--- a/src/feature/hs/hs_client.c
+++ b/src/feature/hs/hs_client.c
@@ -1453,6 +1453,8 @@ hs_client_register_auth_status_t
hs_client_register_auth_credentials(hs_client_service_authorization_t *creds)
{
ed25519_public_key_t service_identity_pk;
+ hs_client_service_authorization_t *old_creds = NULL;
+ hs_client_register_auth_status_t retval = REGISTER_SUCCESS;
tor_assert(creds);
@@ -1466,13 +1468,22 @@ hs_client_register_auth_credentials(hs_client_service_authorization_t *creds)
return REGISTER_FAIL_BAD_ADDRESS;
}
- if (digest256map_get(client_auths, service_identity_pk.pubkey)) {
- client_service_authorization_free(creds);
- return REGISTER_FAIL_ALREADY_EXISTS;
+ old_creds = digest256map_get(client_auths, service_identity_pk.pubkey);
+ if (old_creds) {
+ digest256map_remove(client_auths, service_identity_pk.pubkey);
+ client_service_authorization_free(old_creds);
+ retval = REGISTER_SUCCESS_ALREADY_EXISTS;
}
digest256map_set(client_auths, service_identity_pk.pubkey, creds);
- return REGISTER_SUCCESS;
+
+ /** Now that we set the new credentials, also try to decrypt any cached
+ * descriptors. */
+ if (hs_cache_client_new_auth_parse(&service_identity_pk)) {
+ retval = REGISTER_SUCCESS_ALSO_DECRYPTED;
+ }
+
+ return retval;
}
/** Remove client auth credentials for the service <b>hs_address</b>. */