crypto_curve25519.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Copyright (c) 2012, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_CRYPTO_CURVE25519_H
  4. #define TOR_CRYPTO_CURVE25519_H
  5. #include "torint.h"
  6. /** Length of a curve25519 public key when encoded. */
  7. #define CURVE25519_PUBKEY_LEN 32
  8. /** Length of a curve25519 secret key when encoded. */
  9. #define CURVE25519_SECKEY_LEN 32
  10. /** Length of the result of a curve25519 handshake. */
  11. #define CURVE25519_OUTPUT_LEN 32
  12. /** Wrapper type for a curve25519 public key */
  13. typedef struct curve25519_public_key_t {
  14. uint8_t public_key[CURVE25519_PUBKEY_LEN];
  15. } curve25519_public_key_t;
  16. /** Wrapper type for a curve25519 secret key */
  17. typedef struct curve25519_secret_key_t {
  18. uint8_t secret_key[CURVE25519_SECKEY_LEN];
  19. } curve25519_secret_key_t;
  20. int curve25519_public_key_is_ok(const curve25519_public_key_t *);
  21. void curve25519_secret_key_generate(curve25519_secret_key_t *key_out,
  22. int extra_strong);
  23. void curve25519_public_key_generate(curve25519_public_key_t *key_out,
  24. const curve25519_secret_key_t *seckey);
  25. void curve25519_handshake(uint8_t *output,
  26. const curve25519_secret_key_t *,
  27. const curve25519_public_key_t *);
  28. #ifdef CRYPTO_CURVE25519_PRIVATE
  29. int curve25519_impl(uint8_t *output, const uint8_t *secret,
  30. const uint8_t *basepoint);
  31. #endif
  32. #endif