Recently, I had an OpenVAS scan report that a TLS connection to Postfix used a temporary key size of 2040 bits, instead of the 2048 bits that I have set for my key size, and I have perfect forward secrecy cipher suites enabled.

As part of that, I did some research on DH parameters, and according to this, I need to have my DH parameters and private key size set the same: https://www.keylength.com/en/4/

I can see now that I accidentally left my DH parameters set to 4096, while my private key is 2048 bits. Could that mismatch cause the issue with the temporary server key being too small? I'm regenerating my dh parameters now so that they match (and rescanning the server to see if it's reproducible), but want to know if there's anything else that could cause that.


There is no mathematical connection between the key exchange and the authentication part of the TLS handshake. TLS handshake just needs some way to do Diffie Hellman which is secure and some way to do end-point / counterparty authentication which is secure.

So you can do DHE with at least 2048bit group, or ECDHE with NIST P-256, or X25519 as the key exchange part, and you can do RSA with at least 2048bit key with PKCS#1 v1.5 padding or RSA-PSS padding, or ECDSA with NIST P-256, or in the future ed25519/ed448 as the authentication part. [1]

You are free to mix and match DHE with ECDSA, ECDHE with RSA, ECDHE and ECDSA with different curves, DHE and RSA with different number of bits, whatever.

Each algorithm has its own requirements for how to do it securely, as long as each part is secure you're good.

There is an argument that each part should match the strength of the others, as the weakest part will naturally be attacked so extra strength on the part which is not weakest is just wasted effort / resources (basically, don't invest in extremely strong door if you have paper walls).

So people say that if your TLS Record Protocol / bulk encryption have 128bit equivalent symmetric encryption and MAC (which is what you get with AES-128-GCM which is what you should be using), the key exchange and authentication should be about 128bit equivalent strength. This would be 256bit ECC (so exactly ECDHE and ECDSA with NIST P-256 or X25519 with Ed25519) or 3072bit RSA with DHE. But most people use 2048bit RSA (which is secure enough, though it is considered only 112bit symmetric equivalent). So you can use 2048bit DHE or 3072bit DHE. 4096bit DHE would be overkill, but would work.

Against the argument of matching algorithmic strength, I have to say that matching auth and key exchange strength is wrong because a certificate used only for auth needs only to stay unbroken until its date of expiry. Key exchange needs to stay unbroken as long as the confidentiality of the data needs to stay unbroken. So if 10 years from now the enemy can break your current certificate which is used only for auth, you don't really care because they can't MiTM your connections 10 years in the future using a certificate that by then has long expired. But if they can break the key exchange they can decrypt the data, and if the data needs to stay secret even 10 years from now, that's a problem. [2]

Thus, there is logic in making DHE stronger than the key of the certificate, and 3072bit DHE with only 2048bit RSA cert makes some sense, though most people don't need it.

In summary, use openssl dhparam 2048 to generate a file that postfix smtpd will use (configuration confusingly called smtpd_tls_dh1024_param_file). It's fine to use 2048, 3072 or 4096 here with any certificate. That command does take a while to finish, let it.

1 - You can even do PSK which is symmetric authentication instead of asymmetric authentication, but ~nobody does this. You can do RSA encryption to do both key exchange and auth, though you don't get forward secrecy so it's not allowed for HTTP/2 and in TLS 1.3 (and you shouldn't do this even when it's allowed).

2 - If you allow RSA key exchange that means the key for the certificate was used for key exchange and it needs to be kept safe for as long as data confidentiality matters, so no losing the keys for expired certificates on old hard drives you throw away. This is the argument for only support PFS cipher suites.

  • Nit: you can mix and match kx and auth in TLS1.3, but not fully in earlier versions where both are controlled by the ciphersuite and there are no ciphersuites that combine DHE with ECDSA or ECDHE with DSA aka DSS. (There are for both of DHE,ECDHE with RSA.) – dave_thompson_085 Mar 31 at 11:17

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.