]> git.codecow.com Git - Monocypher.git/commitdiff
Update crypto_argon2.3monocypher - fixes errors and warnings that can lead to incorre...
authorSeth Archambault <seth@doercreator.com>
Thu, 19 Oct 2023 03:20:16 +0000 (23:20 -0400)
committerLoup Vaillant <github-is-valid@loup-vaillant.fr>
Thu, 19 Oct 2023 20:13:39 +0000 (22:13 +0200)
Closes: #264
Fixes these issues, by allowing password array to autosize, and then making sure to drop the \0 character when determining the size of the string, and also reorders the crypto_argon2_inputs field designators to remove a warning.

```
main.cpp:83:24: error: initializer-string for char array is too long, array size is 14 but initializer has size 15 (including the null terminating character)
uint8_t password[14] = "Okay Password!";
                       ^~~~~~~~~~~~~~~~
main.cpp:87:5: warning: ISO C++ requires field designators to be specified in declaration order; field 'pass_size' will be initialized after field 'salt' [-Wreorder-init-list]
    .salt      = salt,                 /* Salt for the password */
    ^~~~~~~~~~~~~~~~~
```

doc/crypto_argon2.3monocypher

index 37bf24fc9afa66f49843cf0e9c118dba0ac48d8d..a84f3d9f56ddec6faf4ee83a278a603bdfa6dd56 100644 (file)
@@ -341,11 +341,11 @@ crypto_argon2_config config = {
     .nb_passes = 3,                          /* 3 iterations    */
     .nb_lanes  = 1                           /* Single-threaded */
 };
-uint8_t password[14] = "Okay Password!";
+uint8_t password[] = "Okay Password!";
 crypto_argon2_inputs inputs = {
-    .pass      = password,                     /* User password */
-    .pass_size = sizeof(password),           /* Password length */
+    .pass      = password,                   /* User password */
     .salt      = salt,                 /* Salt for the password */
+    .pass_size = sizeof(password) - 1,       /* Password length */
     .salt_size = 16
 };
 crypto_argon2_extras extras = {0};   /* Extra parameters unused */
@@ -367,6 +367,8 @@ if (work_area == NULL) {
     crypto_wipe(password, sizeof(password));
     free(work_area);
 }
+
+
 .Ed
 .Sh SEE ALSO
 .Xr crypto_aead_lock 3monocypher ,