I’m working on an application for iOS which will have the user fill out their password. The password will then be posted to a PHP page on my site using either POST or GET. (It must be plaintext because it is used in a script.)
Besides HTTPS, is there any way to secure the password? Encrypt it in Obj-C and then decrypt it in PHP?
NOTE: The username is not sent… only the password is posted to the server.
EDIT:
To clarify, David Stratton is correct… I’m trying to prevent malicious sniffers in public locations from simply reading clear text passwords as they are posted to the server.
Challenge response outline
Lets assume you have one-way hash function
abc(in practice usea cryptographically strong hashing algorithm for PHP see: password_hash).md5orsha1The password you store in your database is
abc(password + salt)(store thesaltseparately)The server generates a random challenge
challengeand sends it to the client (with thesalt) and calculates the expected response:abc(challenge + abc(password + salt))The client then calculates:
abc(user_password + salt)and applies thechallengeto getabc(challenge + abc(user_password + salt)), that is sent to the server and the server can easily verify validity.This is secure because:
There are some issues:
How do you know what salt to send? Well, I’ve never really found a solution for this, but using a deterministic algorithm to turn a username into a salt solves this problem. If the algorithm isn’t deterministic an attacker could potentially figure out which username exists and which do not. This does require you to have a username though. Alternatively you could just have a static salt, but I don’t know enough about cryptography to assess the quality of that implementation.