We have a web service written in c/c++
Before today user passwords were simply hashed with MD5 and stored in DB
It is clear for me that this algorithm is not secure at all
Web service is 1 threaded application. On average it receives ~100 packets a second from users(100p/s). Some of them are authentication packets.
I read about bcrypt and salts, but haven’t used this techniques in practice at all.
The fact that bcrypt produces hashes slower than MD5 because of security reasons is also clear for me.
If we go this way and use bcrypt or scrypt for ciphering passwords and checking auth packets, would it make our service much slower?
Security is better if it slows down attack vectors. Keep this in mind always.
As for salting and hashing, i recomend you to use salting always, with a good entropy generator and to do several rounds of your hash function.
Why salting?
If you use hashes directly from passwords, you’ll get a 1 to 1 representation (in the best case) of hashes and passwords. Salting (specifically, a strong salt with at least 32 bits of entropy) deters dictionary attacks. If your salt has low entropy or a small number of bits, you’re prone to get attacked with a rainbow table if your salted and hashed passwords get stolen.
Why rounding?
Rounding (applying several rounds of the hash function, like bcrypt does) adds some feedback hashing, but more importantly, add cost to building a customized rainbow table. If you don’t salt your password before hashing, rounding does nothing.
Why slowdowns?
You’ll see that some sites have exponential backoff times whenever you input invalid credentials. This is in order to disallow bots to brute force passwords. Always do an exponential backoff if your server holds important data.
As general information,
bcryptdoes 1000 rounds of hashing, that’s why it is slow.