Why do we need stronger encryption?
- To make keys more resilient to attack you need longer keys.
- There are newer ways of providing better private keys than just using large prime numbers. For example using the equation y**2= a* x**3 + b * x**2 + c*x + d. Which you may recognize as a cubic equation, but comes under the name of Elliptic Curves(EC). (For some values of a,b,c,d if you plot the curve it is an ellipse.) These Elliptic Curves with small keys are harder to crack than RSA with longer. They also use less resources during encryption and decryption.
- Originally public/private certificates were used for both authentication and encryption. This has the disadvantage that if I monitor your traffic for a year, then steal your private key (for example from the corporate backups) then I can decrypt all of your traffic. You need to use a technique called Forward Secrecy to prevent this. This gives assurances that session keys will not be compromised even if the private key of the server is compromised. With Forward Secrecy
- You use the public/private key for authentication, and generate a secret for the encryption. A technique called Diffie-Hellman(DH) can be used to agree an agreed common secret without a man-in-the middle being able to determine the secret key. See Wikipedia for a good description. This is good – but repeated conversations may use the same common secret and over repeated use, people may be able to guess your key.
- This problem is fixed by using Ephemeral(E) keys, known as one-time keys, which are valid for just one conversation. A second conversation will get a different secret key.
You need to support and use ECDHE (Elliptic Curves – Diffie-Hellman – Ephemeral) suites in order to enable forward secrecy (having the private key means you cannot decrypt the message) with modern web browsers. Avoid the RSA key exchange unless absolutely necessary.
What does a cipher spec tell us?
This is a good web site which tells you what the cipher spec means.
A cipher spec describes the techniques to be used for authentication, encryption and hashing the data. This is negotiated between the two ends when setting up a TLS handshake. The conversation is like “Client: I support the following cipher specs; Server: I like this one…”, or “Client: I support the following cipher specs; Server: hmm none match”
If you look at the names of cipher suites available with TLS v1.2 you find names like
- TLS_RSA_WITH_… this is for a key with public certificate generated with RSA
- TLS_ECDH_RSA_WITH… this is for a key with public certificate generated with Elliptic Curve(EC) and uses Diffie-Hellman(DH)
- TLS_ECDHE_ECDSA_WITH… this is for a key with public certificate generated with Elliptic Curve(EC) and uses Diffie-Hellman(DH) and Ephemeral key (E)
I found this document which is a good introduction to cipher specs TLS 1.2, TLS 1.3 etc
A cipher spec which I use a lot is TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
Let me break that down into the components
- TLS indicates the protocol ( old versions might have SSL)
- ECDHE : Key Exchange Algorithm. What is used to generate a secret number. Think of a telephone conversation between the UK and China. “Should we talk in English or Chinese”. “I prefer English”. “OK my information is …”. In this example we have ECDHE: Elliptic Curve, Diffie-Hellman, Ephemeral. This can be
- ECDSA: Authentication/Digital Signature Algorithm: What sort of certificate can be used.
- ECDSA the server public key is an Elliptic Curvesignifies. ECDSA is Elliptic Curve + Digital Signing Algorithm. The TLS spec says it should be signed using a CA with EC public certificate – but it works even if it is signed with an RSA certificate
- RSA the server public key is created with RSA public certificate. The TLS spec says it should be signed using a CA with EC public certificate – but it works even if it is signed with an ECDSA certificate
- “WITH” splits the authentication and encryption from the encryption of the data itself.
- AES_256_CBC indicates the bulk encryption algorithm: Once the handshake has completed, the encryption of the payload is done using symmetric encryption. They keys are determined during the handshake. AES_256 is a symmetric encryption with a 256 bit key using Cipher Block Chaining. (CBC is like using a “running total” of the data encrypted so far, as an input to the encryption). TLSv1.3 drops support for CBC; GCM can be used instead. It is faster and can exploit pipeline processors.
- SHA384 indicates the algorithm for hashing the message (MAC = Message Authentication Code)
- DSS is a different authentication algorithm. For example TLS_DHE_DSS… It also stands for Digital for Digital Signature Standard which covers all algorithms – so a touch confusing.
- Because RSA tends to be used for authentication and encryption, I think of TLS_RSA_WITH… as TLS_RSA_RSA_WITH. So the secret number generation algorithm is RSA, and then the certificate with an RSA public key is used.
For TLS 1.3 the cipher specs are like TLS_AES_256_GCM_SHA384 because the key exchange algorithm will be either ECDHE or RSA.