crypto_aead_xchacha20poly1305.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef crypto_aead_xchacha20poly1305_H
  2. #define crypto_aead_xchacha20poly1305_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_aead_xchacha20poly1305_ietf_KEYBYTES 32U
  12. SODIUM_EXPORT
  13. size_t crypto_aead_xchacha20poly1305_ietf_keybytes(void);
  14. #define crypto_aead_xchacha20poly1305_ietf_NSECBYTES 0U
  15. SODIUM_EXPORT
  16. size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes(void);
  17. #define crypto_aead_xchacha20poly1305_ietf_NPUBBYTES 24U
  18. SODIUM_EXPORT
  19. size_t crypto_aead_xchacha20poly1305_ietf_npubbytes(void);
  20. #define crypto_aead_xchacha20poly1305_ietf_ABYTES 16U
  21. SODIUM_EXPORT
  22. size_t crypto_aead_xchacha20poly1305_ietf_abytes(void);
  23. #define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \
  24. (SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES)
  25. SODIUM_EXPORT
  26. size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void);
  27. SODIUM_EXPORT
  28. int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
  29. unsigned long long *clen_p,
  30. const unsigned char *m,
  31. unsigned long long mlen,
  32. const unsigned char *ad,
  33. unsigned long long adlen,
  34. const unsigned char *nsec,
  35. const unsigned char *npub,
  36. const unsigned char *k)
  37. __attribute__ ((nonnull(1, 8, 9)));
  38. SODIUM_EXPORT
  39. int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m,
  40. unsigned long long *mlen_p,
  41. unsigned char *nsec,
  42. const unsigned char *c,
  43. unsigned long long clen,
  44. const unsigned char *ad,
  45. unsigned long long adlen,
  46. const unsigned char *npub,
  47. const unsigned char *k)
  48. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(4, 8, 9)));
  49. SODIUM_EXPORT
  50. int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c,
  51. unsigned char *mac,
  52. unsigned long long *maclen_p,
  53. const unsigned char *m,
  54. unsigned long long mlen,
  55. const unsigned char *ad,
  56. unsigned long long adlen,
  57. const unsigned char *nsec,
  58. const unsigned char *npub,
  59. const unsigned char *k)
  60. __attribute__ ((nonnull(1, 2, 9, 10)));
  61. SODIUM_EXPORT
  62. int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
  63. unsigned char *nsec,
  64. const unsigned char *c,
  65. unsigned long long clen,
  66. const unsigned char *mac,
  67. const unsigned char *ad,
  68. unsigned long long adlen,
  69. const unsigned char *npub,
  70. const unsigned char *k)
  71. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
  72. SODIUM_EXPORT
  73. void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES])
  74. __attribute__ ((nonnull));
  75. /* Aliases */
  76. #define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES
  77. #define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES
  78. #define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
  79. #define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES
  80. #define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif