152 points · by lucb1e · 14y ago · 44 comments
1. C & S exchange messages to agree on versions, ciphersuites, and nonces.
2. S->C certificate, which includes an RSA public key.
3. C verifies certificate against its local cache of CA roots.
4. C->S random secret encrypted under the RSA key (the "pre-master secret").
5. C & S derive (the same) set of MAC keys, crypto keys, and crypto parameters.
6. C & S verify every message of the handshake with the MAC keys.
Other useful things to know:
* SSL/TLS operates over a "record layer" of TLV-style messages. The TLS record layer itself supports fragmentation, which is a little crazy.
* The server can ask the client to send a certificate too; this is common on backend connections and unfortunately not common with browsers, because the UI is terrible.
* Less commonly, C & S can opt for a "DHE" (ephemeral Diffie-Hellman) key exchange, in which the RSA key from the certificate is used to sign a DH key exchange (DH allows both sides to use random public keys instead of long-term fixed keys, but suffers from exposure to MITM attacks --- the RSA key from the cert "breaks the tie" in a MITM situation, making the exchange secure). This has the advantage of ensuring that even if an attacker has been recording all your traffic for years, she can't compromise a server's private key and then decrypt older connections. This is called "forward secrecy".
* The two common cipher suites used on most connections are AES in CBC mode and RC4. AES-CBC chunks plaintext into 16 byte blocks, padding the last block if there are insufficient bytes to fill it. Until TLS 1.1, TLS ran CBC in a continuous stream over the whole connection, using the last block of the most recent message as the IV for the next, which gave rise to the BEAST flaw. RC4 is a stream cipher that encrypts byte-at-a-time --- but nobody trusts RC4 much.
* TLS 1.2 (IIRC) introduces AES-CTR, which runs AES as a stream cipher.
in step 4 above the client sends data to the server that is encrypted with the server's public key. you don't have the server's private key, so you cannot decrypt that data. but the server can. so you cannot duplicate things, even if you are watching.
[edited to swap client/server roles]
It is a thorough read and not the easiest, but you can always pick and choose what chapters you're interested in. I highly recommend it. You can buy it from Amazon here (not an affiliate link):
Heaven forbid anyone but Amazon gains financially from your recommendation.
http://www.theregister.co.uk/2011/04/11/state_of_ssl_analysi...
If you haven't seen any of Marlinspikes presentations, you are missing out on some fascinating stuff.
Moxie @ Defcon 19: http://www.youtube.com/watch?v=xIiklPyS8MU
What's broken about SSL/TLS is the current CA model. Since SSL/TLS was introduced, we've been running with almost exactly the same trust "UX": a hidden browser config panel listing a series of complicated-sounding trusted root CAs, each with the authority to sell or transfer their business to some other entity, or even to delegate the authority to sign certificates to other organizations.
That's absurd; it's a security model that clearly can't work in the real world --- and, more, demonstrably hasn't worked. SSL CA's have been caught red-handing selling their authority for dubious reasons. For instance, Trustwave sold a CA=YES certificate to an undisclosed third-party corporation solely for the purpose of making it easier (not "possible" but merely easier) for that corporation to monitor their own users.
We need a radical rethinking of the UI/UX and trust model behind SSL/TLS, and Moxie's idea of decentralizing that trust --- so that, say, the ACLU could operate a sort of CA root that would vouch for Verisign's signatures on core ecommerce sites but not accept a crazy delegation from Iran.
The protocol, on the other hand, is for all its warts the best-tested crypto protocol in possibly the history of computing. Baby & bathwater, and all that.
It's too bad, it sounds like a very good idea.
Thanks
The private-public key encryption concept explained through mixing paint: http://www.youtube.com/watch?v=6NcDVERzMGw#t=147s (Starts at about 2:20.)
Reputation is mark of making _good_ contributions, and is something that every site has utility for, including HN.