Client side password hash versus plain text
I am compiling an Android client (and possibly in the future iOS, a web portal, etc.) and a mysql php server. Server side I am currently using the PHPass library to hash and solarium incoming passwords.
Should I force the client to send plain text passwords over HTTPS / SSL or should the client perform some form of hashing first. For example, should every client just sha1 (or some other algorithm) every outgoing password?
source to share
Most websites will send a plain-text password over an SSL / HTTPS encrypted connection. Client-side password hashing can be done, but the advantage is small and often client-side languages (JavaScrypt) are slow so you can count fewer rounds in the same time, which weakens the hash. In each case, the server must also compute the hash to be safe.
The advantage is small, because if an attacker can attack ManInTheMiddle, he can also modify / remove the script (JS) that does the hashing. Only an encrypted connection with SSL / HTTPS can protect against a MITM attack, so you need SSL anyway.
In your case with the application, it looks a little different. Since the user has to install your software first, there is no need to send the script to the client, so MITM cannot change this script. In addition, the application can compute the hash relatively quickly (if it can run native code) and therefore can do enough rounds on the client side.
This is what I would do:
- For convenience, send the password in plain text over an SSL / HTTPS encrypted connection and compute the slow side of the BCrypt hash key server as you do now.
- Only if the load on the server becomes too heavy, you can move the BCrypt slow hash computation to the client application. Still use HTTPS to send the hash, and then compute an extra fast hash (like SHA-256) on the server. This is more difficult because you have to exchange and store the salt separately.
source to share
Another disadvantage of hashing passwords on the client is that you cannot change the hashing algorithm or iteration count without having to update your clients.
For JavaScript clients that aren't a problem, but you can't easily guarantee that your users will be on the most recent version of your own client.
So, I would stick with sending simple passwords over HTTPS.
source to share