Mitigate Timing Attacks On Basic RPC Authorization
authoralex <alex@alex-VirtualBox.(none)>
Sat, 24 Aug 2013 14:21:53 +0000 (18:21 +0400)
committeralex <alex@alex-VirtualBox.(none)>
Sat, 24 Aug 2013 14:21:53 +0000 (18:21 +0400)
commit6511bd83b46b2e14c5d08c682f1490b8816588a7
tree8cba309e24bff01a25416c9bbca2e84be85635cd
parent604f231007ba34207fe0914b8a8b48482ec5109e
Mitigate Timing Attacks On Basic RPC Authorization

Eliminates the possibility of timing attacks by changing the way the two passwords are compared.
It iterates through each char in the strings, and if the two chars it is comparing aren't the same, then it adds 1 to nReturn and the function, once it's done comparing all the chars, will return false. Previously, the function would return false on the first char that didn't match, allowing a possible attacker to run a timing attack.

See

https://github.com/bitcoin/bitcoin/pull/2886
http://rdist.root.org/2010/01/07/timing-independent-array-comparison/

for more detailed explanation.
src/bitcoinrpc.cpp
src/util.h