crypto_box_curve25519xsalsa20poly1305.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef crypto_box_curve25519xsalsa20poly1305_H
  2. #define crypto_box_curve25519xsalsa20poly1305_H
  3. #include <stddef.h>
  4. #include "crypto_stream_xsalsa20.h"
  5. #include "export.h"
  6. #ifdef __cplusplus
  7. # ifdef __GNUC__
  8. # pragma GCC diagnostic ignored "-Wlong-long"
  9. # endif
  10. extern "C" {
  11. #endif
  12. #define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U
  13. SODIUM_EXPORT
  14. size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void);
  15. #define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U
  16. SODIUM_EXPORT
  17. size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void);
  18. #define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 32U
  19. SODIUM_EXPORT
  20. size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void);
  21. #define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 32U
  22. SODIUM_EXPORT
  23. size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void);
  24. #define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 24U
  25. SODIUM_EXPORT
  26. size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void);
  27. #define crypto_box_curve25519xsalsa20poly1305_MACBYTES 16U
  28. SODIUM_EXPORT
  29. size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void);
  30. /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
  31. #define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \
  32. (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES)
  33. SODIUM_EXPORT
  34. size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void);
  35. SODIUM_EXPORT
  36. int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk,
  37. unsigned char *sk,
  38. const unsigned char *seed)
  39. __attribute__ ((nonnull));
  40. SODIUM_EXPORT
  41. int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk,
  42. unsigned char *sk)
  43. __attribute__ ((nonnull));
  44. SODIUM_EXPORT
  45. int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
  46. const unsigned char *pk,
  47. const unsigned char *sk)
  48. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  49. /* -- NaCl compatibility interface ; Requires padding -- */
  50. #define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U
  51. SODIUM_EXPORT
  52. size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void);
  53. #define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES \
  54. (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \
  55. crypto_box_curve25519xsalsa20poly1305_MACBYTES)
  56. SODIUM_EXPORT
  57. size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void);
  58. SODIUM_EXPORT
  59. int crypto_box_curve25519xsalsa20poly1305(unsigned char *c,
  60. const unsigned char *m,
  61. unsigned long long mlen,
  62. const unsigned char *n,
  63. const unsigned char *pk,
  64. const unsigned char *sk)
  65. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
  66. SODIUM_EXPORT
  67. int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
  68. const unsigned char *c,
  69. unsigned long long clen,
  70. const unsigned char *n,
  71. const unsigned char *pk,
  72. const unsigned char *sk)
  73. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
  74. SODIUM_EXPORT
  75. int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
  76. const unsigned char *m,
  77. unsigned long long mlen,
  78. const unsigned char *n,
  79. const unsigned char *k)
  80. __attribute__ ((nonnull(1, 4, 5)));
  81. SODIUM_EXPORT
  82. int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
  83. const unsigned char *c,
  84. unsigned long long clen,
  85. const unsigned char *n,
  86. const unsigned char *k)
  87. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif