Archives For DOMCrypt

DOMCrypt round up

2011/06/13 — 3 Comments

While I work on the spec for DOMCrypt, I want to make sure to keep the latest information about the status of this API fresh.

For the uninitiated, DOMCrypt is a browser window API I have been working on that makes using public key and symmetric crypto as well as hashing easy and fast for web developers.  The current implementation is a Firefox add-on as well as a patch for Firefox.

First and foremost, a WebKit bug was filed to implement the DOMCrypt API! This is great news. Both Adam Barth and Jarred Nichols have jumped in to write the code.

Secondly, I have created a proper WebIDL document to describe the API: https://wiki.mozilla.org/Privacy/Features/DOMCryptAPISpec/Latest#Browser_Window_property_WebIDL

The mailing list archives for the 3 lists I requested feedback and criticism from are here:

The consensus seems to be that this is a good idea – and a good place to start for a *high-level* browser-based crypto API. Some of the changes that should be made are:

  • Fold this API into the existing window.crypto property to avoid confusion
  • Removed the ‘addressbook’ sub-API as it adds too much undefined complexity (for now, anyway – I hope to revisit this concept in a separate spec)
  • Add an algorithm property to each sub-API to allow for forward migration to better, faster crypto
  • Add an HMAC sub-API to round out the API

All of this has been reflected in the spec.

I have attempted to aggregate most of the discussion into this etherpad (may need some updating): http://etherpad.mozilla.com:9000/DOMCrypt-discussion

As far as the Gecko implementation is concerned, Brian Smith has been giving me a lot of pointers on what will be a better implementation, starting with a new set of APIs to more easily handle the interfacing with NSS, see bug 662674

I would love to collect more feedback on this API, please do not hesitate to join in on the discussion.

It seems like the time is right for this to gain steam as we see the effect of not having these  tools  – in what seems like daily personal data breaches on the web. I think an API like DOMCrypt will help spur new communications tools that have security, privacy and user control built in from the ground up.

Advertisements

There has been so much written and discussed online and off about privacy, user control and identity lately. This dovetails nicely with the draft spec for DOMCrypt as a proposed Crypto API for web browsers.

See: https://wiki.mozilla.org/Privacy/Features/DOMCryptAPISpec/Latest

DOMCrypt was discussed on the WHATWG mailing list last week, see: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031741.html

I have summarized the discussion here: http://etherpad.mozilla.com:9000/DOMCrypt-discussion

Out of these discussions, I have updated the Firefox feature page: https://wiki.mozilla.org/Privacy/Features/DOMCryptAPI

A Use-cases page was created, see: https://wiki.mozilla.org/Privacy/Features/DOMCryptAPI/UseCases

For anyone unfamiliar with DOMCrypt, this proposal in a nutshell says:

Privacy and user control on the web is of utter importance. Tracking, unauthorized user data aggregation and personal information breaches are becoming so commonplace you see a new headline almost daily. (It seems).

We need crypto APIs in browsers to allow developers to create more secure communications tools and web applications that don’t have to implicitly trust the server.

The DOMCrypt API is a good start, and more feedback and discussion will really help round out how all of this should work – as well as how it can work in any browser that will support such an API.

This API will provide each web browser window with a ‘cipher’ property[1] that facilitates:

  • asymmetric encryption key pair generation
  • public key encryption
  • public key decryption
  • symmetric encryption
  • signature generation
  • signature verification
  • hashing
  • easy public key discovery via meta tags or an ‘addressbookentry’ tag

[1] There is a bit of discussion around adding this API to window.navigator or consolidation within window.crypto

I have created a Firefox extension that implements most of the above, and am working on an experimental patch that integrates this API into Firefox.

The project originated in an extension I wrote, the home page is here: http://domcrypt.org

The source code for the extension is here: https://github.com/daviddahl/domcrypt

The Mozilla bugs are here:

You can test the API by installing the extension hosted at domcrypt.org and addons.mozilla.org, and going to http://domcrypt.org

The API:

window.cipher = {
 // Public Key API
 pk: {
   set algorithm(algorithm){ },
   get algorithm(){ },

  // Generate a keypair and then execute the callback function
  generateKeypair: function ( function callback( aPublicKey ) { } ) {  },

  // encrypt a plainText
  encrypt: function ( plainText, function callback (cipherMessageObject) ) {  } ) {  },

  // decrypt a cipherMessage
  decrypt: function ( cipherMessageObject, function callback ( plainText ) { } ) {  },

  // sign a message
  sign: function ( plainText, function callback ( signature ) { } ) {  },

  // verify a signature
  verify: function ( signature, plainText, function callback ( boolean ) { } ) {  },

  // get the JSON cipherAddressbook
  get addressbook() {},

  // make changes to the addressbook
  saveAddressbook: function (JSONObject, function callback ( addresssbook ) { }) {  }
  },

  // Symmetric Crypto API
  sym: {
  get algorithm(),
  set algorithm(algorithm),

  // create a new symmetric key
  generateKey: function (function callback ( key ){ }) {  },

  // encrypt some data
  encrypt: function (plainText, key, function callback( cipherText ){ }) {  },

  // decrypt some data
  decrypt: function (cipherText, key, function callback( plainText ) { }) {  },
  },

  // hashing
  hash: {
    SHA256: function (function callback (hash){}) {  }
  }
}

I am in the process of posting this proposed spec for review by the W3C webapps list and TC39. Your feedback and / or help with this effort will be greatly appreciated.

>I did a quick DOMCrypt presentation at the All Hands last week. It went well,  a lot of helpful and smart people showed up. I am thinking about all of the improvements that need to be made in the coming weeks to make DOMCrypt better.

There are 3 obvious things to do now:

1. Namespace the API to allow for future additional APIs

2. move all heavy-lifting work to a ChromeWorker

3. DOMCrypt needs a story – an understandable message – so that Web Developers and web users can understand the possibilities and the risks of not being in control of their data. Even talking about cryptography makes people’s eyes glaze over, so the move to simplify the nomenclature is essential.

The main story is a familiar one at Mozilla: User Control. Web users should be able to control who reads what they write online.  To everyone else, the message is a garbled stream of incoherent data. This should be the default mode in online communication – default and easy.

A fourth item is to figure out how to inter-operate with  existing Crypto standards. This is a very large undertaking, so I am not sure how it will play out yet. I have a lot of reading to do. I would like to have an elegant, “webby” toolkit that is easy to use and make available ASAP. Getting bogged down in standardization may work against this. Right now, I think supporting existing standards should be a long term goal which will be achieved via future APIs.

>DOMCrypt is a Firefox privacy extension I have been working on for some time. In this post I will attempt to explain what it is and why I am working on it in a somewhat non-technical manner.

What is DOMCrypt?

The core functionality is being able to take a bunch of text (or any data) and turn it into an unreadable blob via a password, right in any web page.

For instance, you can take the sentence: “Meet me in Lincoln Park by the beach at 2:00” and scramble it into something that looks like: iim08xKWVut3eqGubpq2jdCTanU7jV41q4UQKTJOoLD8y6sadUEm/8K9kpv+Wvq

The scrambled “version” of the sentence cannot be turned back into plain text unless you know the password required to convert it back.
This sentence can be sent to your contact, who alone can unscramble it and read the plain text.

The cool thing is that this kind of data scrambling – encryption – is pretty standard these days, in fact, you use this technology every time you visit a page that begins with https://.


The problem I am trying to solve is that the encryption tools in your browser are either not exposed to web pages for developers to use or the implementation (of, perhaps, an extension) is so complex, few users will ever use it.

Why DOMCrypt?

If you think about it, you realize that it is nearly impossible to communicate online without the content of the conversation recorded by a third party. Whether the purpose is ‘advertising’ or truly nefarious, you are stuck revealing your conversation to your internet provider, free email host, or social networking site. Perhaps that is not a problem to you, but to many it really is a bad situation.

The web has evolved into a network where users are tracked as web sites are traversed, their email and personal information is archived, collated, sliced, diced and indexed. Your data is not yours. This is about privacy and it is about ownership. Is privacy a relic? Is the ownership of your data important to you?

Privacy really needs to become the default configuration, a primary feature.

There is a lot of upheaval in the world right now. People all over the world need to be able to communicate privately, anonymously (or pseudo-anonymously) and quickly. With DOMCrypt, developers can build privacy-enhanced pages and applications which fully obscure at least the contents of these messages. The server that accepts these messages can be written so that there is virtually no identifiable data stored about the user.

I have created a Drumbeat project and the code is on Github.

As part of the project, I am building demo pages and web applications to demonstrate DOMCrypt in the wild. The first couple of demos show how basic encryption and an “addressbook” feature work:

http://mozilla.ddahl.com/domcrypt/demos/demo.html

http://mozilla.ddahl.com/domcrypt/demos/get-pub-key.html

I just put together a new demo that showcases a fully-working secure messaging application:

https://messages.domcrypt.org/

It is rough around the edges, but works and the source code is on Github.

>For some time now I have been playing with the WeaveCrypto service – now a JavaScript module implemented on top of NSS via jsctypes. It is a pretty easy to use module – thanks in large part to the Weave (now Sync) team, Justin Dolske and many others.

I recently dove back into the code to try and distill down an easy to use API that can be attached as a property to any DOM Window.

The WeaveCrypto API was truncated because Sync started using a better encryption system (J-PAKE) for its purposes, so I had to dig through hg log to find the bits I needed:

http://hg.mozilla.org/mozilla-central/raw-file/d0c40fc38702/services/crypto/modules/WeaveCrypto.js

I took the old WeaveCrypto module and created an easy to use front-end component that sticks a ‘crypt’ property on each DOM Window.

My github repo is here: https://github.com/daviddahl/domcrypt 

A demo (with xpi link) page is here: http://mozilla.ddahl.com/domcrypt/demo.html

The 3 methods exposed (so far)  are generateKeyPair(), encrypt() and decrypt()

While I am not sure this is ‘production system’ ready, I am sure that these are the kinds of tools the users of the web need to build secure communications applications, toolkits and libraries.

Perhaps ‘Do Not Track’ can extend to ‘Do Not Datamine’?