crypto_box_curve25519xchacha20poly1305.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #ifndef crypto_box_curve25519xchacha20poly1305_H
  2. #define crypto_box_curve25519xchacha20poly1305_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_box_curve25519xchacha20poly1305_SEEDBYTES 32U
  13. SODIUM_EXPORT
  14. size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void);
  15. #define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U
  16. SODIUM_EXPORT
  17. size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void);
  18. #define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U
  19. SODIUM_EXPORT
  20. size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void);
  21. #define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U
  22. SODIUM_EXPORT
  23. size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void);
  24. #define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U
  25. SODIUM_EXPORT
  26. size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void);
  27. #define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U
  28. SODIUM_EXPORT
  29. size_t crypto_box_curve25519xchacha20poly1305_macbytes(void);
  30. #define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \
  31. (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES)
  32. SODIUM_EXPORT
  33. size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void);
  34. SODIUM_EXPORT
  35. int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk,
  36. unsigned char *sk,
  37. const unsigned char *seed)
  38. __attribute__ ((nonnull));
  39. SODIUM_EXPORT
  40. int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk,
  41. unsigned char *sk)
  42. __attribute__ ((nonnull));
  43. SODIUM_EXPORT
  44. int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
  45. const unsigned char *m,
  46. unsigned long long mlen,
  47. const unsigned char *n,
  48. const unsigned char *pk,
  49. const unsigned char *sk)
  50. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
  51. SODIUM_EXPORT
  52. int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
  53. const unsigned char *c,
  54. unsigned long long clen,
  55. const unsigned char *n,
  56. const unsigned char *pk,
  57. const unsigned char *sk)
  58. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
  59. SODIUM_EXPORT
  60. int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
  61. unsigned char *mac,
  62. const unsigned char *m,
  63. unsigned long long mlen,
  64. const unsigned char *n,
  65. const unsigned char *pk,
  66. const unsigned char *sk)
  67. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
  68. SODIUM_EXPORT
  69. int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
  70. const unsigned char *c,
  71. const unsigned char *mac,
  72. unsigned long long clen,
  73. const unsigned char *n,
  74. const unsigned char *pk,
  75. const unsigned char *sk)
  76. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6, 7)));
  77. /* -- Precomputation interface -- */
  78. SODIUM_EXPORT
  79. int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
  80. const unsigned char *pk,
  81. const unsigned char *sk)
  82. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  83. SODIUM_EXPORT
  84. int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
  85. const unsigned char *m,
  86. unsigned long long mlen,
  87. const unsigned char *n,
  88. const unsigned char *k)
  89. __attribute__ ((nonnull(1, 4, 5)));
  90. SODIUM_EXPORT
  91. int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
  92. const unsigned char *c,
  93. unsigned long long clen,
  94. const unsigned char *n,
  95. const unsigned char *k)
  96. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
  97. SODIUM_EXPORT
  98. int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
  99. unsigned char *mac,
  100. const unsigned char *m,
  101. unsigned long long mlen,
  102. const unsigned char *n,
  103. const unsigned char *k)
  104. __attribute__ ((nonnull(1, 2, 5, 6)));
  105. SODIUM_EXPORT
  106. int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m,
  107. const unsigned char *c,
  108. const unsigned char *mac,
  109. unsigned long long clen,
  110. const unsigned char *n,
  111. const unsigned char *k)
  112. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
  113. /* -- Ephemeral SK interface -- */
  114. #define crypto_box_curve25519xchacha20poly1305_SEALBYTES \
  115. (crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \
  116. crypto_box_curve25519xchacha20poly1305_MACBYTES)
  117. SODIUM_EXPORT
  118. size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void);
  119. SODIUM_EXPORT
  120. int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c,
  121. const unsigned char *m,
  122. unsigned long long mlen,
  123. const unsigned char *pk)
  124. __attribute__ ((nonnull(1, 4)));
  125. SODIUM_EXPORT
  126. int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
  127. const unsigned char *c,
  128. unsigned long long clen,
  129. const unsigned char *pk,
  130. const unsigned char *sk)
  131. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif