onion_ntor.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (c) 2012, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_ONION_NTOR_H
  4. #define TOR_ONION_NTOR_H
  5. #include "torint.h"
  6. #include "crypto_curve25519.h"
  7. #include "di_ops.h"
  8. /** State to be maintained by a client between sending an ntor onionskin
  9. * and receiving a reply. */
  10. typedef struct ntor_handshake_state_t ntor_handshake_state_t;
  11. /** Length of an ntor onionskin, as sent from the client to server. */
  12. #define NTOR_ONIONSKIN_LEN 84
  13. /** Length of an ntor reply, as sent from server to client. */
  14. #define NTOR_REPLY_LEN 64
  15. /** A paired public and private key for curve25519.
  16. * XXXX024 move this structure somewhere smarter.
  17. **/
  18. typedef struct curve25519_keypair_t {
  19. curve25519_public_key_t pubkey;
  20. curve25519_secret_key_t seckey;
  21. } curve25519_keypair_t;
  22. void ntor_handshake_state_free(ntor_handshake_state_t *state);
  23. int onion_skin_ntor_create(const uint8_t *router_id,
  24. const curve25519_public_key_t *router_key,
  25. ntor_handshake_state_t **handshake_state_out,
  26. uint8_t *onion_skin_out);
  27. int onion_skin_ntor_server_handshake(const uint8_t *onion_skin,
  28. const di_digest256_map_t *private_keys,
  29. const uint8_t *my_node_id,
  30. uint8_t *handshake_reply_out,
  31. uint8_t *key_out,
  32. size_t key_out_len);
  33. int onion_skin_ntor_client_handshake(
  34. const ntor_handshake_state_t *handshake_state,
  35. const uint8_t *handshake_reply,
  36. uint8_t *key_out,
  37. size_t key_out_len);
  38. #endif