diff options
author | David Goulet <dgoulet@torproject.org> | 2020-01-14 12:54:56 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-01-21 10:31:29 -0500 |
commit | faada6af8d77eee40499be06acfab80d0ffac97f (patch) | |
tree | cb8c89c3983d078996020c9bfd4a350a18385dd8 /src | |
parent | 780e498f760b139fb540d2e050de08df60714f4a (diff) | |
download | tor-faada6af8d77eee40499be06acfab80d0ffac97f.tar.gz tor-faada6af8d77eee40499be06acfab80d0ffac97f.zip |
hs-v3: Implement hs_ob_service_is_instance()
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/hs/hs_cell.c | 2 | ||||
-rw-r--r-- | src/feature/hs/hs_ob.c | 18 | ||||
-rw-r--r-- | src/feature/hs/hs_ob.h | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/feature/hs/hs_cell.c b/src/feature/hs/hs_cell.c index 021a41825d..aabc558599 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 7e84af3d99..62db3bd434 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 8ad6aabc4f..fea6a737d7 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, |