LoupVaillant / Monocypher

An easy to use, easy to deploy crypto library
https://monocypher.org
Other
580 stars 80 forks source link

Update crypto_argon2.3monocypher - fixes errors and warnings that can lead to the incorrect solution #265

Closed SethArchambault closed 8 months ago

SethArchambault commented 8 months ago

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 */
    ^~~~~~~~~~~~~~~~~
LoupVaillant commented 8 months ago

Looks pretty good to me, thanks for the fix!

This may help more than you realise, such issues not only waste time (sorry about yours), they also tend to hurt whatever trust users may have in the library.

SethArchambault commented 8 months ago

@LoupVaillant Cool, glad it helps! 😄

Appreciate your work, and glad this exists! 👍

SethArchambault commented 7 months ago

Realizing now that I was conflating strlen with sizeof! 🤦 strlen would be a fine replacement for sizeof here that would avoid all confusion.