1 // SPDX-License-Identifier: BSD-2-Clause
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 *
4 * LibTomCrypt is a library that provides various cryptographic
5 * algorithms in a highly modular and flexible manner.
6 *
7 * The library is free for all purposes without any express
8 * guarantee it works.
9 */
10
11 /* The implementation is based on:
12 * "Salsa20 specification", http://cr.yp.to/snuffle/spec.pdf
13 * and salsa20-ref.c version 20051118
14 * Public domain from D. J. Bernstein
15 */
16
17 #include "tomcrypt_private.h"
18
19 #ifdef LTC_SALSA20
20
21 /**
22 Generate a stream of random bytes via Salsa20
23 @param st The Salsa20 state
24 @param out [out] The output buffer
25 @param outlen The output length
26 @return CRYPT_OK on success
27 */
salsa20_keystream(salsa20_state * st,unsigned char * out,unsigned long outlen)28 int salsa20_keystream(salsa20_state *st, unsigned char *out, unsigned long outlen)
29 {
30 if (outlen == 0) return CRYPT_OK; /* nothing to do */
31 LTC_ARGCHK(out != NULL);
32 XMEMSET(out, 0, outlen);
33 return salsa20_crypt(st, out, outlen, out);
34 }
35
36 #endif
37
38 /* ref: $Format:%D$ */
39 /* git commit: $Format:%H$ */
40 /* commit time: $Format:%ai$ */
41