I have a question regarding the keyexchange happening in web browsers. If you check the certificate here on crypto.stackexchange you can go under details and see that the public key is type RSA (2048 Bits). Does this mean that StackExchange is generating a private key via RSA between them and me to encrypt my messages?


The RSA encryption algorithm implies two types of keys: a public key and a private key. The public key is composed from the public exponent $e$ and modulus $n$. The private key is composed from the private exponent $d$ and modulus $n$. The relationship between them is $(e,d)\ ≡\ 1\ (mod\ φ(n))$. To encrypt, you rise the plaintext to the power $e$ and to decrypt you rise the ciphertext to the power $d$ (both operations are done modulo $n$). More detalis here. The traffic between you and StackExchange is encrypted under the TLS protocol. The TLS protocol uses a hybrid encryption scheme. That is, you first generate a random key, say K, that you'll encrypt with RSA using the public key of StackExchange. The StackExchange will decrypt the key K using its private key. From now on you will both use a symmetric algorithm (AES 256) to encrypt your data. The encryption key for this symmetric algorithm will be the K key, which you previously encrypted using RSA. More detils about TLS here.

  • $\begingroup$ Okay thank you i think i got it. If i check google for example i can see that its tls protocol uses ecc as an asymmetric algorithmen right? $\endgroup$
    – Crptoo33
    Sep 16 '18 at 15:00
  • $\begingroup$ The part reading "you first generate a random key, say K, that you'll encrypt with RSA using the public key of StackExchange" usually does not hold. My connection to https://crypto.stackexchange.com is reported as "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 128 bits, TLS 1.2". An AES-128 key is negotiated using Elliptic-Curve Diffie-Hellman (with an RSA signature of authentication data made by the server and verified by the client), rather than chosen and enciphered by the client as described in this answer. $\endgroup$
    – fgrieu
    Sep 16 '18 at 15:05
  • $\begingroup$ There are also various issues with the description of RSA: padding is omitted, as well as the possibility of signing. The relation $(e,d)\ ≡\ 1\ (mod\ φ(n))$ uses a comma where multiplication is though, and some valid RSA keys do not match that relation, which should be $e\cdot d\equiv1\pmod{\lambda(n)}$ where $\lambda$ is Carmichael's function; see PKCS#1v2. $\endgroup$
    – fgrieu
    Sep 16 '18 at 15:17
  • $\begingroup$ so rsa and simple diffie hellman is very rarely used these days for key exchange? and thank you for your answer :) $\endgroup$
    – Crptoo33
    Sep 16 '18 at 15:28
  • $\begingroup$ The answer is the general idea of tls. I provided some links for details about padding and ECDHE $\endgroup$
    – mip
    Sep 16 '18 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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