I would like to build a simple system, are there any obvious security flaws in it? Will this hashing mechanism be fairly secure without any other layers of encryption?
I have a simple module where people can enter in codes, and a server that keeps a list of allowable codes (which are used only once, and new ones are added, but not reused). Assume the wifi connection between the module and server is insecure.
Here are the steps the code gets verified:
- the module sends a sha1 hash of the code to the server
- (if valid) the server responds with a sha1 hash of the code + a hard-coded salt (known to the module, but unknown to hackers)
- the module can verify that and accept or deny the user
(The reason only hashes are used is so it would be impossible for a hacker to transmit an Allow/Deny message straight to the module. A salt is used, is so that middle-men cannot enter a random code then then transmit their own sha1 hash of it)
I am avoiding the complexity of SSL because the module will be run on an extremely simple embedded system with no OS.
Updated example that makes more sense: Allow UPS couriers to scan the tracking number of packages to unlock a door so they can drop off the package. Only known tracking numbers are allowed so that robbers cannot simply scan an irrelevant package to break in.
Notes:
- I guess "password" isn't the right word, it's just one-time use codes. Yes, the salt is hard-coded and I'm hoping to avoid encryption. The reason sending back the code is involved is so that regardless of what a hacker might transmit to the module, it will be impossible to authenticate unless he knows the salt.
- As for where the authentication happens: the server will know if the code is valid or not, but the module will only accept the hash of salt + code so that the module knows the answer came from the server not hackers, and also so hackers cannot figure out the salt.