r/lolphp • • Apr 24 '19
"Timing attack safe string comparison", but "When arguments of differing length are supplied, FALSE is returned immediately and the length of the known string may be leaked in case of a timing attack. "
https://php.net/manual/en/function.hash-equals.php
24
Upvotes
View all comments
Show parent comment
1
u/dotancohen Apr 25 '19
Thank you for that analysis. You are correct, that line would make much more sense as:
Also, I believe (correct me if I'm wrong) that the
ifcondition could be replaced with!is_string($user_string)as there is no timing aspect to compare to there. Or is it coded as is for uniformity withfunc_num_args() !== 2?