Tor 0.4.9.0-alpha-dev
hs_ntor.h
Go to the documentation of this file.
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"
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 */
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];
28
29/* Key material needed to encode/decode RENDEZVOUS1 cells */
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];
37
38#define SUBCRED_LEN DIGEST256_LEN
39
40/**
41 * A 'subcredential' used to prove knowledge of a hidden service.
42 **/
43typedef struct hs_subcredential_t {
44 uint8_t subcred[SUBCRED_LEN];
46
47int 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
54int 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
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
69int 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
76int 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
83int 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
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) */
#define CIPHER256_KEY_LEN
Definition: crypto_cipher.h:26
#define DIGEST256_LEN
Definition: digest_sizes.h:23
int hs_ntor_circuit_key_expansion(const uint8_t *ntor_key_seed, size_t seed_len, uint8_t *keys_out, size_t keys_out_len)
Definition: hs_ntor.c:615
int hs_ntor_service_get_introduce1_keys_multi(const struct ed25519_public_key_t *intro_auth_pubkey, const struct curve25519_keypair_t *intro_enc_keypair, const struct curve25519_public_key_t *client_ephemeral_enc_pubkey, size_t n_subcredentials, const hs_subcredential_t *subcredentials, hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out)
Definition: hs_ntor.c:470
int hs_ntor_client_rendezvous2_mac_is_good(const hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys, const uint8_t *rcvd_mac)
Definition: hs_ntor.c:594
Master header file for Tor-specific functionality.