Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:05

0001 // naclite.h - written and placed in the public domain by Jeffrey Walton

0002 //          based on public domain NaCl source code written by

0003 //          Daniel J. Bernstein, Bernard van Gastel, Wesley Janssen,

0004 //          Tanja Lange, Peter Schwabe and Sjaak Smetsers.

0005 
0006 // The Tweet API was added to the Crypto++ library to cross-validate results.

0007 // We debated over putting it in the Test namespace, but settled for the NaCl

0008 // namespace to segregate it from other parts of the library.

0009 
0010 /// \file naclite.h

0011 /// \brief Crypto++ interface to TweetNaCl library (20140917)

0012 /// \details TweetNaCl is a compact reimplementation of the NaCl library

0013 ///   by Daniel J. Bernstein, Bernard van Gastel, Wesley Janssen, Tanja

0014 ///   Lange, Peter Schwabe and Sjaak Smetsers. The library is less than

0015 ///   20 KB in size and provides 25 of the NaCl library functions.

0016 /// \details The compact library uses curve25519, XSalsa20, Poly1305 and

0017 ///   SHA-512 as default primitives, and includes both x25519 key exchange

0018 ///   and ed25519 signatures. The complete list of functions can be found

0019 ///   in <A

0020 ///   HREF="https://tweetnacl.cr.yp.to/tweetnacl-20140917.pdf">TweetNaCl:

0021 ///   A crypto library in 100 tweets</A> (20140917), Table 1, page 5.

0022 /// \details Crypto++ rejects small order elements using libsodium's

0023 ///   blacklist. The TweetNaCl library allowed them but the library predated

0024 ///   the attack. If you wish to allow small elements then use the "unchecked"

0025 ///   versions of crypto_box_unchecked, crypto_box_open_unchecked and

0026 ///   crypto_box_beforenm_unchecked.

0027 /// \details TweetNaCl is well written but not well optimzed. It runs about

0028 ///   10x slower than optimized routines from libsodium. However, the library

0029 ///   is still 2x to 4x faster than the algorithms NaCl was designed to replace

0030 ///   and allows cross-checking results from an independent implementation.

0031 /// \details The Crypto++ wrapper for TweetNaCl requires OS features. That is,

0032 ///   <tt>NO_OS_DEPENDENCE</tt> cannot be defined. It is due to TweetNaCl's

0033 ///   internal function <tt>randombytes</tt>. Crypto++ used

0034 ///   <tt>DefaultAutoSeededRNG</tt> within <tt>randombytes</tt>, so OS

0035 ///   integration must be enabled. You can use another generator like

0036 ///   <tt>RDRAND</tt> to avoid the restriction.

0037 /// \sa <A HREF="https://cr.yp.to/highspeed/coolnacl-20120725.pdf">The security

0038 ///   impact of a new cryptographic library</A>, <A

0039 ///   HREF="https://tweetnacl.cr.yp.to/tweetnacl-20140917.pdf">TweetNaCl:

0040 ///   A crypto library in 100 tweets</A> (20140917), <A

0041 ///   HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You:

0042 ///   A Microarchitectural Side Channel Attack on Several Real-World

0043 ///   Applications of Curve25519</A>, <A

0044 ///   HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium

0045 ///   commit afabd7e7386e1194</A> and <A

0046 ///   HREF="https://tools.ietf.org/html/rfc7748">RFC 7748, Elliptic Curves for

0047 ///   Security</A>, Section 6.

0048 /// \since Crypto++ 6.0

0049 
0050 #ifndef CRYPTOPP_NACL_H
0051 #define CRYPTOPP_NACL_H
0052 
0053 #include "config.h"
0054 #include "stdcpp.h"
0055 
0056 #if defined(NO_OS_DEPENDENCE) || !defined(OS_RNG_AVAILABLE)
0057 # define CRYPTOPP_DISABLE_NACL 1
0058 #endif
0059 
0060 #ifndef CRYPTOPP_DISABLE_NACL
0061 
0062 NAMESPACE_BEGIN(CryptoPP)
0063 NAMESPACE_BEGIN(NaCl)
0064 
0065 /// \brief Hash size in bytes

0066 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_hash documentation</A>

0067 CRYPTOPP_CONSTANT(crypto_hash_BYTES = 64);
0068 
0069 /// \brief Key size in bytes

0070 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>

0071 CRYPTOPP_CONSTANT(crypto_stream_KEYBYTES = 32);
0072 /// \brief Nonce size in bytes

0073 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>

0074 CRYPTOPP_CONSTANT(crypto_stream_NONCEBYTES = 24);
0075 
0076 /// \brief Key size in bytes

0077 /// \sa <A HREF="https://nacl.cr.yp.to/auth.html">NaCl crypto_auth documentation</A>

0078 CRYPTOPP_CONSTANT(crypto_auth_KEYBYTES = 32);
0079 /// \brief Tag size in bytes

0080 /// \sa <A HREF="https://nacl.cr.yp.to/auth.html">NaCl crypto_auth documentation</A>

0081 CRYPTOPP_CONSTANT(crypto_auth_BYTES = 16);
0082 
0083 /// \brief Key size in bytes

0084 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>

0085 CRYPTOPP_CONSTANT(crypto_onetimeauth_KEYBYTES = 32);
0086 /// \brief Tag size in bytes

0087 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>

0088 CRYPTOPP_CONSTANT(crypto_onetimeauth_BYTES = 16);
0089 
0090 /// \brief Key size in bytes

0091 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>

0092 CRYPTOPP_CONSTANT(crypto_secretbox_KEYBYTES = 32);
0093 /// \brief Nonce size in bytes

0094 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>

0095 CRYPTOPP_CONSTANT(crypto_secretbox_NONCEBYTES = 24);
0096 /// \brief Zero-padded message prefix in bytes

0097 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>

0098 CRYPTOPP_CONSTANT(crypto_secretbox_ZEROBYTES = 32);
0099 /// \brief Zero-padded message prefix in bytes

0100 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>

0101 CRYPTOPP_CONSTANT(crypto_secretbox_BOXZEROBYTES = 16);
0102 
0103 /// \brief Private key size in bytes

0104 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0105 CRYPTOPP_CONSTANT(crypto_box_SECRETKEYBYTES = 32);
0106 /// \brief Public key size in bytes

0107 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0108 CRYPTOPP_CONSTANT(crypto_box_PUBLICKEYBYTES = 32);
0109 /// \brief Nonce size in bytes

0110 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0111 CRYPTOPP_CONSTANT(crypto_box_NONCEBYTES = 24);
0112 /// \brief Message 0-byte prefix in bytes

0113 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0114 CRYPTOPP_CONSTANT(crypto_box_ZEROBYTES = 32);
0115 /// \brief Open box 0-byte prefix in bytes

0116 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0117 CRYPTOPP_CONSTANT(crypto_box_BOXZEROBYTES = 16);
0118 /// \brief Precomputation 0-byte prefix in bytes in bytes

0119 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0120 CRYPTOPP_CONSTANT(crypto_box_BEFORENMBYTES = 32);
0121 /// \brief MAC size in bytes

0122 /// \details crypto_box_MACBYTES was missing from tweetnacl.h. Its is defined as

0123 ///   crypto_box_curve25519xsalsa20poly1305_MACBYTES, which is defined as 16U.

0124 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_box documentation</A>

0125 CRYPTOPP_CONSTANT(crypto_box_MACBYTES = 16);
0126 
0127 /// \brief Private key size in bytes

0128 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0129 CRYPTOPP_CONSTANT(crypto_sign_SECRETKEYBYTES = 64);
0130 /// \brief Public key size in bytes

0131 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0132 CRYPTOPP_CONSTANT(crypto_sign_PUBLICKEYBYTES = 32);
0133 /// \brief Seed size in bytes

0134 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0135 CRYPTOPP_CONSTANT(crypto_sign_SEEDBYTES = 32);
0136 /// \brief Signature size in bytes

0137 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0138 CRYPTOPP_CONSTANT(crypto_sign_BYTES = 64);
0139 
0140 /// \brief Group element size in bytes

0141 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>

0142 CRYPTOPP_CONSTANT(crypto_scalarmult_BYTES = 32);
0143 /// \brief Integer size in bytes

0144 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>

0145 CRYPTOPP_CONSTANT(crypto_scalarmult_SCALARBYTES = 32);
0146 
0147 /// \brief Encrypt and authenticate a message

0148 /// \param c output byte buffer

0149 /// \param m input byte buffer

0150 /// \param d size of the input byte buffer

0151 /// \param n nonce byte buffer

0152 /// \param y other's public key

0153 /// \param x private key

0154 /// \details crypto_box() uses crypto_box_curve25519xsalsa20poly1305

0155 /// \return 0 on success, non-0 otherwise

0156 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0157 /// \since Crypto++ 6.0

0158 int crypto_box(byte *c,const byte *m,word64 d,const byte *n,const byte *y,const byte *x);
0159 
0160 /// \brief Verify and decrypt a message

0161 /// \param m output byte buffer

0162 /// \param c input byte buffer

0163 /// \param d size of the input byte buffer

0164 /// \param n nonce byte buffer

0165 /// \param y other's public key

0166 /// \param x private key

0167 /// \details crypto_box_open() uses crypto_box_curve25519xsalsa20poly1305

0168 /// \return 0 on success, non-0 otherwise

0169 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0170 /// \since Crypto++ 6.0

0171 int crypto_box_open(byte *m,const byte *c,word64 d,const byte *n,const byte *y,const byte *x);
0172 
0173 /// \brief Generate a keypair for encryption

0174 /// \param y public key byte buffer

0175 /// \param x private key byte buffer

0176 /// \return 0 on success, non-0 otherwise

0177 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0178 /// \since Crypto++ 6.0

0179 int crypto_box_keypair(byte *y,byte *x);
0180 
0181 /// \brief Encrypt and authenticate a message

0182 /// \param k shared secret byte buffer

0183 /// \param y other's public key

0184 /// \param x private key

0185 /// \details crypto_box_beforenm() performs message-independent precomputation to derive the key.

0186 ///   Once the key is derived multiple calls to crypto_box_afternm() can be made to process the message.

0187 /// \return 0 on success, non-0 otherwise

0188 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0189 /// \since Crypto++ 6.0

0190 int crypto_box_beforenm(byte *k,const byte *y,const byte *x);
0191 
0192 /// \brief Encrypt and authenticate a message

0193 /// \param m output byte buffer

0194 /// \param c input byte buffer

0195 /// \param d size of the input byte buffer

0196 /// \param n nonce byte buffer

0197 /// \param k shared secret byte buffer

0198 /// \details crypto_box_afternm() performs message-dependent computation using the derived the key.

0199 ///   Once the key is derived using crypto_box_beforenm() multiple calls to crypto_box_afternm()

0200 ///   can be made to process the message.

0201 /// \return 0 on success, non-0 otherwise

0202 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0203 /// \since Crypto++ 6.0

0204 int crypto_box_afternm(byte *c,const byte *m,word64 d,const byte *n,const byte *k);
0205 
0206 /// \brief Verify and decrypt a message

0207 /// \param m output byte buffer

0208 /// \param c input byte buffer

0209 /// \param d size of the input byte buffer

0210 /// \param n nonce byte buffer

0211 /// \param k shared secret byte buffer

0212 /// \details crypto_box_afternm() performs message-dependent computation using the derived the key.

0213 ///   Once the key is derived using crypto_box_beforenm() multiple calls to crypto_box_open_afternm()

0214 ///   can be made to process the message.

0215 /// \return 0 on success, non-0 otherwise

0216 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>

0217 /// \since Crypto++ 6.0

0218 int crypto_box_open_afternm(byte *m,const byte *c,word64 d,const byte *n,const byte *k);
0219 
0220 /// \brief Encrypt and authenticate a message

0221 /// \param c output byte buffer

0222 /// \param m input byte buffer

0223 /// \param d size of the input byte buffer

0224 /// \param n nonce byte buffer

0225 /// \param y other's public key

0226 /// \param x private key

0227 /// \details crypto_box() uses crypto_box_curve25519xsalsa20poly1305.

0228 /// \details This version of crypto_box() does not check for small order elements. It can be unsafe

0229 ///   but it exists for backwards compatibility with downlevel clients. Without the compatibility

0230 ///   interop with early versions of NaCl, libsodium and other libraries does not exist. The

0231 ///   downlevel interop may also be needed of cryptocurrencies like Bitcoin, Ethereum, Monero

0232 ///   and Zcash.

0233 /// \return 0 on success, non-0 otherwise

0234 /// \warning This version of crypto_box() does not check for small order elements. It should not

0235 ///   be used in new software.

0236 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>,

0237 ///   <A HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A Microarchitectural

0238 ///   Side Channel Attack on Several Real-World Applications of Curve25519</A>,

0239 ///   <A HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium commit

0240 ///   afabd7e7386e1194</A>.

0241 /// \since Crypto++ 6.0

0242 int crypto_box_unchecked(byte *c,const byte *m,word64 d,const byte *n,const byte *y,const byte *x);
0243 
0244 /// \brief Verify and decrypt a message

0245 /// \param m output byte buffer

0246 /// \param c input byte buffer

0247 /// \param d size of the input byte buffer

0248 /// \param n nonce byte buffer

0249 /// \param y other's public key

0250 /// \param x private key

0251 /// \details crypto_box_open() uses crypto_box_curve25519xsalsa20poly1305.

0252 /// \details This version of crypto_box_open() does not check for small order elements. It can be unsafe

0253 ///   but it exists for backwards compatibility with downlevel clients. Without the compatibility

0254 ///   interop with early versions of NaCl, libsodium and other libraries does not exist. The

0255 ///   downlevel interop may also be needed of cryptocurrencies like Bitcoin, Ethereum, Monero

0256 ///   and Zcash.

0257 /// \return 0 on success, non-0 otherwise

0258 /// \warning This version of crypto_box_open() does not check for small order elements. It should not

0259 ///   be used in new software.

0260 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>,

0261 ///   <A HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A Microarchitectural

0262 ///   Side Channel Attack on Several Real-World Applications of Curve25519</A>,

0263 ///   <A HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium commit

0264 ///   afabd7e7386e1194</A>.

0265 /// \since Crypto++ 6.0

0266 int crypto_box_open_unchecked(byte *m,const byte *c,word64 d,const byte *n,const byte *y,const byte *x);
0267 
0268 /// \brief Encrypt and authenticate a message

0269 /// \param k shared secret byte buffer

0270 /// \param y other's public key

0271 /// \param x private key

0272 /// \details crypto_box_beforenm() performs message-independent precomputation to derive the key.

0273 ///   Once the key is derived multiple calls to crypto_box_afternm() can be made to process the message.

0274 /// \details This version of crypto_box_beforenm() does not check for small order elements. It can be unsafe

0275 ///   but it exists for backwards compatibility with downlevel clients. Without the compatibility

0276 ///   interop with early versions of NaCl, libsodium and other libraries does not exist. The

0277 ///   downlevel interop may also be needed of cryptocurrencies like Bitcoin, Ethereum, Monero

0278 ///   and Zcash.

0279 /// \return 0 on success, non-0 otherwise

0280 /// \warning This version of crypto_box_beforenm() does not check for small order elements. It should not

0281 ///   be used in new software.

0282 /// \sa <A HREF="https://nacl.cr.yp.to/box.html">NaCl crypto_box documentation</A>,

0283 ///   <A HREF="https://eprint.iacr.org/2017/806.pdf">May the Fourth Be With You: A Microarchitectural

0284 ///   Side Channel Attack on Several Real-World Applications of Curve25519</A>,

0285 ///   <A HREF="https://github.com/jedisct1/libsodium/commit/afabd7e7386e1194">libsodium commit

0286 ///   afabd7e7386e1194</A>.

0287 /// \since Crypto++ 6.0

