PHP - Implementing Secure Login with PHP, JavaScript, and Sessions (without SSL)
Friday, February 9th, 2007HTTPS (HTTP over SSL) is the most common mechanism on the internet used to ensure server authenticity and provide data privacy. Unfortunately, SSL is often too complex and prohibitively expensive for many small-scale sites where all that is needed is a secure authentication mechanism.
Challenge-Response Authentication Mechanism
The biggest drawback of a regular non-SSL login is that the password is sent in clear-text, which can be easily sniffed by a potential attacker. But if the password were never to leave the client, there would be no chance of capturing it.
We can use a cryptographically-secure one-way hash function, such as MD5, to convert the password into a 128-bit hash number, which we could send instead. Even though this method would preserve the secrecy of the password, it would fail under a replay attack where an attacker could log in using the sniffed hash.
(more…)