crypto_secretbox.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef crypto_secretbox_H
  2. #define crypto_secretbox_H
  3. #include <stddef.h>
  4. #include "crypto_secretbox_xsalsa20poly1305.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_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES
  13. SODIUM_EXPORT
  14. size_t crypto_secretbox_keybytes(void);
  15. #define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES
  16. SODIUM_EXPORT
  17. size_t crypto_secretbox_noncebytes(void);
  18. #define crypto_secretbox_MACBYTES crypto_secretbox_xsalsa20poly1305_MACBYTES
  19. SODIUM_EXPORT
  20. size_t crypto_secretbox_macbytes(void);
  21. #define crypto_secretbox_PRIMITIVE "xsalsa20poly1305"
  22. SODIUM_EXPORT
  23. const char *crypto_secretbox_primitive(void);
  24. #define crypto_secretbox_MESSAGEBYTES_MAX crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX
  25. SODIUM_EXPORT
  26. size_t crypto_secretbox_messagebytes_max(void);
  27. SODIUM_EXPORT
  28. int crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
  29. unsigned long long mlen, const unsigned char *n,
  30. const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
  31. SODIUM_EXPORT
  32. int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
  33. unsigned long long clen, const unsigned char *n,
  34. const unsigned char *k)
  35. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
  36. SODIUM_EXPORT
  37. int crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
  38. const unsigned char *m,
  39. unsigned long long mlen,
  40. const unsigned char *n,
  41. const unsigned char *k)
  42. __attribute__ ((nonnull(1, 2, 5, 6)));
  43. SODIUM_EXPORT
  44. int crypto_secretbox_open_detached(unsigned char *m,
  45. const unsigned char *c,
  46. const unsigned char *mac,
  47. unsigned long long clen,
  48. const unsigned char *n,
  49. const unsigned char *k)
  50. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
  51. SODIUM_EXPORT
  52. void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])
  53. __attribute__ ((nonnull));
  54. /* -- NaCl compatibility interface ; Requires padding -- */
  55. #define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
  56. SODIUM_EXPORT
  57. size_t crypto_secretbox_zerobytes(void);
  58. #define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
  59. SODIUM_EXPORT
  60. size_t crypto_secretbox_boxzerobytes(void);
  61. SODIUM_EXPORT
  62. int crypto_secretbox(unsigned char *c, const unsigned char *m,
  63. unsigned long long mlen, const unsigned char *n,
  64. const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
  65. SODIUM_EXPORT
  66. int crypto_secretbox_open(unsigned char *m, const unsigned char *c,
  67. unsigned long long clen, const unsigned char *n,
  68. const unsigned char *k)
  69. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif