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