crypto_kx.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef crypto_kx_H
  2. #define crypto_kx_H
  3. #include <stddef.h>
  4. #include "export.h"
  5. #ifdef __cplusplus
  6. # ifdef __GNUC__
  7. # pragma GCC diagnostic ignored "-Wlong-long"
  8. # endif
  9. extern "C" {
  10. #endif
  11. #define crypto_kx_PUBLICKEYBYTES 32
  12. SODIUM_EXPORT
  13. size_t crypto_kx_publickeybytes(void);
  14. #define crypto_kx_SECRETKEYBYTES 32
  15. SODIUM_EXPORT
  16. size_t crypto_kx_secretkeybytes(void);
  17. #define crypto_kx_SEEDBYTES 32
  18. SODIUM_EXPORT
  19. size_t crypto_kx_seedbytes(void);
  20. #define crypto_kx_SESSIONKEYBYTES 32
  21. SODIUM_EXPORT
  22. size_t crypto_kx_sessionkeybytes(void);
  23. #define crypto_kx_PRIMITIVE "x25519blake2b"
  24. SODIUM_EXPORT
  25. const char *crypto_kx_primitive(void);
  26. SODIUM_EXPORT
  27. int crypto_kx_seed_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
  28. unsigned char sk[crypto_kx_SECRETKEYBYTES],
  29. const unsigned char seed[crypto_kx_SEEDBYTES])
  30. __attribute__ ((nonnull));
  31. SODIUM_EXPORT
  32. int crypto_kx_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
  33. unsigned char sk[crypto_kx_SECRETKEYBYTES])
  34. __attribute__ ((nonnull));
  35. SODIUM_EXPORT
  36. int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
  37. unsigned char tx[crypto_kx_SESSIONKEYBYTES],
  38. const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES],
  39. const unsigned char client_sk[crypto_kx_SECRETKEYBYTES],
  40. const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES])
  41. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5)));
  42. SODIUM_EXPORT
  43. int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
  44. unsigned char tx[crypto_kx_SESSIONKEYBYTES],
  45. const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES],
  46. const unsigned char server_sk[crypto_kx_SECRETKEYBYTES],
  47. const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES])
  48. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 4, 5)));
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif