I have a web service on an insecure network that needs authorization.
I wish to implement it over HTTP, instead of HTTPS, at the same time evading man-in-the-middle and sniffing attacks. I need only one key for the client and the server.
The client calls a server function, and the server can authenticate whether this client is right, and can give back a response, which needs to be signed not encrypted.
I have a crude idea how this could be implemented, and will give it as an example:
Pseudocode
Web service and client has already shared PASSCODE1 and PASSCODE2
First Handshake:
Client pings web service
Web service sends random string A with length
Client checks A is nonnull, and sends Hash X=(md5(A XOR PASSCODE1) XOR
concat("RIGHT",random string B) XOR PASSCODE2)
Web service receives Hash X, checks if "RIGHT" is there, saves key B, sends
Hash Y=(md5(B XOR PASSCODE1) XOR concat ("RIGHT", random string C)
XOR PASSCODE2)
Client checks if this value is right, and they are authenticated
At this point, if everything goes right, have keys B and C for this
particular transaction
Sample Transaction:
Client calls function(args, md5(args, C) XOR PASSCODE2)
Server returns (object(), md5(args, B) XOR PASSCODE2)
keys expire after a few minutes, and a new key pair needs to be requested
I know this method is really crude, are there any other ways to do so?
Specifically, I am looking to do this in Java.