1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 
4 /* The implementation is based on:
5  * "Salsa20 specification", http://cr.yp.to/snuffle/spec.pdf
6  * and salsa20-ref.c version 20051118
7  * Public domain from D. J. Bernstein
8  */
9 
10 #include "tomcrypt_private.h"
11 
12 #ifdef LTC_SALSA20
13 
14 /**
15   Generate a stream of random bytes via Salsa20
16   @param st      The Salsa20 state
17   @param out     [out] The output buffer
18   @param outlen  The output length
19   @return CRYPT_OK on success
20  */
salsa20_keystream(salsa20_state * st,unsigned char * out,unsigned long outlen)21 int salsa20_keystream(salsa20_state *st, unsigned char *out, unsigned long outlen)
22 {
23    if (outlen == 0) return CRYPT_OK; /* nothing to do */
24    LTC_ARGCHK(out != NULL);
25    XMEMSET(out, 0, outlen);
26    return salsa20_crypt(st, out, outlen, out);
27 }
28 
29 #endif
30