Home | History | Annotate | Line # | Download | only in sodium
      1 #ifndef crypto_stream_salsa20_H
      2 #define crypto_stream_salsa20_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_salsa20_KEYBYTES 32U
     24 SODIUM_EXPORT
     25 size_t crypto_stream_salsa20_keybytes(void);
     26 
     27 #define crypto_stream_salsa20_NONCEBYTES 8U
     28 SODIUM_EXPORT
     29 size_t crypto_stream_salsa20_noncebytes(void);
     30 
     31 #define crypto_stream_salsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
     32 SODIUM_EXPORT
     33 size_t crypto_stream_salsa20_messagebytes_max(void);
     34 
     35 SODIUM_EXPORT
     36 int crypto_stream_salsa20(unsigned char *c, unsigned long long clen,
     37                           const unsigned char *n, const unsigned char *k);
     38 
     39 SODIUM_EXPORT
     40 int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m,
     41                               unsigned long long mlen, const unsigned char *n,
     42                               const unsigned char *k);
     43 
     44 SODIUM_EXPORT
     45 int crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m,
     46                                  unsigned long long mlen,
     47                                  const unsigned char *n, uint64_t ic,
     48                                  const unsigned char *k);
     49 
     50 SODIUM_EXPORT
     51 void crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES]);
     52 
     53 #ifdef __cplusplus
     54 }
     55 #endif
     56 
     57 #endif
     58