hs-v3: Implement hs_ob_service_is_instance()

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2020-01-14 12:54:56 -05:00 committed by Nick Mathewson
parent 780e498f76
commit faada6af8d
3 changed files with 21 additions and 1 deletions

View File

@ -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);

View File

@ -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.
*

View File

@ -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,