added chacha_done
This commit is contained in:
parent
ff6abc776c
commit
c8cb714e08
@ -35,6 +35,7 @@ int chacha20poly1305_done(chachapoly_state *st, unsigned char *tag, unsigned lon
|
||||
STORE64L(st->ctlen, buf + 8);
|
||||
if ((err = poly1305_process(&st->poly, buf, 16)) != CRYPT_OK) return err;
|
||||
if ((err = poly1305_done(&st->poly, tag, taglen)) != CRYPT_OK) return err;
|
||||
if ((err = chacha_done(&st->chacha)) != CRYPT_OK) return err;
|
||||
return CRYPT_OK;
|
||||
}
|
||||
|
||||
|
@ -954,6 +954,7 @@ int chacha_ivctr32(chacha_state *st, const unsigned char *iv, unsigned long ivle
|
||||
int chacha_ivctr64(chacha_state *st, const unsigned char *iv, unsigned long ivlen, ulong64 counter);
|
||||
int chacha_crypt(chacha_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out);
|
||||
int chacha_keystream(chacha_state *st, unsigned char *out, unsigned long outlen);
|
||||
int chacha_done(chacha_state *st);
|
||||
int chacha_test(void);
|
||||
|
||||
#endif /* LTC_CHACHA */
|
||||
|
@ -103,6 +103,7 @@ int chacha_prng_ready(prng_state *prng)
|
||||
*/
|
||||
unsigned long chacha_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
|
||||
{
|
||||
LTC_ARGCHK(prng != NULL);
|
||||
if (chacha_keystream(&prng->chacha.s, out, outlen) != CRYPT_OK) return 0;
|
||||
return outlen;
|
||||
}
|
||||
@ -114,10 +115,8 @@ unsigned long chacha_prng_read(unsigned char *out, unsigned long outlen, prng_st
|
||||
*/
|
||||
int chacha_prng_done(prng_state *prng)
|
||||
{
|
||||
LTC_UNUSED_PARAM(prng);
|
||||
prng->chacha.ready = 0;
|
||||
XMEMSET(&prng->chacha.s, 0, sizeof(chacha_state));
|
||||
return CRYPT_OK;
|
||||
LTC_ARGCHK(prng != NULL);
|
||||
return chacha_done(&prng->chacha.s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
31
src/stream/chacha/chacha_done.c
Normal file
31
src/stream/chacha/chacha_done.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
|
||||
/* The implementation is based on:
|
||||
* chacha-ref.c version 20080118
|
||||
* Public domain from D. J. Bernstein
|
||||
*/
|
||||
|
||||
#include "tomcrypt.h"
|
||||
|
||||
#ifdef LTC_CHACHA
|
||||
|
||||
/**
|
||||
Terminate and clear ChaCha state
|
||||
@param st The ChaCha state
|
||||
@return CRYPT_OK on success
|
||||
*/
|
||||
int chacha_done(chacha_state *st)
|
||||
{
|
||||
LTC_ARGCHK(st != NULL);
|
||||
XMEMSET(st, 0, sizeof(chacha_state));
|
||||
return CRYPT_OK;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user