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