Imagine we start building a new web app from scratch. Most static pieces of the application do not really require encryption (html, company logo, css...). Let us also assume that we are not afraid of Javascript and can exchange all sensitive information through XmlHttpRequests. What prevents us from encrypting that data before sending it out? All we need is for client and server to negotiate an encryption method.
Ingredients needed:
- a pure python implementation of RSA
- a pure javascript implementation of RSA
- Javascript and Python implementations of AES
Imagine the server runs on AppEngine and that we uploaded a key of public/private keys with the app. What would prevent us from doing the following:
- put the public key into one of the Javascript files that is downloaded as part of the application. This way, the Javascript client is able to encrypt data in a way only the server can read.
- upon initialization, the Javascript client creates a random key for AES encryption. It encrypts that data using the public key and stores it in a cookie.
- we create out own version of an XmlHttpRequest that encrypts all data before sending it out using AES
- the server gets the encrypted data, extracts the key from the encrypted cookie, and uses it to decrypt the data
- when the server needs to send any data in return, it uses the very key it got from the client to encrypt the response
2 comments:
Thanks for linking to my RSA implementation. If there is anything I can do to improve it, let me know.
Sybren, thanks for making this code available to other developers :-D. If you happen to know of people putting it to interesting use in App Engine, please let me know.
Post a Comment