tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

hs_ntor.h (3746B)


      1 /* Copyright (c) 2017-2021, The Tor Project, Inc. */
      2 /* See LICENSE for licensing information */
      3 
      4 /**
      5 * @file hs_ntor.h
      6 * @brief Header for hs_ntor.c
      7 **/
      8 
      9 #ifndef TOR_HS_NTOR_H
     10 #define TOR_HS_NTOR_H
     11 
     12 #include "core/or/or.h"
     13 struct ed25519_public_key_t;
     14 struct curve25519_public_key_t;
     15 struct curve25519_keypair_t;
     16 
     17 /* Output length of KDF for key expansion */
     18 #define HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN \
     19  (DIGEST256_LEN*2 + CIPHER256_KEY_LEN*2)
     20 
     21 /* Key material needed to encode/decode INTRODUCE1 cells */
     22 typedef struct hs_ntor_intro_cell_keys_t {
     23  /* Key used for encryption of encrypted INTRODUCE1 blob */
     24  uint8_t enc_key[CIPHER256_KEY_LEN];
     25  /* MAC key used to protect encrypted INTRODUCE1 blob */
     26  uint8_t mac_key[DIGEST256_LEN];
     27 } hs_ntor_intro_cell_keys_t;
     28 
     29 /* Key material needed to encode/decode RENDEZVOUS1 cells */
     30 typedef struct hs_ntor_rend_cell_keys_t {
     31  /* This is the MAC of the HANDSHAKE_INFO field */
     32  uint8_t rend_cell_auth_mac[DIGEST256_LEN];
     33  /* This is the key seed used to derive further rendezvous crypto keys as
     34   * detailed in section 4.2.1 of rend-spec-ng.txt. */
     35  uint8_t ntor_key_seed[DIGEST256_LEN];
     36 } hs_ntor_rend_cell_keys_t;
     37 
     38 #define SUBCRED_LEN DIGEST256_LEN
     39 
     40 /**
     41 * A 'subcredential' used to prove knowledge of a hidden service.
     42 **/
     43 typedef struct hs_subcredential_t {
     44  uint8_t subcred[SUBCRED_LEN];
     45 } hs_subcredential_t;
     46 
     47 int hs_ntor_client_get_introduce1_keys(
     48              const struct ed25519_public_key_t *intro_auth_pubkey,
     49              const struct curve25519_public_key_t *intro_enc_pubkey,
     50              const struct curve25519_keypair_t *client_ephemeral_enc_keypair,
     51              const hs_subcredential_t *subcredential,
     52              hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
     53 
     54 int hs_ntor_client_get_rendezvous1_keys(
     55          const struct ed25519_public_key_t *intro_auth_pubkey,
     56          const struct curve25519_keypair_t *client_ephemeral_enc_keypair,
     57          const struct curve25519_public_key_t *intro_enc_pubkey,
     58          const struct curve25519_public_key_t *service_ephemeral_rend_pubkey,
     59          hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
     60 
     61 int hs_ntor_service_get_introduce1_keys_multi(
     62            const struct ed25519_public_key_t *intro_auth_pubkey,
     63            const struct curve25519_keypair_t *intro_enc_keypair,
     64            const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
     65            size_t n_subcredentials,
     66            const hs_subcredential_t *subcredentials,
     67            hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
     68 
     69 int hs_ntor_service_get_introduce1_keys(
     70            const struct ed25519_public_key_t *intro_auth_pubkey,
     71            const struct curve25519_keypair_t *intro_enc_keypair,
     72            const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
     73            const hs_subcredential_t *subcredential,
     74            hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
     75 
     76 int hs_ntor_service_get_rendezvous1_keys(
     77            const struct ed25519_public_key_t *intro_auth_pubkey,
     78            const struct curve25519_keypair_t *intro_enc_keypair,
     79            const struct curve25519_keypair_t *service_ephemeral_rend_keypair,
     80            const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
     81            hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
     82 
     83 int hs_ntor_circuit_key_expansion(const uint8_t *ntor_key_seed,
     84                                  size_t seed_len,
     85                                  uint8_t *keys_out, size_t keys_out_len);
     86 
     87 int hs_ntor_client_rendezvous2_mac_is_good(
     88                        const hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys,
     89                        const uint8_t *rcvd_mac);
     90 
     91 #endif /* !defined(TOR_HS_NTOR_H) */