Crypto++  7.0
Free C++ class library of cryptographic schemes
naclite.h
Go to the documentation of this file.
1 // naclite.h - written and placed in the public domain by Jeffrey Walton
2 // based on public domain NaCl source code written by
3 // Daniel J. Bernstein, Bernard van Gastel, Wesley Janssen,
4 // Tanja Lange, Peter Schwabe and Sjaak Smetsers.
5 
6 /// \file naclite.h
7 /// \brief Crypto++ interface to TweetNaCl library (20140917)
8 /// \details TweetNaCl is a compact reimplementation of the NaCl library by
9 /// Daniel J. Bernstein, Bernard van Gastel, Wesley Janssen, Tanja Lange,
10 /// Peter Schwabe and Sjaak Smetsers. The library is less than 20 KB in size
11 /// and provides 25 of the NaCl library functions.
12 /// \details The compact library uses curve25519, XSalsa20, Poly1305 and
13 /// SHA-512 as default primitives, and includes both x25519 key exchange and
14 /// ed25519 signatures. The complete list of functions can be found in
15 /// <A HREF="https://tweetnacl.cr.yp.to/tweetnacl-20140917.pdf">TweetNaCl:
16 /// A crypto library in 100 tweets</A> (20140917), Table 1, page 5.
17 /// \details Crypto++ rejects small order elements using libsodium's blacklist. The
18 /// TweetNaCl library allowed them but the library predated the attack. If you wish
19 /// to allow small elements then use the "unchecked" versions of crypto_box_unchecked,
20 /// crypto_box_open_unchecked and crypto_box_beforenm_unchecked.
21 /// \details TweetNaCl is well written but not well optimzed. It runs 2x to 3x
22 /// slower than optimized routines from libsodium. However, the library is still
23 /// 2x to 4x faster than the algorithms NaCl was designed to replace.
24 /// \details The Crypto++ wrapper for TweetNaCl requires OS features. That is,
25 /// <tt>NO_OS_DEPENDENCE</tt> cannot be defined. It is due to TweetNaCl's
26 /// internal function <tt>randombytes</tt>. Crypto++ used
27 /// <tt>DefaultAutoSeededRNG</tt> within <tt>randombytes</tt>, so OS integration
28 /// must be enabled. You can use another generator like <tt>RDRAND</tt> to
29 /// avoid the restriction.
30 /// \sa <A HREF="https://cr.yp.to/highspeed/coolnacl-20120725.pdf">The security impact
31 /// of a new cryptographic library</A>, <A
32 /// HREF="https://tweetnacl.cr.yp.to/tweetnacl-20140917.pdf">TweetNaCl:
33 /// A crypto library in 100 tweets</A> (20140917), <A
34 /// HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A
35 /// Microarchitectural Side Channel Attack on Several Real-World Applications of
36 /// Curve25519</A>, <A
37 /// HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium
38 /// commit afabd7e7386e1194</A> and <A HREF="https://tools.ietf.org/html/rfc7748">RFC
39 /// 7748, Elliptic Curves for Security</A>, Section 6.
40 /// \since Crypto++ 6.0
41 
42 #ifndef CRYPTOPP_NACL_H
43 #define CRYPTOPP_NACL_H
44 
45 #include "config.h"
46 #include "stdcpp.h"
47 
48 #if defined(NO_OS_DEPENDENCE)
49 # define CRYPTOPP_DISABLE_NACL 1
50 #endif
51 
52 #ifndef CRYPTOPP_DISABLE_NACL
53 
54 NAMESPACE_BEGIN(CryptoPP)
55 NAMESPACE_BEGIN(NaCl)
56 
57 /// \brief Hash size in bytes
58 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_hash documentation</A>
59 CRYPTOPP_CONSTANT(crypto_hash_BYTES = 64)
60 
61 /// \brief Key size in bytes
62 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>
63 CRYPTOPP_CONSTANT(crypto_stream_KEYBYTES = 32)
64 /// \brief Nonce size in bytes
65 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>
66 CRYPTOPP_CONSTANT(crypto_stream_NONCEBYTES = 24)
67 
68 /// \brief Key size in bytes
69 /// \sa <A HREF="https://nacl.cr.yp.to/auth.html">NaCl crypto_auth documentation</A>
70 CRYPTOPP_CONSTANT(crypto_auth_KEYBYTES = 32)
71 /// \brief Tag size in bytes
72 /// \sa <A HREF="https://nacl.cr.yp.to/auth.html">NaCl crypto_auth documentation</A>
73 CRYPTOPP_CONSTANT(crypto_auth_BYTES = 16)
74 
75 /// \brief Key size in bytes
76 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>
77 CRYPTOPP_CONSTANT(crypto_onetimeauth_KEYBYTES = 32)
78 /// \brief Tag size in bytes
79 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>
80 CRYPTOPP_CONSTANT(crypto_onetimeauth_BYTES = 16)
81 
82 /// \brief Key size in bytes
83 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>
84 CRYPTOPP_CONSTANT(crypto_secretbox_KEYBYTES = 32)
85 /// \brief Nonce size in bytes
86 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>
87 CRYPTOPP_CONSTANT(crypto_secretbox_NONCEBYTES = 24)
88 /// \brief Zero-padded message prefix in bytes
89 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>
90 CRYPTOPP_CONSTANT(crypto_secretbox_ZEROBYTES = 32)
91 /// \brief Zero-padded message prefix in bytes
92 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>
93 CRYPTOPP_CONSTANT(crypto_secretbox_BOXZEROBYTES = 16)
94 
95 /// \brief Private key size in bytes
96 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
97 CRYPTOPP_CONSTANT(crypto_box_SECRETKEYBYTES = 32)
98 /// \brief Public key size in bytes
99 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
100 CRYPTOPP_CONSTANT(crypto_box_PUBLICKEYBYTES = 32)
101 /// \brief Nonce size in bytes
102 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
103 CRYPTOPP_CONSTANT(crypto_box_NONCEBYTES = 24)
104 /// \brief Message 0-byte prefix in bytes
105 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
106 CRYPTOPP_CONSTANT(crypto_box_ZEROBYTES = 32)
107 /// \brief Open box 0-byte prefix in bytes
108 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
109 CRYPTOPP_CONSTANT(crypto_box_BOXZEROBYTES = 16)
110 /// \brief Precomputation 0-byte prefix in bytes in bytes
111 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
112 CRYPTOPP_CONSTANT(crypto_box_BEFORENMBYTES = 32)
113 /// \brief MAC size in bytes
114 /// \details crypto_box_MACBYTES was missing from tweetnacl.h. Its is defined as
115 /// crypto_box_curve25519xsalsa20poly1305_MACBYTES, which is defined as 16U.
116 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_box documentation</A>
117 CRYPTOPP_CONSTANT(crypto_box_MACBYTES = 16)
118 
119 /// \brief Private key size in bytes
120 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
121 CRYPTOPP_CONSTANT(crypto_sign_SECRETKEYBYTES = 64)
122 /// \brief Public key size in bytes
123 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
124 CRYPTOPP_CONSTANT(crypto_sign_PUBLICKEYBYTES = 32)
125 /// \brief Seed size in bytes
126 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
127 CRYPTOPP_CONSTANT(crypto_sign_SEEDBYTES = 32)
128 /// \brief Signature size in bytes
129 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
130 CRYPTOPP_CONSTANT(crypto_sign_BYTES = 64)
131 
132 /// \brief Group element size in bytes
133 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>
134 CRYPTOPP_CONSTANT(crypto_scalarmult_BYTES = 32)
135 /// \brief Integer size in bytes
136 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>
137 CRYPTOPP_CONSTANT(crypto_scalarmult_SCALARBYTES = 32)
138 
139 /// \brief Encrypt and authenticate a message
140 /// \param c output byte buffer
141 /// \param m input byte buffer
142 /// \param d size of the input byte buffer
143 /// \param n nonce byte buffer
144 /// \param y other's public key
145 /// \param x private key
146 /// \details crypto_box() uses crypto_box_curve25519xsalsa20poly1305
147 /// \returns 0 on success, non-0 otherwise
148 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
149 /// \since Crypto++ 6.0
150 int crypto_box(byte *c,const byte *m,word64 d,const byte *n,const byte *y,const byte *x);
151 
152 /// \brief Verify and decrypt a message
153 /// \param m output byte buffer
154 /// \param c input byte buffer
155 /// \param d size of the input byte buffer
156 /// \param n nonce byte buffer
157 /// \param y other's public key
158 /// \param x private key
159 /// \details crypto_box_open() uses crypto_box_curve25519xsalsa20poly1305
160 /// \returns 0 on success, non-0 otherwise
161 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
162 /// \since Crypto++ 6.0
163 int crypto_box_open(byte *m,const byte *c,word64 d,const byte *n,const byte *y,const byte *x);
164 
165 /// \brief Generate a keypair for encryption
166 /// \param y public key byte buffer
167 /// \param x private key byte buffer
168 /// \returns 0 on success, non-0 otherwise
169 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
170 /// \since Crypto++ 6.0
171 int crypto_box_keypair(byte *y,byte *x);
172 
173 /// \brief Encrypt and authenticate a message
174 /// \param k shared secret byte buffer
175 /// \param y other's public key
176 /// \param x private key
177 /// \details crypto_box_beforenm() performs message-independent precomputation to derive the key.
178 /// Once the key is derived multiple calls to crypto_box_afternm() can be made to process the message.
179 /// \returns 0 on success, non-0 otherwise
180 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
181 /// \since Crypto++ 6.0
182 int crypto_box_beforenm(byte *k,const byte *y,const byte *x);
183 
184 /// \brief Encrypt and authenticate a message
185 /// \param m output byte buffer
186 /// \param c input byte buffer
187 /// \param d size of the input byte buffer
188 /// \param n nonce byte buffer
189 /// \param k shared secret byte buffer
190 /// \details crypto_box_afternm() performs message-dependent computation using the derived the key.
191 /// Once the key is derived using crypto_box_beforenm() multiple calls to crypto_box_afternm()
192 /// can be made to process the message.
193 /// \returns 0 on success, non-0 otherwise
194 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
195 /// \since Crypto++ 6.0
196 int crypto_box_afternm(byte *c,const byte *m,word64 d,const byte *n,const byte *k);
197 
198 /// \brief Verify and decrypt a message
199 /// \param m output byte buffer
200 /// \param c input byte buffer
201 /// \param d size of the input byte buffer
202 /// \param n nonce byte buffer
203 /// \param k shared secret byte buffer
204 /// \details crypto_box_afternm() performs message-dependent computation using the derived the key.
205 /// Once the key is derived using crypto_box_beforenm() multiple calls to crypto_box_open_afternm()
206 /// can be made to process the message.
207 /// \returns 0 on success, non-0 otherwise
208 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>
209 /// \since Crypto++ 6.0
210 int crypto_box_open_afternm(byte *m,const byte *c,word64 d,const byte *n,const byte *k);
211 
212 /// \brief Encrypt and authenticate a message
213 /// \param c output byte buffer
214 /// \param m input byte buffer
215 /// \param d size of the input byte buffer
216 /// \param n nonce byte buffer
217 /// \param y other's public key
218 /// \param x private key
219 /// \details crypto_box() uses crypto_box_curve25519xsalsa20poly1305.
220 /// \details This version of crypto_box() does not check for small order elements. It can be unsafe
221 /// but it exists for backwards compatibility with downlevel clients. Without the compatibility
222 /// interop with early versions of NaCl, libsodium and other libraries does not exist. The
223 /// downlevel interop may also be needed of cryptocurrencies like Bitcoin, Ethereum, Monero
224 /// and Zcash.
225 /// \returns 0 on success, non-0 otherwise
226 /// \warning This version of crypto_box() does not check for small order elements. It should not
227 /// be used in new software.
228 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>,
229 /// <A HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A Microarchitectural
230 /// Side Channel Attack on Several Real-World Applications of Curve25519</A>,
231 /// <A HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium commit
232 /// afabd7e7386e1194</A>.
233 /// \since Crypto++ 6.0
234 int crypto_box_unchecked(byte *c,const byte *m,word64 d,const byte *n,const byte *y,const byte *x);
235 
236 /// \brief Verify and decrypt a message
237 /// \param m output byte buffer
238 /// \param c input byte buffer
239 /// \param d size of the input byte buffer
240 /// \param n nonce byte buffer
241 /// \param y other's public key
242 /// \param x private key
243 /// \details crypto_box_open() uses crypto_box_curve25519xsalsa20poly1305.
244 /// \details This version of crypto_box_open() does not check for small order elements. It can be unsafe
245 /// but it exists for backwards compatibility with downlevel clients. Without the compatibility
246 /// interop with early versions of NaCl, libsodium and other libraries does not exist. The
247 /// downlevel interop may also be needed of cryptocurrencies like Bitcoin, Ethereum, Monero
248 /// and Zcash.
249 /// \returns 0 on success, non-0 otherwise
250 /// \warning This version of crypto_box_open() does not check for small order elements. It should not
251 /// be used in new software.
252 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>,
253 /// <A HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A Microarchitectural
254 /// Side Channel Attack on Several Real-World Applications of Curve25519</A>,
255 /// <A HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium commit
256 /// afabd7e7386e1194</A>.
257 /// \since Crypto++ 6.0
258 int crypto_box_open_unchecked(byte *m,const byte *c,word64 d,const byte *n,const byte *y,const byte *x);
259 
260 /// \brief Encrypt and authenticate a message
261 /// \param k shared secret byte buffer
262 /// \param y other's public key
263 /// \param x private key
264 /// \details crypto_box_beforenm() performs message-independent precomputation to derive the key.
265 /// Once the key is derived multiple calls to crypto_box_afternm() can be made to process the message.
266 /// \details This version of crypto_box_beforenm() does not check for small order elements. It can be unsafe
267 /// but it exists for backwards compatibility with downlevel clients. Without the compatibility
268 /// interop with early versions of NaCl, libsodium and other libraries does not exist. The
269 /// downlevel interop may also be needed of cryptocurrencies like Bitcoin, Ethereum, Monero
270 /// and Zcash.
271 /// \returns 0 on success, non-0 otherwise
272 /// \warning This version of crypto_box_beforenm() does not check for small order elements. It should not
273 /// be used in new software.
274 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>,
275 /// <A HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A Microarchitectural
276 /// Side Channel Attack on Several Real-World Applications of Curve25519</A>,
277 /// <A HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium commit
278 /// afabd7e7386e1194</A>.
279 /// \since Crypto++ 6.0
280 int crypto_box_beforenm_unchecked(byte *k,const byte *y,const byte *x);
281 
282 /// \brief TODO
283 int crypto_core_salsa20(byte *out,const byte *in,const byte *k,const byte *c);
284 
285 /// \brief TODO
286 /// \returns 0 on success, non-0 otherwise
287 /// \since Crypto++ 6.0
288 int crypto_core_hsalsa20(byte *out,const byte *in,const byte *k,const byte *c);
289 
290 /// \brief Hash multiple blocks
291 /// \details crypto_hashblocks() uses crypto_hashblocks_sha512.
292 /// \returns 0 on success, non-0 otherwise
293 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_hash documentation</A>
294 /// \since Crypto++ 6.0
295 int crypto_hashblocks(byte *x,const byte *m,word64 n);
296 
297 /// \brief Hash a message
298 /// \details crypto_hash() uses crypto_hash_sha512.
299 /// \returns 0 on success, non-0 otherwise
300 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_hash documentation</A>
301 /// \since Crypto++ 6.0
302 int crypto_hash(byte *out,const byte *m,word64 n);
303 
304 /// \brief Create an authentication tag for a message
305 /// \details crypto_onetimeauth() uses crypto_onetimeauth_poly1305.
306 /// \returns 0 on success, non-0 otherwise
307 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>
308 /// \since Crypto++ 6.0
309 int crypto_onetimeauth(byte *out,const byte *m,word64 n,const byte *k);
310 
311 /// \brief Verify an authentication tag on a message
312 /// \returns 0 on success, non-0 otherwise
313 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>
314 /// \since Crypto++ 6.0
315 int crypto_onetimeauth_verify(const byte *h,const byte *m,word64 n,const byte *k);
316 
317 /// \brief Scalar multiplication of a point
318 /// \details crypto_scalarmult() uses crypto_scalarmult_curve25519
319 /// \returns 0 on success, non-0 otherwise
320 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>
321 /// \since Crypto++ 6.0
322 int crypto_scalarmult(byte *q,const byte *n,const byte *p);
323 
324 /// \brief Scalar multiplication of base point
325 /// \details crypto_scalarmult_base() uses crypto_scalarmult_curve25519
326 /// \returns 0 on success, non-0 otherwise
327 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>
328 /// \since Crypto++ 6.0
329 int crypto_scalarmult_base(byte *q,const byte *n);
330 
331 /// \brief Encrypt and authenticate a message
332 /// \details crypto_secretbox() uses a symmetric key to encrypt and authenticate a message.
333 /// \returns 0 on success, non-0 otherwise
334 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>
335 /// \since Crypto++ 6.0
336 int crypto_secretbox(byte *c,const byte *m,word64 d,const byte *n,const byte *k);
337 
338 /// \brief Verify and decrypt a message
339 /// \returns 0 on success, non-0 otherwise
340 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>
341 /// \since Crypto++ 6.0
342 int crypto_secretbox_open(byte *m,const byte *c,word64 d,const byte *n,const byte *k);
343 
344 /// \brief Sign a message
345 /// \param sm output byte buffer
346 /// \param smlen size of the output byte buffer
347 /// \param m input byte buffer
348 /// \param n size of the input byte buffer
349 /// \param sk private key
350 /// \details crypto_sign() uses crypto_sign_ed25519.
351 /// \returns 0 on success, non-0 otherwise
352 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
353 /// \since Crypto++ 6.0
354 int crypto_sign(byte *sm,word64 *smlen,const byte *m,word64 n,const byte *sk);
355 
356 /// \brief Verify a message
357 /// \param m output byte buffer
358 /// \param mlen size of the output byte buffer
359 /// \param sm input byte buffer
360 /// \param n size of the input byte buffer
361 /// \param pk public key
362 /// \returns 0 on success, non-0 otherwise
363 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
364 /// \since Crypto++ 6.0
365 int crypto_sign_open(byte *m,word64 *mlen,const byte *sm,word64 n,const byte *pk);
366 
367 /// \brief Generate a keypair for signing
368 /// \param pk public key byte buffer
369 /// \param sk private key byte buffer
370 /// \details crypto_sign_keypair() creates an ed25519 keypair.
371 /// \returns 0 on success, non-0 otherwise
372 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>
373 /// \since Crypto++ 6.0
374 int crypto_sign_keypair(byte *pk, byte *sk);
375 
376 /// \brief Produce a keystream using XSalsa20
377 /// \details crypto_stream() uses crypto_stream_xsalsa20
378 /// \returns 0 on success, non-0 otherwise
379 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>
380 /// \since Crypto++ 6.0
381 int crypto_stream(byte *c,word64 d,const byte *n,const byte *k);
382 
383 /// \brief Encrypt a message using XSalsa20
384 /// \returns 0 on success, non-0 otherwise
385 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>
386 /// \since Crypto++ 6.0
387 int crypto_stream_xor(byte *c,const byte *m,word64 d,const byte *n,const byte *k);
388 
389 /// \brief Produce a keystream using Salsa20
390 /// \returns 0 on success, non-0 otherwise
391 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>
392 /// \since Crypto++ 6.0
393 int crypto_stream_salsa20(byte *c,word64 d,const byte *n,const byte *k);
394 
395 /// \brief Encrypt a message using Salsa20
396 /// \returns 0 on success, non-0 otherwise
397 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>
398 /// \since Crypto++ 6.0
399 int crypto_stream_salsa20_xor(byte *c,const byte *m,word64 b,const byte *n,const byte *k);
400 
401 /// \brief Compare 16-byte buffers
402 /// \returns 0 on success, non-0 otherwise
403 /// \sa <A HREF="https://nacl.cr.yp.to/verify.html">NaCl crypto_verify documentation</A>
404 /// \since Crypto++ 6.0
405 int crypto_verify_16(const byte *x,const byte *y);
406 
407 /// \brief Compare 32-byte buffers
408 /// \returns 0 on success, non-0 otherwise
409 /// \sa <A HREF="https://nacl.cr.yp.to/verify.html">NaCl crypto_verify documentation</A>
410 /// \since Crypto++ 6.0
411 int crypto_verify_32(const byte *x,const byte *y);
412 
413 NAMESPACE_END // CryptoPP
414 NAMESPACE_END // NaCl
415 
416 #endif // CRYPTOPP_DISABLE_NACL
417 #endif // CRYPTOPP_NACL_H
int crypto_stream_xor(byte *c, const byte *m, word64 d, const byte *n, const byte *k)
Encrypt a message using XSalsa20.
Definition: tweetnacl.cpp:187
int crypto_box_keypair(byte *y, byte *x)
Generate a keypair for encryption.
Definition: tweetnacl.cpp:508
Namespace containing NaCl library functions.
Definition: cryptlib.h:543
int crypto_hash(byte *out, const byte *m, word64 n)
Hash a message.
Definition: tweetnacl.cpp:645
int crypto_box_beforenm_unchecked(byte *k, const byte *y, const byte *x)
Encrypt and authenticate a message.
Definition: tweetnacl.cpp:525
int crypto_hashblocks(byte *x, const byte *m, word64 n)
Hash multiple blocks.
Definition: tweetnacl.cpp:602
int crypto_box(byte *c, const byte *m, word64 d, const byte *n, const byte *y, const byte *x)
Encrypt and authenticate a message.
Definition: tweetnacl.cpp:542
int crypto_core_salsa20(byte *out, const byte *in, const byte *k, const byte *c)
TODO.
Definition: tweetnacl.cpp:134
int crypto_box_afternm(byte *c, const byte *m, word64 d, const byte *n, const byte *k)
Encrypt and authenticate a message.
Definition: tweetnacl.cpp:532
Library configuration file.
Common C++ header files.
int crypto_box_open_afternm(byte *m, const byte *c, word64 d, const byte *n, const byte *k)
Verify and decrypt a message.
Definition: tweetnacl.cpp:537
int crypto_box_open_unchecked(byte *m, const byte *c, word64 d, const byte *n, const byte *y, const byte *x)
Verify and decrypt a message.
Definition: tweetnacl.cpp:563
int crypto_sign_open(byte *m, word64 *mlen, const byte *sm, word64 n, const byte *pk)
Verify a message.
Definition: tweetnacl.cpp:862
int crypto_sign(byte *sm, word64 *smlen, const byte *m, word64 n, const byte *sk)
Sign a message.
Definition: tweetnacl.cpp:794
int crypto_sign_keypair(byte *pk, byte *sk)
Generate a keypair for signing.
Definition: tweetnacl.cpp:739
int crypto_stream_salsa20_xor(byte *c, const byte *m, word64 b, const byte *n, const byte *k)
Encrypt a message using Salsa20.
Definition: tweetnacl.cpp:148
int crypto_onetimeauth(byte *out, const byte *m, word64 n, const byte *k)
Create an authentication tag for a message.
Definition: tweetnacl.cpp:208
int crypto_verify_16(const byte *x, const byte *y)
Compare 16-byte buffers.
Definition: tweetnacl.cpp:84
int crypto_secretbox_open(byte *m, const byte *c, word64 d, const byte *n, const byte *k)
Verify and decrypt a message.
Definition: tweetnacl.cpp:278
int crypto_verify_32(const byte *x, const byte *y)
Compare 32-byte buffers.
Definition: tweetnacl.cpp:89
int crypto_stream(byte *c, word64 d, const byte *n, const byte *k)
Produce a keystream using XSalsa20.
Definition: tweetnacl.cpp:180
int crypto_core_hsalsa20(byte *out, const byte *in, const byte *k, const byte *c)
TODO.
Definition: tweetnacl.cpp:140
int crypto_box_unchecked(byte *c, const byte *m, word64 d, const byte *n, const byte *y, const byte *x)
Encrypt and authenticate a message.
Definition: tweetnacl.cpp:549
int crypto_scalarmult_base(byte *q, const byte *n)
Scalar multiplication of base point.
Definition: tweetnacl.cpp:503
Crypto++ library namespace.
int crypto_box_open(byte *m, const byte *c, word64 d, const byte *n, const byte *y, const byte *x)
Verify and decrypt a message.
Definition: tweetnacl.cpp:556
int crypto_scalarmult(byte *q, const byte *n, const byte *p)
Scalar multiplication of a point.
Definition: tweetnacl.cpp:452
int crypto_box_beforenm(byte *k, const byte *y, const byte *x)
Encrypt and authenticate a message.
Definition: tweetnacl.cpp:516
int crypto_secretbox(byte *c, const byte *m, word64 d, const byte *n, const byte *k)
Encrypt and authenticate a message.
Definition: tweetnacl.cpp:268
int crypto_stream_salsa20(byte *c, word64 d, const byte *n, const byte *k)
Produce a keystream using Salsa20.
Definition: tweetnacl.cpp:175
int crypto_onetimeauth_verify(const byte *h, const byte *m, word64 n, const byte *k)
Verify an authentication tag on a message.
Definition: tweetnacl.cpp:261