1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
10 /* The implementation is based on:
11 * chacha-ref.c version 20080118
12 * Public domain from D. J. Bernstein
20 Generate a stream of random bytes via ChaCha
21 @param st The ChaCha20 state
22 @param out [out] The output buffer
23 @param outlen The output length
24 @return CRYPT_OK on success
26 int chacha_keystream(chacha_state *st, unsigned char *out, unsigned long outlen)
28 if (outlen == 0) return CRYPT_OK; /* nothing to do */
29 LTC_ARGCHK(out != NULL);
30 XMEMSET(out, 0, outlen);
31 return chacha_crypt(st, out, outlen, out);
36 /* ref: $Format:%D$ */
37 /* git commit: $Format:%H$ */
38 /* commit time: $Format:%ai$ */