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.


DOMCrypt was discussed on the WHATWG mailing list last week, see:

I have summarized the discussion here:

Out of these discussions, I have updated the Firefox feature page:

A Use-cases page was created, see:

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:

The source code for the extension is here:

The Mozilla bugs are here:

You can test the API by installing the extension hosted at and, and going to

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 am on my third project where I need to create a custom property on every web page in Firefox. Creating custom properties used to be somewhat of a hack, with mixed results, but today it is trivial.

For the release of Firefox 4, the content team created a new component, nsIDOMGlobalPropertyInitializer, which is a mouthful, but is a tasty morsel, I promise!

The basic procedure is this:

1. Create a JS Constructor and prototype with *some* XPCOM gunk

2. Make sure the prototype has an init() method

3. The object returned from the init method is the object lazily added to each web page

4. The init() method accepts an nsIDOMWindow argument if you need access to the window in your property

5. Name the new window property in your .manifest file

Here is an example:

let Cu = Components.utils;let Ci = Components.interfaces;let Cc = Components.classes;


function DOMCryptAPI() {}

DOMCryptAPI.prototype = {

  classID: Components.ID("{3d92fb7f-be77-475c-992a-5235615f9189}"),

  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer,                                         Ci.nsIObserver,]),

  init: function DA_init(aWindow) {

    let self = this;

    this.window = XPCNativeWrapper.unwrap(aWindow);

    let api = {

      // "pk": Public Key encryption namespace      pk: {        encrypt: self.encrypt.bind(self),        decrypt: self.promptDecrypt.bind(self),        sign: self.sign.bind(self),        verify: self.verify.bind(self),        generateKeypair: self.beginGenerateKeypair.bind(self),        getPublicKey: self.getPublicKey.bind(self)      },

      hash: {        SHA256: self.SHA256.bind(self)      },

      __exposedProps__: {        pk: "r",        hash: "r",      },    };

    return api;  },

  // Additional 'private' api methods  ...};

var NSGetFactory = XPCOMUtils.generateNSGetFactory([DOMCryptAPI]);

And, the contents of the manifest file:

component {3d92fb7f-be77-475c-992a-5235615f9189} DOMCrypt.jscontract;1 {3d92fb7f-be77-475c-992a-5235615f9189}category JavaScript-global-property mozCipher;1

“window.mozCipher” is the window property being added to each window

This does not currently work for content windows on Fennec/Firefox mobile, but works like a charm on Firefox 4.

Let me know if you have any questions as I have used this interface extensively.

Here is an mxr link to the console, which was written this way:

and the manifest:

>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:

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

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

>Console ideas

2011/02/22 — 2 Comments

>I recently filed bugs 635504 and 635502 in order to make Firefox’s Web Console customizable via the new Addon SDK and to create a global ‘Browser Console’ that lets you peek at all of the activity going on under the hood in Firefox.

The interesting exercise will be cannibalizing the Web Console to create a global console that displays all errors, css parse warnings, network activity and other events. The filtering interface will need even more options to cut through the density of messages. The cool part will be making commands – and perhaps APIs – that give you access to all of the services, observers, browser tabs and other Gecko bits currently running.

Live inspection of these objects will be a powerful tool for those interested in hacking on Firefox, but don’t know how to start.

The first customization of the Web Console we are planning is integration with Rob Campbell’s ‘Workspace’. I would like to see a console and workspace either side-by-side or be able to toggle between them, with the current console automatically providing a logging API.

I find the Workspace is already an essential tool when I start hacking something together – especially in the  ‘chrome’ context. The Workspace can save your snippets to files, so any commonly used tools and functions can be used as templates.

If you think of anything that would automate or make easier repeated tasks or techniques you use when hacking web apps or Firefox, let me know.

>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:

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: 

A demo (with xpi link) page is here:

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’?

>Wow, it is August already…


Many feedback reviews again this week, mainly on Console UI.
Landed patch for bug 579954 – “sometimes gBrowser cannot be accessed”


Working on bug 568629 “Small footprint, efficient global console service” with jst – we are making a console api that can be attached to all windows as needed, lazily. This is a component that will broadcast all console.log/info/warn/error calls to WebConsole, Firebug, etc…


Would like to know if recent e10s landings like bug 569227 will get activated in Firefox 4 betas at some point.
Still need to get some coordination on bug 567165 – would be great if this bug, or some semblance of this bug blocked a beta.

All in all, the UI is looking great thanks to Patrick Walton, and Julian and  Mihai are producing patches at an alarming rate. The integration of Firefox and Labs DevTools teams is exciting. Still a lot of work to do.