]> git.codecow.com Git - Monocypher.git/commitdiff
Fix Argon2 allocation (test & doc)
authorLoup Vaillant <loup@loup-vaillant.fr>
Wed, 26 Jul 2023 15:46:50 +0000 (17:46 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Wed, 26 Jul 2023 15:46:50 +0000 (17:46 +0200)
doc/crypto_argon2.3monocypher
tests/test.c

index a05f1eb13dd77049dcbfc48bd0df0c40e774732c..64cc6f5e1d807ea579f942d83a4db2e0c1b7de6a 100644 (file)
@@ -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 */
index 1ea2d176cbb4e3cd8e6572895d78b061008c4631..f78ced0514afea30c98c0cab5929aaa9de2a4213 100644 (file)
@@ -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;