summaryrefslogtreecommitdiff
path: root/src/feature/rend/rendservice.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-08-22 11:38:28 -0400
committerDavid Goulet <dgoulet@torproject.org>2018-08-22 11:38:28 -0400
commit61ad81c36e46d7b05b66601520c7ff42469f24d7 (patch)
tree937fcc490cee35171f4d4296ed5d458b9d95a1a3 /src/feature/rend/rendservice.c
parentcb466ee7d6f7f475783847a7201eaa6a3e1c711b (diff)
downloadtor-61ad81c36e46d7b05b66601520c7ff42469f24d7.tar.gz
tor-61ad81c36e46d7b05b66601520c7ff42469f24d7.zip
hs: Learn service version by trying to load the keys
In order to switch the default HS version from 2 to 3, we need tor to be smart and be able to decide on the version by trying to load the service keys during configuration validation. Part of #27215 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/rend/rendservice.c')
-rw-r--r--src/feature/rend/rendservice.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c
index 1a99bd56ed..1af9117aaf 100644
--- a/src/feature/rend/rendservice.c
+++ b/src/feature/rend/rendservice.c
@@ -1341,6 +1341,29 @@ rend_service_poison_new_single_onion_dir(const rend_service_t *s,
return 0;
}
+/* Return true iff the given service identity key is present on disk. This is
+ * used to try to learn the service version during configuration time. */
+int
+rend_service_key_on_disk(const char *directory_path)
+{
+ int ret = 0;
+ char *fname;
+ crypto_pk_t *pk = NULL;
+
+ tor_assert(directory_path);
+
+ /* Load key */
+ fname = hs_path_from_filename(directory_path, private_key_fname);
+ pk = init_key_from_file(fname, 0, LOG_DEBUG, 0);
+ if (pk) {
+ ret = 1;
+ }
+
+ crypto_pk_free(pk);
+ tor_free(fname);
+ return ret;
+}
+
/** Load and/or generate private keys for all hidden services, possibly
* including keys for client authorization.
* If a <b>service_list</b> is provided, treat it as the list of hidden