<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><b id="docs-internal-guid--7464a69-01b7-5e75-8b73-89673e4e1507"><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Dear mailing list,</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">A friend and me are working on a plugin that enables encryption on top of Facebook messaging. The idea is to encrypt messages before they leave the chat client, sending only the cipher to Facebook and decrypt the message on the receiver client, before it is displayed. The plugin automatically realizes which users have it installed and only encrypts these chats.</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Since the reliability of the cryptographic system is a crucial part of the design, I would to discuss the protocol here:</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">First, we use PBKDF2 to derive a 256 bit data block from a passphrase the user chooses and a salt (the username). We advise the user to use a long and hard-to-guess passphrase. We use Parvez Anandam’s JavaScript implementation [1].</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">This data block serves as the private key for a secp256r1 elliptic curve. We cannot use a random private key, as we have to be able to generate the same private key on different devices of the user. Given this private key, and another user’s public key (exchange through a public key server), we calculate the shared key as defined in the Elliptic curve Diffie–Hellman (ECDH) key agreement protocol:</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Given Alice’s private key ‘a’ and the elliptic curve ‘G’ (defined by the secp256r1 parameters), Alice’s public key ‘A’ is defined as:</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">A = a*G</span></div><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">(Analogously for Bob: B = b*G)</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">If Alice has her private key ‘a’ and Bob’s public key B, she can calculate the shared key S</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">S = a*B = a*b*G</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Bob has his private key ‘b’ and Alice’s public key ‘A’ to derive the same secret:</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">S’ = b*A = b*a*G = a*b*G = S</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Tom Wu’s library [2] is used to implement all ECDH related stuff.</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">The shared secret together with a random salt is used as a starting block to generate a 256bit AES key, which eventually encrypts the message. The cipher and the random salt are sent to the other person, so that he can reproduce the symmetric key. We use the Gibberish library for that purpose [3].</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Our process is also depicted here: <a href="http://goo.gl/ghzWSl">http://goo.gl/ghzWSl</a></span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Do you see a problem with that approach? I am looking forward to comments and concerns.</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Thanks!</span></div><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">Felix</span></div><p dir="ltr" style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; "> </span></p><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">[1] <a href="http://anandam.com/pbkdf2/">http://anandam.com/pbkdf2/</a></span></div><div style="line-height: 1.15; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">[2] <a href="http://www-cs-students.stanford.edu/~tjw/jsbn/">http://www-cs-students.stanford.edu/~tjw/jsbn/</a></span></div><span style="font-size: 15px; font-family: Arial; font-weight: normal; vertical-align: baseline; white-space: pre-wrap; ">[3] <a href="https://github.com/mdp/gibberish-aes">https://github.com/mdp/gibberish-aes</a></span></b></div></body></html>