I'm cooking up a very simple system to send commands to a remote server via email. Everytime an email is sent to [email protected]
, the server runs a python script that does something different based on the recipient do_something
, and uses the email content and metadata as parameters for whatever task it will perform. This will be used to provide services through email for a specific set of users that don't have direct Internet connection must of the time. Users don't write emails themselves, but use a small application that generates all necessary metadata.
It is of course very important to authenticate users reliably. I could implement some public key cryptography protocol, but a friend suggested me the following idea, which is very easy to implement, and seems reliable enough for me:
I generate a password for each user (identified by his email address), say a random string of size 2K. The server knows the password for each user, and each user knows his password. The user application generates an email for the corresponding task with all necesary data. After it has finished, it concatenates some of the email metadata (say sender and timestamp to avoid collisions for the same user) with the user password and computes a secure hash (I'm currently using SHA-512). It then attaches this hash to the generated email. The server gets the email and calculates the same hash (remember it knows the supposed sender password). If it matches with the hash attached in the email, it is considered authenticated.
Now suppose that I can reliable make each user get his password (not by electronic means). Is this mechanism secure? I know I'm probably reinventing a lot (rather old) of wheels here, so please forgive my ignorance on the subject. I do know that SHA hashes are virtually irreversible, and that is the main reason why I think this strategy might work.
Thanks in advance.