1
2#ifndef crypto_box_curve25519xchacha20poly1305_H
3#define crypto_box_curve25519xchacha20poly1305_H
4
5#include <stddef.h>
6#include "crypto_stream_xchacha20.h"
7#include "export.h"
8
9#ifdef __cplusplus
10# ifdef __GNUC__
11#  pragma GCC diagnostic ignored "-Wlong-long"
12# endif
13extern "C" {
14#endif
15
16#define crypto_box_curve25519xchacha20poly1305_SEEDBYTES 32U
17SODIUM_EXPORT
18size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void);
19
20#define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U
21SODIUM_EXPORT
22size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void);
23
24#define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U
25SODIUM_EXPORT
26size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void);
27
28#define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U
29SODIUM_EXPORT
30size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void);
31
32#define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U
33SODIUM_EXPORT
34size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void);
35
36#define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U
37SODIUM_EXPORT
38size_t crypto_box_curve25519xchacha20poly1305_macbytes(void);
39
40#define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \
41    (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES)
42SODIUM_EXPORT
43size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void);
44
45SODIUM_EXPORT
46int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk,
47                                                        unsigned char *sk,
48                                                        const unsigned char *seed);
49
50SODIUM_EXPORT
51int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk,
52                                                   unsigned char *sk);
53
54SODIUM_EXPORT
55int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
56                                                const unsigned char *m,
57                                                unsigned long long mlen,
58                                                const unsigned char *n,
59                                                const unsigned char *pk,
60                                                const unsigned char *sk)
61            __attribute__ ((warn_unused_result));
62
63SODIUM_EXPORT
64int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
65                                                     const unsigned char *c,
66                                                     unsigned long long clen,
67                                                     const unsigned char *n,
68                                                     const unsigned char *pk,
69                                                     const unsigned char *sk)
70            __attribute__ ((warn_unused_result));
71
72SODIUM_EXPORT
73int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
74                                                    unsigned char *mac,
75                                                    const unsigned char *m,
76                                                    unsigned long long mlen,
77                                                    const unsigned char *n,
78                                                    const unsigned char *pk,
79                                                    const unsigned char *sk)
80            __attribute__ ((warn_unused_result));
81
82SODIUM_EXPORT
83int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
84                                                         const unsigned char *c,
85                                                         const unsigned char *mac,
86                                                         unsigned long long clen,
87                                                         const unsigned char *n,
88                                                         const unsigned char *pk,
89                                                         const unsigned char *sk)
90            __attribute__ ((warn_unused_result));
91
92/* -- Precomputation interface -- */
93
94SODIUM_EXPORT
95int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
96                                                    const unsigned char *pk,
97                                                    const unsigned char *sk)
98            __attribute__ ((warn_unused_result));
99
100SODIUM_EXPORT
101int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
102                                                        const unsigned char *m,
103                                                        unsigned long long mlen,
104                                                        const unsigned char *n,
105                                                        const unsigned char *k);
106
107SODIUM_EXPORT
108int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
109                                                             const unsigned char *c,
110                                                             unsigned long long clen,
111                                                             const unsigned char *n,
112                                                             const unsigned char *k)
113            __attribute__ ((warn_unused_result));
114
115SODIUM_EXPORT
116int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
117                                                            unsigned char *mac,
118                                                            const unsigned char *m,
119                                                            unsigned long long mlen,
120                                                            const unsigned char *n,
121                                                            const unsigned char *k);
122
123SODIUM_EXPORT
124int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m,
125                                                                 const unsigned char *c,
126                                                                 const unsigned char *mac,
127                                                                 unsigned long long clen,
128                                                                 const unsigned char *n,
129                                                                 const unsigned char *k)
130            __attribute__ ((warn_unused_result));
131
132/* -- Ephemeral SK interface -- */
133
134#define crypto_box_curve25519xchacha20poly1305_SEALBYTES \
135    (crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \
136     crypto_box_curve25519xchacha20poly1305_MACBYTES)
137
138SODIUM_EXPORT
139size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void);
140
141SODIUM_EXPORT
142int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c,
143                                                const unsigned char *m,
144                                                unsigned long long mlen,
145                                                const unsigned char *pk);
146
147SODIUM_EXPORT
148int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
149                                                     const unsigned char *c,
150                                                     unsigned long long clen,
151                                                     const unsigned char *pk,
152                                                     const unsigned char *sk)
153            __attribute__ ((warn_unused_result));
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif
160