2019-01-16 18:33:22 +01:00
|
|
|
/* Copyright (c) 2016-2019, The Tor Project, Inc. */
|
2016-03-08 21:51:53 +01:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file hs_descriptor.h
|
|
|
|
* \brief Header file for hs_descriptor.c
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef TOR_HS_DESCRIPTOR_H
|
|
|
|
#define TOR_HS_DESCRIPTOR_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "core/or/or.h"
|
2018-06-20 15:35:05 +02:00
|
|
|
#include "trunnel/ed25519_cert.h" /* needed for trunnel */
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/nodelist/torcert.h"
|
2016-03-08 21:51:53 +01:00
|
|
|
|
2017-07-18 19:56:19 +02:00
|
|
|
/* Trunnel */
|
2017-08-22 20:10:30 +02:00
|
|
|
struct link_specifier_t;
|
2017-07-18 19:56:19 +02:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The earliest descriptor format version we support. */
|
2016-03-08 21:51:53 +01:00
|
|
|
#define HS_DESC_SUPPORTED_FORMAT_VERSION_MIN 3
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The latest descriptor format version we support. */
|
2016-03-08 21:51:53 +01:00
|
|
|
#define HS_DESC_SUPPORTED_FORMAT_VERSION_MAX 3
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Default lifetime of a descriptor in seconds. The valus is set at 3 hours
|
2017-02-03 21:30:46 +01:00
|
|
|
* which is 180 minutes or 10800 seconds. */
|
|
|
|
#define HS_DESC_DEFAULT_LIFETIME (3 * 60 * 60)
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Maximum lifetime of a descriptor in seconds. The value is set at 12 hours
|
2016-06-28 22:27:01 +02:00
|
|
|
* which is 720 minutes or 43200 seconds. */
|
|
|
|
#define HS_DESC_MAX_LIFETIME (12 * 60 * 60)
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Lifetime of certificate in the descriptor. This defines the lifetime of the
|
2017-09-05 21:52:05 +02:00
|
|
|
* descriptor signing key and the cross certification cert of that key. It is
|
|
|
|
* set to 54 hours because a descriptor can be around for 48 hours and because
|
|
|
|
* consensuses are used after the hour, add an extra 6 hours to give some time
|
|
|
|
* for the service to stop using it. */
|
|
|
|
#define HS_DESC_CERT_LIFETIME (54 * 60 * 60)
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Length of the salt needed for the encrypted section of a descriptor. */
|
2016-03-08 21:51:53 +01:00
|
|
|
#define HS_DESC_ENCRYPTED_SALT_LEN 16
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Length of the KDF output value which is the length of the secret key,
|
2016-03-08 21:51:53 +01:00
|
|
|
* the secret IV and MAC key length which is the length of H() output. */
|
|
|
|
#define HS_DESC_ENCRYPTED_KDF_OUTPUT_LEN \
|
2016-11-07 19:15:46 +01:00
|
|
|
CIPHER256_KEY_LEN + CIPHER_IV_LEN + DIGEST256_LEN
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Pad plaintext of superencrypted data section before encryption so that its
|
2017-02-08 13:43:43 +01:00
|
|
|
* length is a multiple of this value. */
|
|
|
|
#define HS_DESC_SUPERENC_PLAINTEXT_PAD_MULTIPLE 10000
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Maximum length in bytes of a full hidden service descriptor. */
|
2016-12-23 13:48:05 +01:00
|
|
|
#define HS_DESC_MAX_LEN 50000 /* 50kb max size */
|
2016-06-28 22:27:01 +02:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Key length for the descriptor symmetric encryption. As specified in the
|
2016-11-07 19:15:46 +01:00
|
|
|
* protocol, we use AES-256 for the encrypted section of the descriptor. The
|
|
|
|
* following is the length in bytes and the bit size. */
|
|
|
|
#define HS_DESC_ENCRYPTED_KEY_LEN CIPHER256_KEY_LEN
|
|
|
|
#define HS_DESC_ENCRYPTED_BIT_SIZE (HS_DESC_ENCRYPTED_KEY_LEN * 8)
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Length of each components in the auth client section in the descriptor. */
|
2018-04-09 18:09:41 +02:00
|
|
|
#define HS_DESC_CLIENT_ID_LEN 8
|
|
|
|
#define HS_DESC_DESCRIPTOR_COOKIE_LEN 16
|
|
|
|
#define HS_DESC_COOKIE_KEY_LEN 32
|
|
|
|
#define HS_DESC_COOKIE_KEY_BIT_SIZE (HS_DESC_COOKIE_KEY_LEN * 8)
|
|
|
|
#define HS_DESC_ENCRYPED_COOKIE_LEN HS_DESC_DESCRIPTOR_COOKIE_LEN
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The number of auth client entries in the descriptor must be the multiple
|
2018-04-09 18:09:41 +02:00
|
|
|
* of this constant. */
|
|
|
|
#define HS_DESC_AUTH_CLIENT_MULTIPLE 16
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Type of authentication in the descriptor. */
|
2016-06-28 22:27:01 +02:00
|
|
|
typedef enum {
|
2017-02-02 12:58:20 +01:00
|
|
|
HS_DESC_AUTH_ED25519 = 1
|
2016-06-28 22:27:01 +02:00
|
|
|
} hs_desc_auth_type_t;
|
2016-03-08 21:51:53 +01:00
|
|
|
|
2019-05-28 18:35:04 +02:00
|
|
|
/** Error code when decoding a descriptor. */
|
|
|
|
typedef enum {
|
2019-05-28 19:00:57 +02:00
|
|
|
/* The configured client authorization for the requested .onion address
|
|
|
|
* failed to decode the descriptor. */
|
|
|
|
HS_DESC_DECODE_BAD_CLIENT_AUTH = -6,
|
|
|
|
|
|
|
|
/* The requested .onion address requires a client authorization. */
|
|
|
|
HS_DESC_DECODE_NEED_CLIENT_AUTH = -5,
|
|
|
|
|
|
|
|
/* Error during decryption of the encrypted layer. */
|
|
|
|
HS_DESC_DECODE_ENCRYPTED_ERROR = -4,
|
|
|
|
|
|
|
|
/* Error during decryption of the super encrypted layer. */
|
|
|
|
HS_DESC_DECODE_SUPERENC_ERROR = -3,
|
|
|
|
|
|
|
|
/* Error while decoding the plaintext section. */
|
|
|
|
HS_DESC_DECODE_PLAINTEXT_ERROR = -2,
|
|
|
|
|
|
|
|
/* Generic error. */
|
|
|
|
HS_DESC_DECODE_GENERIC_ERROR = -1,
|
|
|
|
|
|
|
|
/* Decoding a descriptor was successful. */
|
|
|
|
HS_DESC_DECODE_OK = 0,
|
2019-05-28 18:35:04 +02:00
|
|
|
} hs_desc_decode_status_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Introduction point information located in a descriptor. */
|
2016-03-08 21:51:53 +01:00
|
|
|
typedef struct hs_desc_intro_point_t {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Link specifier(s) which details how to extend to the relay. This list
|
2018-08-23 11:21:26 +02:00
|
|
|
* contains link_specifier_t objects. It MUST have at least one. */
|
2016-03-08 21:51:53 +01:00
|
|
|
smartlist_t *link_specifiers;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Onion key of the introduction point used to extend to it for the ntor
|
2017-07-19 19:42:35 +02:00
|
|
|
* handshake. */
|
|
|
|
curve25519_public_key_t onion_key;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Authentication key used to establish the introduction point circuit and
|
2016-03-08 21:51:53 +01:00
|
|
|
* cross-certifies the blinded public key for the replica thus signed by
|
|
|
|
* the blinded key and in turn signs it. */
|
|
|
|
tor_cert_t *auth_key_cert;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Encryption key for the "ntor" type. */
|
2017-02-10 20:24:54 +01:00
|
|
|
curve25519_public_key_t enc_key;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Certificate cross certifying the descriptor signing key by the encryption
|
2017-02-10 20:24:54 +01:00
|
|
|
* curve25519 key. This certificate contains the signing key and is of type
|
|
|
|
* CERT_TYPE_CROSS_HS_IP_KEYS [0B]. */
|
|
|
|
tor_cert_t *enc_key_cert;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** (Optional): If this introduction point is a legacy one that is version <=
|
2017-02-10 20:24:54 +01:00
|
|
|
* 0.2.9.x (HSIntro=3), we use this extra key for the intro point to be able
|
|
|
|
* to relay the cells to the service correctly. */
|
|
|
|
struct {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** RSA public key. */
|
2017-02-10 20:24:54 +01:00
|
|
|
crypto_pk_t *key;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Cross certified cert with the descriptor signing key (RSA->Ed). Because
|
2017-02-10 20:24:54 +01:00
|
|
|
* of the cross certification API, we need to keep the certificate binary
|
|
|
|
* blob and its length in order to properly encode it after. */
|
|
|
|
struct {
|
|
|
|
uint8_t *encoded;
|
|
|
|
size_t len;
|
|
|
|
} cert;
|
|
|
|
} legacy;
|
2016-06-28 22:27:01 +02:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** True iff the introduction point has passed the cross certification. Upon
|
2016-06-28 22:27:01 +02:00
|
|
|
* decoding an intro point, this must be true. */
|
|
|
|
unsigned int cross_certified : 1;
|
2016-03-08 21:51:53 +01:00
|
|
|
} hs_desc_intro_point_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Authorized client information located in a descriptor. */
|
2018-04-09 18:09:41 +02:00
|
|
|
typedef struct hs_desc_authorized_client_t {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** An identifier that the client will use to identify which auth client
|
2018-04-09 18:09:41 +02:00
|
|
|
* entry it needs to use. */
|
|
|
|
uint8_t client_id[HS_DESC_CLIENT_ID_LEN];
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** An IV that is used to decrypt the encrypted descriptor cookie. */
|
2018-04-09 18:09:41 +02:00
|
|
|
uint8_t iv[CIPHER_IV_LEN];
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** An encrypted descriptor cookie that the client needs to decrypt to use
|
2018-04-09 18:09:41 +02:00
|
|
|
* it to decrypt the descriptor. */
|
|
|
|
uint8_t encrypted_cookie[HS_DESC_ENCRYPED_COOKIE_LEN];
|
|
|
|
} hs_desc_authorized_client_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The encrypted data section of a descriptor. Obviously the data in this is
|
2016-03-08 21:51:53 +01:00
|
|
|
* in plaintext but encrypted once encoded. */
|
|
|
|
typedef struct hs_desc_encrypted_data_t {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Bitfield of CREATE2 cell supported formats. The only currently supported
|
2016-03-08 21:51:53 +01:00
|
|
|
* format is ntor. */
|
|
|
|
unsigned int create2_ntor : 1;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** A list of authentication types that a client must at least support one
|
2016-03-08 21:51:53 +01:00
|
|
|
* in order to contact the service. Contains NULL terminated strings. */
|
2017-02-02 12:58:20 +01:00
|
|
|
smartlist_t *intro_auth_types;
|
2016-03-08 21:51:53 +01:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Is this descriptor a single onion service? */
|
2016-11-08 19:22:42 +01:00
|
|
|
unsigned int single_onion_service : 1;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** A list of intro points. Contains hs_desc_intro_point_t objects. */
|
2016-03-08 21:51:53 +01:00
|
|
|
smartlist_t *intro_points;
|
|
|
|
} hs_desc_encrypted_data_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The superencrypted data section of a descriptor. Obviously the data in
|
2018-04-09 18:09:41 +02:00
|
|
|
* this is in plaintext but encrypted once encoded. */
|
|
|
|
typedef struct hs_desc_superencrypted_data_t {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** This field contains ephemeral x25519 public key which is used by
|
2018-04-09 18:09:41 +02:00
|
|
|
* the encryption scheme in the client authorization. */
|
|
|
|
curve25519_public_key_t auth_ephemeral_pubkey;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** A list of authorized clients. Contains hs_desc_authorized_client_t
|
2018-04-09 18:09:41 +02:00
|
|
|
* objects. */
|
|
|
|
smartlist_t *clients;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Decoding only: The b64-decoded encrypted blob from the descriptor */
|
2018-04-09 18:09:41 +02:00
|
|
|
uint8_t *encrypted_blob;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Decoding only: Size of the encrypted_blob */
|
2018-04-09 18:09:41 +02:00
|
|
|
size_t encrypted_blob_size;
|
|
|
|
} hs_desc_superencrypted_data_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Plaintext data that is unencrypted information of the descriptor. */
|
2016-03-08 21:51:53 +01:00
|
|
|
typedef struct hs_desc_plaintext_data_t {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Version of the descriptor format. Spec specifies this field as a
|
2016-03-08 21:51:53 +01:00
|
|
|
* positive integer. */
|
|
|
|
uint32_t version;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The lifetime of the descriptor in seconds. */
|
2016-03-08 21:51:53 +01:00
|
|
|
uint32_t lifetime_sec;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Certificate with the short-term ed22519 descriptor signing key for the
|
2016-03-08 21:51:53 +01:00
|
|
|
* replica which is signed by the blinded public key for that replica. */
|
|
|
|
tor_cert_t *signing_key_cert;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Signing public key which is used to sign the descriptor. Same public key
|
2016-03-08 21:51:53 +01:00
|
|
|
* as in the signing key certificate. */
|
2016-12-05 03:30:26 +01:00
|
|
|
ed25519_public_key_t signing_pubkey;
|
2016-03-08 21:51:53 +01:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Blinded public key used for this descriptor derived from the master
|
2016-03-08 21:51:53 +01:00
|
|
|
* identity key and generated for a specific replica number. */
|
2016-12-05 03:30:26 +01:00
|
|
|
ed25519_public_key_t blinded_pubkey;
|
2016-03-08 21:51:53 +01:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Revision counter is incremented at each upload, regardless of whether
|
2016-03-08 21:51:53 +01:00
|
|
|
* the descriptor has changed. This avoids leaking whether the descriptor
|
|
|
|
* has changed. Spec specifies this as a 8 bytes positive integer. */
|
|
|
|
uint64_t revision_counter;
|
2016-06-28 22:27:01 +02:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Decoding only: The b64-decoded superencrypted blob from the descriptor */
|
2017-02-06 13:13:35 +01:00
|
|
|
uint8_t *superencrypted_blob;
|
2016-06-28 22:27:01 +02:00
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Decoding only: Size of the superencrypted_blob */
|
2017-02-06 13:13:35 +01:00
|
|
|
size_t superencrypted_blob_size;
|
2016-03-08 21:51:53 +01:00
|
|
|
} hs_desc_plaintext_data_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Service descriptor in its decoded form. */
|
2016-03-08 21:51:53 +01:00
|
|
|
typedef struct hs_descriptor_t {
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Contains the plaintext part of the descriptor. */
|
2016-03-08 21:51:53 +01:00
|
|
|
hs_desc_plaintext_data_t plaintext_data;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The following contains what's in the superencrypted part of the
|
2018-04-09 18:09:41 +02:00
|
|
|
* descriptor. It's only encrypted in the encoded version of the descriptor
|
|
|
|
* thus the data contained in that object is in plaintext. */
|
|
|
|
hs_desc_superencrypted_data_t superencrypted_data;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** The following contains what's in the encrypted part of the descriptor.
|
2016-03-08 21:51:53 +01:00
|
|
|
* It's only encrypted in the encoded version of the descriptor thus the
|
|
|
|
* data contained in that object is in plaintext. */
|
|
|
|
hs_desc_encrypted_data_t encrypted_data;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Subcredentials of a service, used by the client and service to decrypt
|
2016-03-08 21:51:53 +01:00
|
|
|
* the encrypted data. */
|
|
|
|
uint8_t subcredential[DIGEST256_LEN];
|
|
|
|
} hs_descriptor_t;
|
|
|
|
|
2019-10-16 17:33:03 +02:00
|
|
|
/** Return true iff the given descriptor format version is supported. */
|
2016-03-08 21:51:53 +01:00
|
|
|
static inline int
|
|
|
|
hs_desc_is_supported_version(uint32_t version)
|
|
|
|
{
|
|
|
|
if (version < HS_DESC_SUPPORTED_FORMAT_VERSION_MIN ||
|
|
|
|
version > HS_DESC_SUPPORTED_FORMAT_VERSION_MAX) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Public API. */
|
|
|
|
|
2017-11-21 15:37:47 +01:00
|
|
|
void hs_descriptor_free_(hs_descriptor_t *desc);
|
2017-12-07 16:52:55 +01:00
|
|
|
#define hs_descriptor_free(desc) \
|
|
|
|
FREE_AND_NULL(hs_descriptor_t, hs_descriptor_free_, (desc))
|
2017-11-21 15:37:47 +01:00
|
|
|
void hs_desc_plaintext_data_free_(hs_desc_plaintext_data_t *desc);
|
|
|
|
#define hs_desc_plaintext_data_free(desc) \
|
2017-12-07 16:44:04 +01:00
|
|
|
FREE_AND_NULL(hs_desc_plaintext_data_t, hs_desc_plaintext_data_free_, (desc))
|
2018-04-09 18:09:41 +02:00
|
|
|
void hs_desc_superencrypted_data_free_(hs_desc_superencrypted_data_t *desc);
|
|
|
|
#define hs_desc_superencrypted_data_free(desc) \
|
|
|
|
FREE_AND_NULL(hs_desc_superencrypted_data_t, \
|
|
|
|
hs_desc_superencrypted_data_free_, (desc))
|
2017-11-21 15:37:47 +01:00
|
|
|
void hs_desc_encrypted_data_free_(hs_desc_encrypted_data_t *desc);
|
|
|
|
#define hs_desc_encrypted_data_free(desc) \
|
2017-12-07 16:44:04 +01:00
|
|
|
FREE_AND_NULL(hs_desc_encrypted_data_t, hs_desc_encrypted_data_free_, (desc))
|
2017-11-21 15:37:47 +01:00
|
|
|
|
2017-08-03 14:51:24 +02:00
|
|
|
void hs_descriptor_clear_intro_points(hs_descriptor_t *desc);
|
2017-02-03 21:30:46 +01:00
|
|
|
|
2017-08-19 15:26:46 +02:00
|
|
|
MOCK_DECL(int,
|
|
|
|
hs_desc_encode_descriptor,(const hs_descriptor_t *desc,
|
|
|
|
const ed25519_keypair_t *signing_kp,
|
2018-04-13 23:04:31 +02:00
|
|
|
const uint8_t *descriptor_cookie,
|
2017-08-19 15:26:46 +02:00
|
|
|
char **encoded_out));
|
2016-03-08 21:51:53 +01:00
|
|
|
|
2016-06-28 22:27:01 +02:00
|
|
|
int hs_desc_decode_descriptor(const char *encoded,
|
|
|
|
const uint8_t *subcredential,
|
2018-05-21 19:01:52 +02:00
|
|
|
const curve25519_secret_key_t *client_auth_sk,
|
2016-06-28 22:27:01 +02:00
|
|
|
hs_descriptor_t **desc_out);
|
|
|
|
int hs_desc_decode_plaintext(const char *encoded,
|
|
|
|
hs_desc_plaintext_data_t *plaintext);
|
2018-04-19 17:44:17 +02:00
|
|
|
int hs_desc_decode_superencrypted(const hs_descriptor_t *desc,
|
|
|
|
hs_desc_superencrypted_data_t *desc_out);
|
2016-06-28 22:27:01 +02:00
|
|
|
int hs_desc_decode_encrypted(const hs_descriptor_t *desc,
|
2018-05-21 19:01:52 +02:00
|
|
|
const curve25519_secret_key_t *client_auth_sk,
|
2016-06-28 22:27:01 +02:00
|
|
|
hs_desc_encrypted_data_t *desc_out);
|
|
|
|
|
2017-06-01 12:37:11 +02:00
|
|
|
size_t hs_desc_obj_size(const hs_descriptor_t *data);
|
2016-03-29 21:08:04 +02:00
|
|
|
size_t hs_desc_plaintext_obj_size(const hs_desc_plaintext_data_t *data);
|
|
|
|
|
2017-07-20 17:34:32 +02:00
|
|
|
hs_desc_intro_point_t *hs_desc_intro_point_new(void);
|
2017-11-21 15:37:47 +01:00
|
|
|
void hs_desc_intro_point_free_(hs_desc_intro_point_t *ip);
|
2017-12-07 16:52:55 +01:00
|
|
|
#define hs_desc_intro_point_free(ip) \
|
|
|
|
FREE_AND_NULL(hs_desc_intro_point_t, hs_desc_intro_point_free_, (ip))
|
2018-04-09 18:09:41 +02:00
|
|
|
void hs_desc_authorized_client_free_(hs_desc_authorized_client_t *client);
|
|
|
|
#define hs_desc_authorized_client_free(client) \
|
|
|
|
FREE_AND_NULL(hs_desc_authorized_client_t, \
|
|
|
|
hs_desc_authorized_client_free_, (client))
|
2017-07-20 17:34:32 +02:00
|
|
|
|
2018-09-05 19:37:37 +02:00
|
|
|
hs_desc_authorized_client_t *hs_desc_build_fake_authorized_client(void);
|
2019-09-09 22:18:14 +02:00
|
|
|
|
2018-09-06 15:25:31 +02:00
|
|
|
void hs_desc_build_authorized_client(const uint8_t *subcredential,
|
|
|
|
const curve25519_public_key_t *
|
2018-05-21 19:09:40 +02:00
|
|
|
client_auth_pk,
|
2018-04-09 18:09:41 +02:00
|
|
|
const curve25519_secret_key_t *
|
|
|
|
auth_ephemeral_sk,
|
|
|
|
const uint8_t *descriptor_cookie,
|
|
|
|
hs_desc_authorized_client_t *client_out);
|
2018-05-09 22:14:01 +02:00
|
|
|
void hs_desc_plaintext_data_free_contents(hs_desc_plaintext_data_t *desc);
|
|
|
|
void hs_desc_superencrypted_data_free_contents(
|
|
|
|
hs_desc_superencrypted_data_t *desc);
|
|
|
|
void hs_desc_encrypted_data_free_contents(hs_desc_encrypted_data_t *desc);
|
2018-04-09 18:09:41 +02:00
|
|
|
|
2016-03-15 19:18:03 +01:00
|
|
|
#ifdef HS_DESCRIPTOR_PRIVATE
|
|
|
|
|
|
|
|
/* Encoding. */
|
|
|
|
STATIC char *encode_link_specifiers(const smartlist_t *specs);
|
|
|
|
STATIC size_t build_plaintext_padding(const char *plaintext,
|
|
|
|
size_t plaintext_len,
|
|
|
|
uint8_t **padded_out);
|
|
|
|
/* Decoding. */
|
|
|
|
STATIC smartlist_t *decode_link_specifiers(const char *encoded);
|
|
|
|
STATIC hs_desc_intro_point_t *decode_introduction_point(
|
|
|
|
const hs_descriptor_t *desc,
|
|
|
|
const char *text);
|
|
|
|
STATIC int encrypted_data_length_is_valid(size_t len);
|
|
|
|
STATIC int cert_is_valid(tor_cert_t *cert, uint8_t type,
|
|
|
|
const char *log_obj_type);
|
|
|
|
STATIC int desc_sig_is_valid(const char *b64_sig,
|
2016-12-05 03:30:26 +01:00
|
|
|
const ed25519_public_key_t *signing_pubkey,
|
2016-03-15 19:18:03 +01:00
|
|
|
const char *encoded_desc, size_t encoded_len);
|
2017-08-24 22:21:44 +02:00
|
|
|
|
2017-10-27 20:28:02 +02:00
|
|
|
MOCK_DECL(STATIC size_t, decrypt_desc_layer,(const hs_descriptor_t *desc,
|
2018-04-19 17:44:17 +02:00
|
|
|
const uint8_t *descriptor_cookie,
|
2019-09-09 22:18:14 +02:00
|
|
|
bool is_superencrypted_layer,
|
2017-10-27 20:28:02 +02:00
|
|
|
char **decrypted_out));
|
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* defined(HS_DESCRIPTOR_PRIVATE) */
|
2016-03-15 19:18:03 +01:00
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* !defined(TOR_HS_DESCRIPTOR_H) */
|