Some of the guys here are developing an application which incorporates some 'secure areas' accessible by logging in. In the past, the login form and subsequent 'secure' pages were all plain text transmitted over http, as it's an application that goes out for use on shared servers where there is little chance of being able to use SSL (think WordPress and the like). Most people just shrugged their shoulders as that's all they expected - it's hardly a national bank.
We are now thinking of writing the next version using a JavaScript front end, with the advantage of loading all the images & CSS once, then writing HTML into the DOM thereafter with extJS (or maybe jQuery). We'd like to encrypt user input at the client before being sent to the server, then decrypt server output at the browser before being rendered to HTML so as to introduce some sort of security for users. There are also gains to be had with reducing page loading times, as we're only sending gzipped JSON back and forth.
While playing around, we realised that the method we were looking at to encrypt the basic stuff also doubled up as an authentication mechanism for login in the first place.
For simplicity...:
username
, password
and secret
into a login form.username
and password
to the server via AJAX. The secret
is only stored in JavaScript and is never sent across the internet.username
and secret
from the database.username
and secret
back to the browser.username
and secret
and compares it to the hash sent back from the server.response
with secret
and sends the message back to the server.secret
to find the expected response
and starts a new session.secret
.There seem to be a few advantages of this type of system, but are we right in thinking:
username
and secret
, proving the server knows and understands username
and secret
.response
with secret
, proving the user knows secret
.secret
ever transmitted in plain text, or is it possible to determine secret
from the hash.It all seems quick enough as to be imperceptible to the user. Can anyone see through this, as we all just assumed we shouldn't be playing with JavaScript encryption!
Don't do this. Please use SSL/TLS. See Javascript Cryptography Considered Harmful.