hs_ntor.h 2.9 KB

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