crypto_dh.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file crypto_dh.h
  8. *
  9. * \brief Headers for crypto_dh.c
  10. **/
  11. #ifndef TOR_CRYPTO_DH_H
  12. #define TOR_CRYPTO_DH_H
  13. #include "orconfig.h"
  14. #include "lib/defs/dh_sizes.h"
  15. typedef struct crypto_dh_t crypto_dh_t;
  16. /* Key negotiation */
  17. #define DH_TYPE_CIRCUIT 1
  18. #define DH_TYPE_REND 2
  19. #define DH_TYPE_TLS 3
  20. void crypto_set_tls_dh_prime(void);
  21. crypto_dh_t *crypto_dh_new(int dh_type);
  22. crypto_dh_t *crypto_dh_dup(const crypto_dh_t *dh);
  23. int crypto_dh_get_bytes(crypto_dh_t *dh);
  24. int crypto_dh_generate_public(crypto_dh_t *dh);
  25. int crypto_dh_get_public(crypto_dh_t *dh, char *pubkey_out,
  26. size_t pubkey_out_len);
  27. ssize_t crypto_dh_compute_secret(int severity, crypto_dh_t *dh,
  28. const char *pubkey, size_t pubkey_len,
  29. char *secret_out, size_t secret_out_len);
  30. void crypto_dh_free_(crypto_dh_t *dh);
  31. #define crypto_dh_free(dh) FREE_AND_NULL(crypto_dh_t, crypto_dh_free_, (dh))
  32. /* Crypto DH free */
  33. void crypto_dh_free_all(void);
  34. /* Prototypes for private functions only used by tortls.c, crypto.c, and the
  35. * unit tests. */
  36. struct dh_st;
  37. struct dh_st *crypto_dh_get_dh_(crypto_dh_t *dh);
  38. #endif /* !defined(TOR_CRYPTO_DH_H) */