From: Loup Vaillant Date: Wed, 26 Jul 2023 15:46:50 +0000 (+0200) Subject: Fix Argon2 allocation (test & doc) X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=3f9f5470fde35f603939215644673a223a55379e;p=Monocypher.git Fix Argon2 allocation (test & doc) --- diff --git a/doc/crypto_argon2.3monocypher b/doc/crypto_argon2.3monocypher index a05f1eb..64cc6f5 100644 --- a/doc/crypto_argon2.3monocypher +++ b/doc/crypto_argon2.3monocypher @@ -348,7 +348,12 @@ crypto_argon2_inputs inputs = { .salt_size = 16 }; crypto_argon2_extras extras = {0}; /* Extra parameters unused */ -void *work_area = malloc(nb_blocks * 1024); /* Work area */ + +/* Allocate work area. + * Note the conversion to size_t. + * Without it we cannot allocate more than 4GiB. + */ +void *work_area = malloc((size_t)nb_blocks * 1024); if (work_area == NULL) { /* Handle malloc() failure */ /* Wipe secrets if they are no longer needed */ diff --git a/tests/test.c b/tests/test.c index 1ea2d17..f78ced0 100644 --- a/tests/test.c +++ b/tests/test.c @@ -620,7 +620,7 @@ static void argon2(vector_reader *reader) vector key = next_input(reader); vector ad = next_input(reader); vector out = next_output(reader); - void *work_area = alloc(config.nb_blocks * 1024); + void *work_area = alloc((size_t)config.nb_blocks * 1024); crypto_argon2_inputs inputs; inputs.pass = pass.buf;