hs_ntor.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* Key material needed to encode/decode INTRODUCE1 cells */
  7. typedef struct {
  8. /* Key used for encryption of encrypted INTRODUCE1 blob */
  9. uint8_t enc_key[CIPHER256_KEY_LEN];
  10. /* MAC key used to protect encrypted INTRODUCE1 blob */
  11. uint8_t mac_key[DIGEST256_LEN];
  12. } hs_ntor_intro_cell_keys_t;
  13. /* Key material needed to encode/decode RENDEZVOUS1 cells */
  14. typedef struct {
  15. /* This is the MAC of the HANDSHAKE_INFO field */
  16. uint8_t rend_cell_auth_mac[DIGEST256_LEN];
  17. /* This is the key seed used to derive further rendezvous crypto keys as
  18. * detailed in section 4.2.1 of rend-spec-ng.txt. */
  19. uint8_t ntor_key_seed[DIGEST256_LEN];
  20. } hs_ntor_rend_cell_keys_t;
  21. /* Key material resulting from key expansion as detailed in section "4.2.1. Key
  22. * expansion" of rend-spec-ng.txt. */
  23. typedef struct {
  24. /* Per-circuit key material used in ESTABLISH_INTRO cell */
  25. uint8_t KH[DIGEST256_LEN];
  26. /* Authentication key for outgoing RELAY cells */
  27. uint8_t Df[DIGEST256_LEN];
  28. /* Authentication key for incoming RELAY cells */
  29. uint8_t Db[DIGEST256_LEN];
  30. /* Encryption key for outgoing RELAY cells */
  31. uint8_t Kf[CIPHER256_KEY_LEN];
  32. /* Decryption key for incoming RELAY cells */
  33. uint8_t Kb[CIPHER256_KEY_LEN];
  34. } hs_ntor_rend_circuit_keys_t;
  35. int hs_ntor_client_get_introduce1_keys(
  36. const ed25519_public_key_t *intro_auth_pubkey,
  37. const curve25519_public_key_t *intro_enc_pubkey,
  38. const curve25519_keypair_t *client_ephemeral_enc_keypair,
  39. const uint8_t *subcredential,
  40. hs_ntor_intro_cell_keys_t *hs_ntor_intro_cell_keys_out);
  41. int hs_ntor_client_get_rendezvous1_keys(
  42. const ed25519_public_key_t *intro_auth_pubkey,
  43. const curve25519_keypair_t *client_ephemeral_enc_keypair,
  44. const curve25519_public_key_t *intro_enc_pubkey,
  45. const curve25519_public_key_t *service_ephemeral_rend_pubkey,
  46. hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
  47. int hs_ntor_service_get_introduce1_keys(
  48. const ed25519_public_key_t *intro_auth_pubkey,
  49. const curve25519_keypair_t *intro_enc_keypair,
  50. const 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. int hs_ntor_service_get_rendezvous1_keys(
  54. const ed25519_public_key_t *intro_auth_pubkey,
  55. const curve25519_keypair_t *intro_enc_keypair,
  56. const curve25519_keypair_t *service_ephemeral_rend_keypair,
  57. const curve25519_public_key_t *client_ephemeral_enc_pubkey,
  58. hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys_out);
  59. hs_ntor_rend_circuit_keys_t *hs_ntor_circuit_key_expansion(
  60. const hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys);
  61. int hs_ntor_client_rendezvous2_mac_is_good(
  62. const hs_ntor_rend_cell_keys_t *hs_ntor_rend_cell_keys,
  63. const uint8_t *rcvd_mac);
  64. #endif