make sure chacha_crypt() can only be called after setting the IV
This commit is contained in:
parent
342a10cc14
commit
da4f854329
@ -57,9 +57,11 @@ int chacha_crypt(chacha_state *st, const unsigned char *in, unsigned long inlen,
|
|||||||
unsigned long i, j;
|
unsigned long i, j;
|
||||||
|
|
||||||
if (inlen == 0) return CRYPT_OK; /* nothing to do */
|
if (inlen == 0) return CRYPT_OK; /* nothing to do */
|
||||||
|
|
||||||
LTC_ARGCHK(st != NULL);
|
LTC_ARGCHK(st != NULL);
|
||||||
LTC_ARGCHK(in != NULL);
|
LTC_ARGCHK(in != NULL);
|
||||||
LTC_ARGCHK(out != NULL);
|
LTC_ARGCHK(out != NULL);
|
||||||
|
LTC_ARGCHK(st->ivlen != 0);
|
||||||
|
|
||||||
if (st->ksleft > 0) {
|
if (st->ksleft > 0) {
|
||||||
j = MIN(st->ksleft, inlen);
|
j = MIN(st->ksleft, inlen);
|
||||||
|
Loading…
Reference in New Issue
Block a user