note 124294 added to function.password-hash
| From: | ms1 at rdrecs dot com | Date: | Mon, 14 Oct 2019 17:07:42 +0000 |
| Subject: | note 124294 added to function.password-hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212651@lists.php.net to get a copy of this message | ||
Timing attacks simply put, are attacks that can calculate what characters of the password are due to
speed of the execution.
More at...
https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy
I have added code to phpnetcomment201908 at lucb1e dot com's suggestion to make this possible
"timing attack" more difficult using the code phpnetcomment201908 at lucb1e dot com
posted.
$pph_strt = microtime(true);
//...
/*The code he posted for login.php*/
//...
$end = (microtime(true) - $pph_strt);
$wait = bcmul((1 - $end), 1000000); // usleep(250000) 1/4 of a second
usleep ( $wait );
echo "<br>Execution time:".(microtime(true) - $pph_strt)."; ";
Note I suggest changing the wait time to suit your needs but make sure that it is more than than the
highest execution time the script takes on your server.
Also, this is my workaround to obfuscate the execution time to nullify timing attacks. You can find
an in-depth discussion and more from people far more equipped than I for cryptography at the link I
posted. I do not believe this was there but there are others. It is where I found out what timing
attacks were as I am new to this but would like solid security.
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.157.54 (proxied: 2601:282:101:4389:fd04:6a4d:370a:f831)
----
Manual Page -- http://php.net/manual/en/function.password-hash.php
Edit -- https://master.php.net/note/edit/124294
Del: integrated -- https://master.php.net/note/delete/124294/integrated
Del: useless -- https://master.php.net/note/delete/124294/useless
Del: bad code -- https://master.php.net/note/delete/124294/bad+code
Del: spam -- https://master.php.net/note/delete/124294/spam
Del: non-english -- https://master.php.net/note/delete/124294/non-english
Del: in docs -- https://master.php.net/note/delete/124294/in+docs
Del: other reasons-- https://master.php.net/note/delete/124294
Reject -- https://master.php.net/note/reject/124294
Search -- https://master.php.net/manage/user-notes.php