I had an idea. Could anyone tell me if this is a thing, if they see any problems with it, and if they know of a commutative hash function that would make it work?
Suppose you had a pair of cryptographic hash functions, one of which could take an a key in addition to its regular input, and that these functions were commutative. So:
hash1(hash2(key, input)) = hash2(key, hash1(input))
I think this could be used to implement a very effective challenge-response password system:
- Server stores
storedHash = hash1(password)
- User requests login
- Server generates random
key, sends to user. (Alternatively: User and hub use trust-less protocol to agree on random key.)
- User returns
sentHash = hash2(key, password)
- Server compares
hash1(sentHash) == hash2(key, storedHash)
The upside to this system is that even if the communications are intercepted, the users password remains safe, even for future use on the same server. Even if the user were tricked into trying to log in to a malicious fake server, the credentials they sent would be useless for impersonating them to the true server.
So... anyone see a problem with this? Anyone know a hash function that would make it work? (Or is there a reason any hash functions that's key-able and commutative would not be secure?)