Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I have a app which transmit the password in clear text. I was planning to use the hash of the password (SHA-512) as the key for encrypting the plain text password. Then send the encrypted text to the server. the password length is minimum 12 chars (including special characters) and max 20 chars.

Is this is bad mechanism ?

share|improve this question

5 Answers 5

up vote 1 down vote accepted

With a minor tweak this can be made reasonably secure.

The problem with your original approach is that the hash would be the same every time, so it is vulnerable to a replay attack.

If you adjust the protocol to include a variable challenge this can work:

  1. Server sends a random challenge
  2. Client computes hash = hmac(hash(password), challenge)
  3. Client sends cipher = encrypt(hash, password)
  4. Server computes hash = hmac(hash(password), challenge)
  5. Server computes password = decrypt(hash, cipher)
  6. Server checks hash(password) = stored hash

This arrangement is secure against replay attacks and it also avoids the server storing a password equivalent. It's main vulnerability is that a captured login can be used for an offline brute force attack. Also, if you are implementing this in JavaScript, then the JavaScript code could be intercepted and tampered with.

Now, while this is interesting, I should echo the advice from other answers: do not roll your own crypto

share|improve this answer

Is this is bad mechanism ?

Yes. Use SSL/TLS and do not attempt to roll your own cryptograhy scheme.

share|improve this answer
    
what if I use en.wikipedia.org/wiki/PBKDF2 and use the hash if the password as the salt ? –  user851157 Nov 23 '13 at 5:06
    
@user851157 Unless the connection itself is encrypted, it's still a bad idea. Without that encrypted (and, as another function of SSL, authenticated) connection, anyone could just MitM the user and pass the authenticator on to your system as if it were their own. They don't need the cleartext of the password. They just need the cleartext of the packets being passed between the user and your system. Seriously, don't roll your own crypto. Ever. And don't pass authenticators in the clear. Ever. –  Iszi Nov 23 '13 at 5:40

If your concern is transmitting the password, then yes, absolutely, this is a bad mechanism. Your application is still vulnerable to a form of pass-the-hash attack. Although the password itself won't be available to the attacker, the encrypted password can be intercepted and used, itself, for authentication.

Always go for the standard:

share|improve this answer

Yes, this is bad. If all the server needs in order to authenticate you is this (never changing) hash, then the has is your password now. This is no better than sending the password in the clear, because all the attacker needs in order to impersonate you is that hash.

Instead, if you want to hash passwords for transmission, the way you do it is through a challenge-reponse system. This way, the same hash is never sent twice. But this is not a good idea, because...

It's more important that the password not be stored on your server. TLS/SSL is sufficient to prevent any sort of man-in-the-middle attack. That part is solved, Just use TLS and don't worry about it. But you do have to worry about your server getting hacked and your password database getting leaked. Publishing other people's password databases is all the rage these days, and you don't want to be one of those caught not hashing their database. There's just no excuse.

So, transmit your passwords plain-text inside an encrypted connection, but store them hashed on the server. If you do anything else, anything else at all, then you're doing it wrong.

share|improve this answer

I was planning to use the hash of the password (SHA-512) as the key for encrypting the plain text password. Then send the encrypted text to the server.

I don't care if you're using SHA with 8192 bit key, you're trying to authenticate with something traveling in the clear that someone can just MITM so your answer is no. Anyone who's worked with crypto (as the other good answers here) will tell you not to try rolling your own crypto, unless you really know what you're doing, and even then there are plenty of good API's for that.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.