1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-31 22:42:57 -07:00

Refuse an output length > 256 Gb in crypto_stream_chacha20_ietf_ref()

This commit is contained in:
Frank Denis 2015-10-30 20:47:37 +01:00
parent aeb4ff95e4
commit 8deb15bd85

View File

@ -8,6 +8,7 @@
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "api.h"
@ -267,6 +268,9 @@ crypto_stream_chacha20_ietf_ref(unsigned char *c, unsigned long long clen,
if (!clen) {
return 0;
}
if (clen > 64ULL * (1ULL << 32) - 64ULL) {
abort();
}
(void) sizeof(int[crypto_stream_chacha20_KEYBYTES == 256 / 8 ? 1 : -1]);
chacha_keysetup(&ctx, k);
chacha_ietf_ivsetup(&ctx, n, NULL);