5
$\begingroup$

if the client and the server need to exchange keys and I can sniff it, wouldn't I be able to decrypt the data transported?

$\endgroup$

1 Answer 1

7
$\begingroup$

No, you can't; the reason you can't depends on the negotiated TLS ciphersuite:

  • The original ciphersuites had the server send to the client the server's RSA public key; the client selects a random value ("premaster secret"), and encrypts that value with the server's public key; it sends that encrypted value to the server. Now, these public keys have the property that anyone with the public key can encrypt, however only the holder of the private key can decrypt. Someone can listen in, and hear both the public key, and the encrypted value; however they won't be able to decrypt it. The server can, and and so both sides know a random value that no else else knows; they use that as part of the formula to derive the keys that protect the traffic.

  • Gaining in popularity are DHE ciphersuites; in these suites, both sides execute the Diffie-Hellman protocol. This protocol also has the property that both sides arrive at the same secret value (again dubbed the "premaster secret"), but someone listening in cannot.

And, it's actually more complicated than above, because there has to be protections that both sides (or, at least, the server) is who they claim they are; that generally involves certificates.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.