Reputation: 1764
Ok guys just a small game:
I have some specifications for a project. At some point they ask for the following to encrypt a password over the net, saying that it is a challenge response protocol:
CLIENT ----------------------------- SERVER (1)ask for challenge --------------> (2) <---------------------------- send SHA1 taken from the time (this is the challenge) (3) make SHA1 xor PASSWORD --------> if it's equal to SHA1 xor stored password (4) <---------------------------- Grant access
For those who don't know it SHA stands for Secure Hashing Algorithm, a standard algorithm for cryptography.
I hope it's clear. Question is: If I sniff packets 2 and 3 (the "challenge" and the "challenge xor password", I do have the actual password just with another xor between them both!?!? There is other way to implement this kind of protocol??
Upvotes: 2
Views: 1786
Reputation: 40319
I believe the Diffie-hellman is a well-known and solid key exchange protocol?
Upvotes: 0
Reputation: 6082
Although it is never a good solution to roll out your own cryptographic protocol, and it is something I would not suggest....
To overcome the problem that you are facing... F - A function which takes in the password and a pseudorandom monotonically increasing value and returns a number. For e.g. Hash(Hash(Password) ^ Timestamp)
Kind regards, Ashish Sharma
Upvotes: 0
Reputation: 6806
public key encryption? Use the server's public key to encrypt the password.
Upvotes: 0
Reputation: 101149
As others have pointed out, yes, this is a poor challenge response algorithm.
You probably want to check out Digest Authentication, as used by HTTP. In fact, if your protocol is over HTTP, you can skip writing your own and just use or implement this.
Upvotes: 0
Reputation: 25707
The way I would do this is the following:
Server responds with it's public key (for, say RSA encryption) digitally signed.
Client verifies PK, and encrypts password with the key, then digitally signs the encrypted password.
Server verifies signing and decrypts the password to store/check it.
The digital signing is important here as it acts as the beginning of preventing man in the middle attacks.
Upvotes: 0
Reputation: 47366
How about the following:
Upvotes: 3
Reputation: 16833
As the other's have pointed out, you are correct. Also keep in mind that someone could intercept communication (3) and potentially resend it while the real user is experiencing network issues (eg: a DDOS), the impostor would then be logged in and often that is sufficient to change the password (that is, many systems don't require that you supply a password inorder to change it once you are logged in).
You may want to consider HMAC (keyed-Hash Message Authentication Code). I've blogged about it in detail here: http://blog.ciscavate.org/2007/09/creating-a-secure-webauth-system-part-1-hmac.html and I'll give a quick summary below.
HMAC is a method of ensuring that a message was generated by someone with access to a shared secret. HMAC makes use of some sort of one-way hashing function (like MD5 or SHA-1) to encrypt the secret along with a message. This generates a short digest of 16-20 bytes that acts as a fingerprint of the message+secret combination. When the digest is sent along with the message, the receiver (our server) can re-generate the hash with the same HMAC calculation and compare the locally generated digest with the digest that came along with the message. Remember: the server has the secret too, so it has enough information to confirm the digest. (This only considers the problem of verifying the origin of a message, but you can use the same approach to encrypt the entire message, if you use a different secret, say a set of public keys.)
Upvotes: 1
Reputation: 101400
That's a pretty horrible protocol. If this is something someone wants you to implement, refuse to. There are existing, vetted protocols for this type of thing. If this is a game where you point out all the flaws - okay.
And I'm definetly missing some more.
Upvotes: 2
Reputation: 30107
You would be able to reverse engineer the password. You want to send the SHA of the password, not the password itself. Rolling your own security protocols is almost never a good idea. Can you not use SSL or something equivalent?
http://en.wikipedia.org/wiki/Cryptographic_nonce
Upvotes: 4
Reputation: 47482
You are right -- if you capture the challenge and (challenge XOR password) then extracting the password is easy.
You need to use proper encryption in step 3, not XOR. Encrypt the challenge with the password.
To make an attacker's life harder you could add random data to what you encrypt to: e.g. encrypt paddingCHALLENGEpadding. The server doesn't care what the padding is, it knows where to look for the challenge, but it means an attacker won't know what the whole plaintext is.
Upvotes: 1