crypto_secretbox_xchacha20poly1305.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef crypto_secretbox_xchacha20poly1305_H
  2. #define crypto_secretbox_xchacha20poly1305_H
  3. #include <stddef.h>
  4. #include "crypto_stream_xchacha20.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_xchacha20poly1305_KEYBYTES 32U
  13. SODIUM_EXPORT
  14. size_t crypto_secretbox_xchacha20poly1305_keybytes(void);
  15. #define crypto_secretbox_xchacha20poly1305_NONCEBYTES 24U
  16. SODIUM_EXPORT
  17. size_t crypto_secretbox_xchacha20poly1305_noncebytes(void);
  18. #define crypto_secretbox_xchacha20poly1305_MACBYTES 16U
  19. SODIUM_EXPORT
  20. size_t crypto_secretbox_xchacha20poly1305_macbytes(void);
  21. #define crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX \
  22. (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_secretbox_xchacha20poly1305_MACBYTES)
  23. SODIUM_EXPORT
  24. size_t crypto_secretbox_xchacha20poly1305_messagebytes_max(void);
  25. SODIUM_EXPORT
  26. int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c,
  27. const unsigned char *m,
  28. unsigned long long mlen,
  29. const unsigned char *n,
  30. const unsigned char *k)
  31. __attribute__ ((nonnull(1, 4, 5)));
  32. SODIUM_EXPORT
  33. int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
  34. const unsigned char *c,
  35. unsigned long long clen,
  36. const unsigned char *n,
  37. const unsigned char *k)
  38. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
  39. SODIUM_EXPORT
  40. int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
  41. unsigned char *mac,
  42. const unsigned char *m,
  43. unsigned long long mlen,
  44. const unsigned char *n,
  45. const unsigned char *k)
  46. __attribute__ ((nonnull(1, 2, 5, 6)));
  47. SODIUM_EXPORT
  48. int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
  49. const unsigned char *c,
  50. const unsigned char *mac,
  51. unsigned long long clen,
  52. const unsigned char *n,
  53. const unsigned char *k)
  54. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif