Req #75572 [Opn]: sodium_crypto_pwhash_str() allow opslimit of 1

From: Date: Tue, 28 Nov 2017 13:05:11 +0000
Subject: Req #75572 [Opn]: sodium_crypto_pwhash_str() allow opslimit of 1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212770@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75572&edit=1 ID: 75572 Updated by: jedisct1@php.net Reported by: phpdoc at mail dot my1 dot info Summary: sodium_crypto_pwhash_str() allow opslimit of 1 Status: Open Type: Feature/Change Request Package: *Encryption and hash functions PHP Version: 7.2.0RC6 Block user comment: N Private report: N New Comment: Fixed in c05cbd1e775fa69ed9939796a908390f2bfb4459 Previous Comments: ------------------------------------------------------------------------ [2017-11-26 08:26:41] phpdoc at mail dot my1 dot info Description: ------------ when using an opslimit (which equals the time_cost parameter in password_hash with argon2i) of 1 a warning is thrown. this is a result of https://github.com/php/php-src/blob/master/ext/sodium/libsodium.c#L1905-L1908 and the fact that the constant SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE is 2. considering the process on how the argon2 RFC goes for parameter choice, a time factor of 1 is certainly not impossible, in fact especially if the server has a lot of RAM, chances are that one would choose a time of 1 and go for the ram instead of lowering the RAM and choosing a 2 or higher for time if the situation allows. also as a side note the RFC even states that for argon2id (which is what sodium uses) that 1 pass maximizes the attack costs for the constant time of the defender. https://tools.ietf.org/html/draft-irtf-cfrg-argon2-03#section-9.3 Test script: --------------- <?php header("Content-Type: text/plain"); if(defined("SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE")) { echo "NaCl Found. ".PHP_EOL; echo sodium_crypto_pwhash_str("test",1,1<<26).PHP_EOL; } else echo "no NaCl with pwhash".PHP_EOL; ?> Expected result: ---------------- NaCl Found. $argon2id$v=19$m=65536,t=1,p=1$h1v/Fexw43PMyi6W8NRRGA$QiqKXRL+csDoLqLT7p282LxPM3kfwc4UlGE5BUBD45w Actual result: -------------- NaCl Found. <br /> <b>Warning</b>: number of operations for the password hashing function is low in <b>C:\xampp\htdocs\a2.php</b> on line <b>5</b><br /> $argon2id$v=19$m=65536,t=1,p=1$h1v/Fexw43PMyi6W8NRRGA$QiqKXRL+csDoLqLT7p282LxPM3kfwc4UlGE5BUBD45w ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75572&edit=1

« previous php.bugs (#212770) next »