tor  0.4.2.0-alpha-dev
hs_ntor.h
1 /* Copyright (c) 2017-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 #ifndef TOR_HS_NTOR_H
5 #define TOR_HS_NTOR_H
6 
7 #include "core/or/or.h"
11 
12 /* Output length of KDF for key expansion */
13 #define HS_NTOR_KEY_EXPANSION_KDF_OUT_LEN \
14  (DIGEST256_LEN*2 + CIPHER256_KEY_LEN*2)
15 
16 /* Key material needed to encode/decode INTRODUCE1 cells */
17 typedef struct {
18  /* Key used for encryption of encrypted INTRODUCE1 blob */
19  uint8_t enc_key[CIPHER256_KEY_LEN];
20  /* MAC key used to protect encrypted INTRODUCE1 blob */
21  uint8_t mac_key[DIGEST256_LEN];
23 
24 /* Key material needed to encode/decode RENDEZVOUS1 cells */
25 typedef struct {
26  /* This is the MAC of the HANDSHAKE_INFO field */
27  uint8_t rend_cell_auth_mac[DIGEST256_LEN];
28  /* This is the key seed used to derive further rendezvous crypto keys as
29  * detailed in section 4.2.1 of rend-spec-ng.txt. */
30  uint8_t ntor_key_seed[DIGEST256_LEN];
32 
33 int hs_ntor_client_get_introduce1_keys(
34  const struct ed25519_public_key_t *intro_auth_pubkey,
35  const struct curve25519_public_key_t *intro_enc_pubkey,
36  const struct curve25519_keypair_t *client_ephemeral_enc_keypair,
37  const uint8_t *subcredential,
38  hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
39 
40 int hs_ntor_client_get_rendezvous1_keys(
41  const struct ed25519_public_key_t *intro_auth_pubkey,
42  const struct curve25519_keypair_t *client_ephemeral_enc_keypair,
43  const struct curve25519_public_key_t *intro_enc_pubkey,
44  const struct curve25519_public_key_t *service_ephemeral_rend_pubkey,
45  hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
46 
47 int hs_ntor_service_get_introduce1_keys(
48  const struct ed25519_public_key_t *intro_auth_pubkey,
49  const struct curve25519_keypair_t *intro_enc_keypair,
50  const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
51  const uint8_t *subcredential,
52  hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
53 
54 int hs_ntor_service_get_rendezvous1_keys(
55  const struct ed25519_public_key_t *intro_auth_pubkey,
56  const struct curve25519_keypair_t *intro_enc_keypair,
57  const struct curve25519_keypair_t *service_ephemeral_rend_keypair,
58  const struct curve25519_public_key_t *client_ephemeral_enc_pubkey,
59  hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
60 
61 int hs_ntor_circuit_key_expansion(const uint8_t *ntor_key_seed,
62  size_t seed_len,
63  uint8_t *keys_out, size_t keys_out_len);
64 
66  const hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys,
67  const uint8_t *rcvd_mac);
68 
69 #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.
#define CIPHER256_KEY_LEN
Definition: crypto_cipher.h:26
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