libsodium (1.0.19)

(root)/
include/
sodium/
crypto_secretbox.h
       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) __attribute__ ((nonnull(1, 4, 5)));
      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)) __attribute__ ((nonnull(2, 4, 5)));
      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              __attribute__ ((nonnull(1, 2, 5, 6)));
      54  
      55  SODIUM_EXPORT
      56  int crypto_secretbox_open_detached(unsigned char *m,
      57                                     const unsigned char *c,
      58                                     const unsigned char *mac,
      59                                     unsigned long long clen,
      60                                     const unsigned char *n,
      61                                     const unsigned char *k)
      62              __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 3, 5, 6)));
      63  
      64  SODIUM_EXPORT
      65  void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])
      66              __attribute__ ((nonnull));
      67  
      68  /* -- NaCl compatibility interface ; Requires padding -- */
      69  
      70  #define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
      71  SODIUM_EXPORT
      72  size_t  crypto_secretbox_zerobytes(void);
      73  
      74  #define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
      75  SODIUM_EXPORT
      76  size_t  crypto_secretbox_boxzerobytes(void);
      77  
      78  SODIUM_EXPORT
      79  int crypto_secretbox(unsigned char *c, const unsigned char *m,
      80                       unsigned long long mlen, const unsigned char *n,
      81                       const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
      82  
      83  SODIUM_EXPORT
      84  int crypto_secretbox_open(unsigned char *m, const unsigned char *c,
      85                            unsigned long long clen, const unsigned char *n,
      86                            const unsigned char *k)
      87              __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
      88  
      89  #ifdef __cplusplus
      90  }
      91  #endif
      92  
      93  #endif