[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] hs-v3: Implement hs_ob_service_is_instance()
commit faada6af8d77eee40499be06acfab80d0ffac97f
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Tue Jan 14 12:54:56 2020 -0500
hs-v3: Implement hs_ob_service_is_instance()
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/feature/hs/hs_cell.c | 2 +-
src/feature/hs/hs_ob.c | 18 ++++++++++++++++++
src/feature/hs/hs_ob.h | 2 ++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/feature/hs/hs_cell.c b/src/feature/hs/hs_cell.c
index 021a41825..aabc55859 100644
--- a/src/feature/hs/hs_cell.c
+++ b/src/feature/hs/hs_cell.c
@@ -916,7 +916,7 @@ hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
* file. This is because the master identity key and the blinded key is put
* in the INTRODUCE2 cell by the client thus it will never validate with
* this instance default public key. */
- if (service->config.ob_master_pubkeys) {
+ if (hs_ob_service_is_instance(service)) {
intro_keys = get_intro2_keys_as_ob(&service->config, data,
encrypted_section,
encrypted_section_len);
diff --git a/src/feature/hs/hs_ob.c b/src/feature/hs/hs_ob.c
index 7e84af3d9..62db3bd43 100644
--- a/src/feature/hs/hs_ob.c
+++ b/src/feature/hs/hs_ob.c
@@ -193,6 +193,24 @@ build_subcredential(const ed25519_public_key_t *pkey, uint64_t tp,
* Public API.
*/
+/** Return true iff the given service is configured as an onion balance
+ * instance. To satisfy that condition, there must at least be one master
+ * ed25519 public key configured. */
+bool
+hs_ob_service_is_instance(const hs_service_t *service)
+{
+ if (BUG(service == NULL)) {
+ return false;
+ }
+
+ /* No list, we are not an instance. */
+ if (!service->config.ob_master_pubkeys) {
+ return false;
+ }
+
+ return smartlist_len(service->config.ob_master_pubkeys) > 0;
+}
+
/** Read and parse the config file at fname on disk. The service config object
* is populated with the options if any.
*
diff --git a/src/feature/hs/hs_ob.h b/src/feature/hs/hs_ob.h
index 8ad6aabc4..fea6a737d 100644
--- a/src/feature/hs/hs_ob.h
+++ b/src/feature/hs/hs_ob.h
@@ -11,6 +11,8 @@
#include "hs_service.h"
+bool hs_ob_service_is_instance(const hs_service_t *service);
+
int hs_ob_parse_config_file(hs_service_config_t *config);
size_t hs_ob_get_subcredentials(const hs_service_config_t *config,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits