Skip to content

µChat: Encryption for private conversations…finally (10 day turn around ftw!)

July 4, 2011

I got the request for encrypted conversations almost immediately upon µChat’s release, but I didn’t have to time to hammer it out until this weekend (happy 4th of July everyone!). The code is pretty fresh, and I admittedly don’t have that much experience doing this in Javascript, but it feels pretty solid. I just can’t bring myself to go into the office to release on a three day weekend, so it won’t be available in the apps store until tomorrow around 10ish (+/- 3 alarm snoozes).

Friends are, as I’ve mentioned in the past, simply a common magnet link, and a couple shared RSA public keys. When you log on to µChat, you add the magnet links for each “friend”. When you connect to a peer, barring any foul play, its almost certainly your friend (Imagine two people agreeing to meet at a specific random place in an infinitely large forest). To avoid foul play, we send the peer a challenge message that we generate on the fly, which they must sign to verify their identity. We do the same for them and everyone’s happy. Its our friend after all! This has been at work since the release, but the code to do this stuff made adding per conversation symmetric encryption a lot simpler, and I don’t think I’ve thoroughly explained it yet.

The public keys that we distribute so that people can friend us, can also be used for the sake of encrypting private conversations. We encrypt half of a random AES password with their RSA public key, and send it to them with the conversation request. They also generate half of a password and send it back to us when they agree to chat. From that point both peers use the complete AES key to encrypt the conversation. It was suggested that I use Diffie–Hellman, however it was important, especially when chatting with your friends that you can identify their original identity (as I’ve mentioned in the past, you never knew precisely what their original identity was… you just know that its the same person). This means that while you don’t necessarily know your friend, you are at least sure that its them that you’re talking to.

That’s it! If you have any suggestions, please shoot them my way. Especially if you can make a compelling argument against the way that this was implemented. Otherwise, happy chatting!

 

Javascript libraries used…

Stanford Javascript Crypto Library (BSD /Gnu GPL v2+)…used for the AES encryption

http://crypto.stanford.edu/sjcl/

Tom Wu’s RSA implementation (BSD License)…rewrote the keygen to be asynchronous.

http://www-cs-students.stanford.edu/~tjw/jsbn/

Kenji Urushima’s RSA signing/verification implementation (MIT License)

http://www9.atwiki.jp/kurushima/pub/jsrsa/

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: