Here's a simple quick demo of moving a secret credential from one
machine to another, through a basic HTTP-based storage server, using the
J-PAKE exchange protocol. The HTTP server allows the two machines to
live behind NAT boxes and not speak directly to each other.

The demo uses python modules that I have lying around, which you will
probably need to unpack and put on your PYTHONPATH to make it work:

 pycryptopp (for AES): http://tahoe-lafs.org/trac/pycryptopp/
 python-jpake (for J-PAKE): http://github.com/warner/python-jpake
 Twisted (for HTTP server): http://twistedmatrix.com/trac/

 (both pycryptopp and Twisted are on PyPI and can be easy_installed.
 python-jpake cannot. I've included a copy of pycryptopp and
 python-jpake in this tarball. Twisted is too large. It would probably
 be easy rewrite the server to use the stdlib wsgiref.simple_sever
 library instead of Twisted).

To run the demo:

 0: Pick a channel name (like "CHANNEL"), and pick the credentials (like
    "CREDS"). In a real exchange, the channel name would derive from the
    nonce, and the credentials would be the private signing key that
    you're trying to copy from the sending client to the receiving
    client.

 1: Set the HTTP server running with:
      % twistd -y server.py
    That will daemonize the server and emit messages to twistd.log . You
    can terminate the daemon with "kill `cat twistd.pid`" . Or, you can
    run it non-daemonized with "twistd -noy server.py", and messages go
    to stdout.

 2: In one shell, start the sending client:
      % python client.py CHANNEL CREDS
    It will tell you a secret word.

 3: In a second shell, start the receiving client:
      % python client.py CHANNEL
    It will ask you for the secret word.

The two clients will exchange messages through the HTTP server, and when
the dust settles, the receiving client will print out the credentials.

The demo is hardwired to use localhost port 9001. The HTTP server
creates a "channel" for each name, which is an append-only list of JSON
messages. The sending client deletes the channel when the exchange is
complete. The clients poll the server once per second.

The exchange requires roughly 3 message roundtrips.

 -Brian Warner, warner@mozilla.com, 16-Jun-2010
