onion_crypto.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file onion_crypto.h
  8. * \brief Header file for onion_crypto.c.
  9. **/
  10. #ifndef TOR_ONION_CRYPTO_H
  11. #define TOR_ONION_CRYPTO_H
  12. typedef struct server_onion_keys_t {
  13. uint8_t my_identity[DIGEST_LEN];
  14. crypto_pk_t *onion_key;
  15. crypto_pk_t *last_onion_key;
  16. struct di_digest256_map_t *curve25519_key_map;
  17. struct curve25519_keypair_t *junk_keypair;
  18. } server_onion_keys_t;
  19. void onion_handshake_state_release(onion_handshake_state_t *state);
  20. int onion_skin_create(int type,
  21. const extend_info_t *node,
  22. onion_handshake_state_t *state_out,
  23. uint8_t *onion_skin_out);
  24. int onion_skin_server_handshake(int type,
  25. const uint8_t *onion_skin, size_t onionskin_len,
  26. const server_onion_keys_t *keys,
  27. uint8_t *reply_out,
  28. uint8_t *keys_out, size_t key_out_len,
  29. uint8_t *rend_nonce_out);
  30. int onion_skin_client_handshake(int type,
  31. const onion_handshake_state_t *handshake_state,
  32. const uint8_t *reply, size_t reply_len,
  33. uint8_t *keys_out, size_t key_out_len,
  34. uint8_t *rend_authenticator_out,
  35. const char **msg_out);
  36. server_onion_keys_t *server_onion_keys_new(void);
  37. void server_onion_keys_free_(server_onion_keys_t *keys);
  38. #define server_onion_keys_free(keys) \
  39. FREE_AND_NULL(server_onion_keys_t, server_onion_keys_free_, (keys))
  40. #endif