Tor  0.4.3.1-alpha-dev
hs_ntor.h
Go to the documentation of this file.
1 /* Copyright (c) 2017-2020, 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 */
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];
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];
37 
38 int hs_ntor_client_get_introduce1_keys(
39  const struct ed25519_public_key_t *intro_auth_pubkey,
40  const struct curve25519_public_key_t *intro_enc_pubkey,
41  const struct curve25519_keypair_t *client_ephemeral_enc_keypair,
42  const uint8_t *subcredential,
43  hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
44 
45 int hs_ntor_client_get_rendezvous1_keys(
46  const struct ed25519_public_key_t *intro_auth_pubkey,
47  const struct curve25519_keypair_t *client_ephemeral_enc_keypair,
48  const struct curve25519_public_key_t *intro_enc_pubkey,
49  const struct curve25519_public_key_t *service_ephemeral_rend_pubkey,
50  hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
51 
52 int hs_ntor_service_get_introduce1_keys(
53  const struct ed25519_public_key_t *intro_auth_pubkey,
54  const struct curve25519_keypair_t *intro_enc_keypair,
55  const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
56  const uint8_t *subcredential,
57  hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
58 
59 int hs_ntor_service_get_rendezvous1_keys(
60  const struct ed25519_public_key_t *intro_auth_pubkey,
61  const struct curve25519_keypair_t *intro_enc_keypair,
62  const struct curve25519_keypair_t *service_ephemeral_rend_keypair,
63  const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
64  hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
65 
66 int hs_ntor_circuit_key_expansion(const uint8_t *ntor_key_seed,
67  size_t seed_len,
68  uint8_t *keys_out, size_t keys_out_len);
69 
71  const hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys,
72  const uint8_t *rcvd_mac);
73 
74 #endif /* !defined(TOR_HS_NTOR_H) */
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:568
#define DIGEST256_LEN
Definition: digest_sizes.h:23
Master header file for Tor-specific functionality.
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:589
#define CIPHER256_KEY_LEN
Definition: crypto_cipher.h:26