0288 int crypto_box_beforenm_unchecked(byte *k,const byte *y,const byte *x);
0289 
0290 /// \brief TODO

0291 int crypto_core_salsa20(byte *out,const byte *in,const byte *k,const byte *c);
0292 
0293 /// \brief TODO

0294 /// \return 0 on success, non-0 otherwise

0295 /// \since Crypto++ 6.0

0296 int crypto_core_hsalsa20(byte *out,const byte *in,const byte *k,const byte *c);
0297 
0298 /// \brief Hash multiple blocks

0299 /// \details crypto_hashblocks() uses crypto_hashblocks_sha512.

0300 /// \return 0 on success, non-0 otherwise

0301 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_hash documentation</A>

0302 /// \since Crypto++ 6.0

0303 int crypto_hashblocks(byte *x,const byte *m,word64 n);
0304 
0305 /// \brief Hash a message

0306 /// \details crypto_hash() uses crypto_hash_sha512.

0307 /// \return 0 on success, non-0 otherwise

0308 /// \sa <A HREF="https://nacl.cr.yp.to/hash.html">NaCl crypto_hash documentation</A>

0309 /// \since Crypto++ 6.0

0310 int crypto_hash(byte *out,const byte *m,word64 n);
0311 
0312 /// \brief Create an authentication tag for a message

0313 /// \details crypto_onetimeauth() uses crypto_onetimeauth_poly1305.

0314 /// \return 0 on success, non-0 otherwise

0315 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>

0316 /// \since Crypto++ 6.0

0317 int crypto_onetimeauth(byte *out,const byte *m,word64 n,const byte *k);
0318 
0319 /// \brief Verify an authentication tag on a message

0320 /// \return 0 on success, non-0 otherwise

0321 /// \sa <A HREF="https://nacl.cr.yp.to/onetimeauth.html">NaCl crypto_onetimeauth documentation</A>

0322 /// \since Crypto++ 6.0

0323 int crypto_onetimeauth_verify(const byte *h,const byte *m,word64 n,const byte *k);
0324 
0325 /// \brief Scalar multiplication of a point

0326 /// \details crypto_scalarmult() uses crypto_scalarmult_curve25519

0327 /// \return 0 on success, non-0 otherwise

0328 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>

0329 /// \since Crypto++ 6.0

0330 int crypto_scalarmult(byte *q,const byte *n,const byte *p);
0331 
0332 /// \brief Scalar multiplication of base point

0333 /// \details crypto_scalarmult_base() uses crypto_scalarmult_curve25519

0334 /// \return 0 on success, non-0 otherwise

0335 /// \sa <A HREF="https://nacl.cr.yp.to/scalarmult.html">NaCl crypto_scalarmult documentation</A>

0336 /// \since Crypto++ 6.0

0337 int crypto_scalarmult_base(byte *q,const byte *n);
0338 
0339 /// \brief Encrypt and authenticate a message

0340 /// \details crypto_secretbox() uses a symmetric key to encrypt and authenticate a message.

0341 /// \return 0 on success, non-0 otherwise

0342 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>

0343 /// \since Crypto++ 6.0

0344 int crypto_secretbox(byte *c,const byte *m,word64 d,const byte *n,const byte *k);
0345 
0346 /// \brief Verify and decrypt a message

0347 /// \return 0 on success, non-0 otherwise

0348 /// \sa <A HREF="https://nacl.cr.yp.to/secretbox.html">NaCl crypto_secretbox documentation</A>

0349 /// \since Crypto++ 6.0

0350 int crypto_secretbox_open(byte *m,const byte *c,word64 d,const byte *n,const byte *k);
0351 
0352 /// \brief Sign a message

0353 /// \param sm output byte buffer

0354 /// \param smlen size of the output byte buffer

0355 /// \param m input byte buffer

0356 /// \param n size of the input byte buffer

0357 /// \param sk private key

0358 /// \details crypto_sign() uses crypto_sign_ed25519.

0359 /// \return 0 on success, non-0 otherwise

0360 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0361 /// \since Crypto++ 6.0

