hs_ntor.h 2.9 KB

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