Home | History | Annotate | Line # | Download | only in sodium
      1 #ifndef crypto_secretbox_H
      2 #define crypto_secretbox_H
      3 
      4 #include <stddef.h>
      5 
      6 #include "crypto_secretbox_xsalsa20poly1305.h"
      7 #include "export.h"
      8 
      9 #ifdef __cplusplus
     10 # ifdef __GNUC__
     11 #  pragma GCC diagnostic ignored "-Wlong-long"
     12 # endif
     13 extern "C" {
     14 #endif
     15 
     16 #define crypto_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES
     17 SODIUM_EXPORT
     18 size_t  crypto_secretbox_keybytes(void);
     19 
     20 #define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES
     21 SODIUM_EXPORT
     22 size_t  crypto_secretbox_noncebytes(void);
     23 
     24 #define crypto_secretbox_MACBYTES crypto_secretbox_xsalsa20poly1305_MACBYTES
     25 SODIUM_EXPORT
     26 size_t  crypto_secretbox_macbytes(void);
     27 
     28 #define crypto_secretbox_PRIMITIVE "xsalsa20poly1305"
     29 SODIUM_EXPORT
     30 const char *crypto_secretbox_primitive(void);
     31 
     32 #define crypto_secretbox_MESSAGEBYTES_MAX crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX
     33 SODIUM_EXPORT
     34 size_t crypto_secretbox_messagebytes_max(void);
     35 
     36 SODIUM_EXPORT
     37 int crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
     38                           unsigned long long mlen, const unsigned char *n,
     39                           const unsigned char *k);
     40 
     41 SODIUM_EXPORT
     42 int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
     43                                unsigned long long clen, const unsigned char *n,
     44                                const unsigned char *k)
     45             __attribute__ ((warn_unused_result));
     46 
     47 SODIUM_EXPORT
     48 int crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
     49                               const unsigned char *m,
     50                               unsigned long long mlen,
     51                               const unsigned char *n,
     52                               const unsigned char *k);
     53 
     54 SODIUM_EXPORT
     55 int crypto_secretbox_open_detached(unsigned char *m,
     56                                    const unsigned char *c,
     57                                    const unsigned char *mac,
     58                                    unsigned long long clen,
     59                                    const unsigned char *n,
     60                                    const unsigned char *k)
     61             __attribute__ ((warn_unused_result));
     62 
     63 SODIUM_EXPORT
     64 void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES]);
     65 
     66 /* -- NaCl compatibility interface ; Requires padding -- */
     67 
     68 #define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
     69 SODIUM_EXPORT
     70 size_t  crypto_secretbox_zerobytes(void);
     71 
     72 #define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
     73 SODIUM_EXPORT
     74 size_t  crypto_secretbox_boxzerobytes(void);
     75 
     76 SODIUM_EXPORT
     77 int crypto_secretbox(unsigned char *c, const unsigned char *m,
     78                      unsigned long long mlen, const unsigned char *n,
     79                      const unsigned char *k);
     80 
     81 SODIUM_EXPORT
     82 int crypto_secretbox_open(unsigned char *m, const unsigned char *c,
     83                           unsigned long long clen, const unsigned char *n,
     84                           const unsigned char *k)
     85             __attribute__ ((warn_unused_result));
     86 
     87 #ifdef __cplusplus
     88 }
     89 #endif
     90 
     91 #endif
     92