xref: /freebsd/sys/contrib/libsodium/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h (revision 3611ec604864a7d4dcc9a3ea898c80eb35eef8a0)
1 #ifndef crypto_secretbox_xchacha20poly1305_H
2 #define crypto_secretbox_xchacha20poly1305_H
3 
4 #include <stddef.h>
5 #include "crypto_stream_xchacha20.h"
6 #include "export.h"
7 
8 #ifdef __cplusplus
9 # ifdef __GNUC__
10 #  pragma GCC diagnostic ignored "-Wlong-long"
11 # endif
12 extern "C" {
13 #endif
14 
15 #define crypto_secretbox_xchacha20poly1305_KEYBYTES 32U
16 SODIUM_EXPORT
17 size_t crypto_secretbox_xchacha20poly1305_keybytes(void);
18 
19 #define crypto_secretbox_xchacha20poly1305_NONCEBYTES 24U
20 SODIUM_EXPORT
21 size_t crypto_secretbox_xchacha20poly1305_noncebytes(void);
22 
23 #define crypto_secretbox_xchacha20poly1305_MACBYTES 16U
24 SODIUM_EXPORT
25 size_t crypto_secretbox_xchacha20poly1305_macbytes(void);
26 
27 #define crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX \
28     (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_secretbox_xchacha20poly1305_MACBYTES)
29 SODIUM_EXPORT
30 size_t crypto_secretbox_xchacha20poly1305_messagebytes_max(void);
31 
32 SODIUM_EXPORT
33 int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c,
34                                             const unsigned char *m,
35                                             unsigned long long mlen,
36                                             const unsigned char *n,
37                                             const unsigned char *k);
38 
39 SODIUM_EXPORT
40 int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
41                                                  const unsigned char *c,
42                                                  unsigned long long clen,
43                                                  const unsigned char *n,
44                                                  const unsigned char *k)
45             __attribute__ ((warn_unused_result));
46 
47 SODIUM_EXPORT
48 int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
49                                                 unsigned char *mac,
50                                                 const unsigned char *m,
51                                                 unsigned long long mlen,
52                                                 const unsigned char *n,
53                                                 const unsigned char *k);
54 
55 SODIUM_EXPORT
56 int crypto_secretbox_xchacha20poly1305_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));
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif
69