crypto_stream_xchacha20.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef crypto_stream_xchacha20_H
  2. #define crypto_stream_xchacha20_H
  3. /*
  4. * WARNING: This is just a stream cipher. It is NOT authenticated encryption.
  5. * While it provides some protection against eavesdropping, it does NOT
  6. * provide any security against active attacks.
  7. * Unless you know what you're doing, what you are looking for is probably
  8. * the crypto_box functions.
  9. */
  10. #include <stddef.h>
  11. #include <stdint.h>
  12. #include "export.h"
  13. #ifdef __cplusplus
  14. # ifdef __GNUC__
  15. # pragma GCC diagnostic ignored "-Wlong-long"
  16. # endif
  17. extern "C" {
  18. #endif
  19. #define crypto_stream_xchacha20_KEYBYTES 32U
  20. SODIUM_EXPORT
  21. size_t crypto_stream_xchacha20_keybytes(void);
  22. #define crypto_stream_xchacha20_NONCEBYTES 24U
  23. SODIUM_EXPORT
  24. size_t crypto_stream_xchacha20_noncebytes(void);
  25. #define crypto_stream_xchacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
  26. SODIUM_EXPORT
  27. size_t crypto_stream_xchacha20_messagebytes_max(void);
  28. SODIUM_EXPORT
  29. int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen,
  30. const unsigned char *n, const unsigned char *k)
  31. __attribute__ ((nonnull));
  32. SODIUM_EXPORT
  33. int crypto_stream_xchacha20_xor(unsigned char *c, const unsigned char *m,
  34. unsigned long long mlen, const unsigned char *n,
  35. const unsigned char *k)
  36. __attribute__ ((nonnull));
  37. SODIUM_EXPORT
  38. int crypto_stream_xchacha20_xor_ic(unsigned char *c, const unsigned char *m,
  39. unsigned long long mlen,
  40. const unsigned char *n, uint64_t ic,
  41. const unsigned char *k)
  42. __attribute__ ((nonnull));
  43. SODIUM_EXPORT
  44. void crypto_stream_xchacha20_keygen(unsigned char k[crypto_stream_xchacha20_KEYBYTES])
  45. __attribute__ ((nonnull));
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif