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