0362 int crypto_sign(byte *sm,word64 *smlen,const byte *m,word64 n,const byte *sk);
0363 
0364 /// \brief Verify a message

0365 /// \param m output byte buffer

0366 /// \param mlen size of the output byte buffer

0367 /// \param sm input byte buffer

0368 /// \param n size of the input byte buffer

0369 /// \param pk public key

0370 /// \return 0 on success, non-0 otherwise

0371 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0372 /// \since Crypto++ 6.0

0373 int crypto_sign_open(byte *m,word64 *mlen,const byte *sm,word64 n,const byte *pk);
0374 
0375 /// \brief Generate a keypair for signing

0376 /// \param pk public key byte buffer

0377 /// \param sk private key byte buffer

0378 /// \details crypto_sign_keypair() creates an ed25519 keypair.

0379 /// \return 0 on success, non-0 otherwise

0380 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0381 /// \since Crypto++ 6.0

0382 int crypto_sign_keypair(byte *pk, byte *sk);
0383 
0384 /// \brief Calculate a public key from a secret key

0385 /// \param pk public key byte buffer

0386 /// \param sk private key byte buffer

0387 /// \details crypto_sign_sk2pk() creates an ed25519 public key from an existing

0388 ///   32-byte secret key. The function does not backfill the tail bytes of the

0389 ///   secret key with the calculated public key.

0390 /// \details crypto_sign_sk2pk() is not part of libsodium or Tweet API. It was

0391 ///   added for interop with some anonymous routing protocols.

0392 /// \return 0 on success, non-0 otherwise

0393 /// \sa <A HREF="https://nacl.cr.yp.to/sign.html">NaCl crypto_sign documentation</A>

0394 /// \since Crypto++ 8.0

0395 int crypto_sign_sk2pk(byte *pk, const byte *sk);
0396 
0397 /// \brief Produce a keystream using XSalsa20

0398 /// \details crypto_stream() uses crypto_stream_xsalsa20

0399 /// \return 0 on success, non-0 otherwise

0400 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>

0401 /// \since Crypto++ 6.0

0402 int crypto_stream(byte *c,word64 d,const byte *n,const byte *k);
0403 
0404 /// \brief Encrypt a message using XSalsa20

0405 /// \return 0 on success, non-0 otherwise

0406 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>

0407 /// \since Crypto++ 6.0

0408 int crypto_stream_xor(byte *c,const byte *m,word64 d,const byte *n,const byte *k);
0409 
0410 /// \brief Produce a keystream using Salsa20

0411 /// \return 0 on success, non-0 otherwise

0412 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>

0413 /// \since Crypto++ 6.0

0414 int crypto_stream_salsa20(byte *c,word64 d,const byte *n,const byte *k);
0415 
0416 /// \brief Encrypt a message using Salsa20

0417 /// \return 0 on success, non-0 otherwise

0418 /// \sa <A HREF="https://nacl.cr.yp.to/stream.html">NaCl crypto_stream documentation</A>

0419 /// \since Crypto++ 6.0

0420 int crypto_stream_salsa20_xor(byte *c,const byte *m,word64 b,const byte *n,const byte *k);
0421 
0422 /// \brief Compare 16-byte buffers

0423 /// \return 0 on success, non-0 otherwise

0424 /// \sa <A HREF="https://nacl.cr.yp.to/verify.html">NaCl crypto_verify documentation</A>

0425 /// \since Crypto++ 6.0

0426 int crypto_verify_16(const byte *x,const byte *y);
0427 
0428 /// \brief Compare 32-byte buffers

0429 /// \return 0 on success, non-0 otherwise

0430 /// \sa <A HREF="https://nacl.cr.yp.to/verify.html">NaCl crypto_verify documentation</A>

0431 /// \since Crypto++ 6.0

0432 int crypto_verify_32(const byte *x,const byte *y);
0433 
0434 NAMESPACE_END  // CryptoPP

0435 NAMESPACE_END  // NaCl

0436 
0437 #endif  // CRYPTOPP_DISABLE_NACL

0438 #endif  // CRYPTOPP_NACL_H