“You encrypt with the public key and sign with the private key… wait, is it the other way around?”
“HTTPS encrypts data with RSA, right?”
Questions like these come up often when talking about certificates. In fact, the second one is wrong. What encrypts the actual data in today’s TLS is not RSA but symmetric encryption.
In Part 1, we saw that TLS protects against the three threats of eavesdropping, tampering, and impersonation with separate components. In Part 2, we look at those components one by one. We use no math and focus on “which component protects what.”
▶ This part is also available as a YouTube video (about 21 min) (it is also embedded at the end of this article).
- Symmetric encryption (AES)
- Block cipher modes and authenticated encryption
- The key distribution problem
- Public key encryption (RSA and elliptic curves)
- Key exchange (DH and ECDHE)
- Forward secrecy and TLS’s hybrid design
- Hash functions (SHA-2 and SHA-3)
- Why MD5 and SHA-1 cannot be used
- MACs and digital signatures
- Signature algorithms (RSA, ECDSA, Ed25519)
- Key length and strength
- Random numbers
- Post-quantum cryptography (PQC)
- Think about it
- Summary
- Watch the video
- The Certificate Fundamentals series (11 parts)
Symmetric encryption (AES)
Symmetric encryption uses the same key for encryption and decryption. Picture a safe that opens and closes with a single key, with the sender and the receiver both using that same key.

It is light and fast, so symmetric encryption still does the encryption of the data itself, both in TLS and in disk encryption (such as BitLocker).
- The current standard is AES (standardized in 2001 as FIPS 197)
- It is a block cipher that splits data into 128-bit (16-byte) blocks and encrypts them
- You choose a key length of 128, 192, or 256 bits
- Many CPUs have dedicated AES instructions, so it runs very fast
DES, used in the past, was broken because its key was too short, and NIST stopped allowing 3DES (Triple DES) for encryption at the end of 2023.
The weakness of symmetric encryption is how to share the same key with the other party safely (explained later).
Block cipher modes and authenticated encryption
A block cipher such as AES changes character a great deal depending on how the blocks are chained (the mode of operation).

| Mode | How it works | Features and cautions | Where it is used |
|---|---|---|---|
| ECB | Encrypts each block on its own | Identical plaintext blocks give identical ciphertext, so patterns remain | Do not use |
| CBC | Mixes in the previous ciphertext block, then encrypts | Cannot detect tampering; a separate MAC is needed. Attacks that abuse padding have existed | TLS 1.2 and earlier, older products |
| CTR | Encrypts a counter value and XORs it with the plaintext | Can be parallelized and is fast. No tamper detection | A building block of GCM and others |
| GCM (AES-GCM) | CTR + a tag for tamper detection | Authenticated encryption (AEAD). Reusing a nonce (a one-time value) with the same key breaks it | Mainstream in TLS 1.2/1.3, IPsec |
| ChaCha20-Poly1305 | Stream cipher + MAC (RFC 8439) | AEAD. Fast even on devices without dedicated AES instructions | TLS 1.3, smartphones, WireGuard |
| XTS | Encrypts with a value that changes by position on the disk | For stored data. No tamper detection | Disk encryption |
As the penguin in the figure shows, ECB leaks patterns, so it is not used. NIST’s draft (SP 800-131A Rev.3) proposes ending the use of ECB for encryption.
Today’s mainstream is authenticated encryption (AEAD). It performs encryption and tamper detection in a single operation and creates a tag along with the ciphertext. If the tag does not match on the receiving side, the data is discarded. This tag is what protects the “integrity (not rewritten)” from Part 1.
TLS 1.3 can use only AEAD cipher suites (TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, and so on).
The key distribution problem
To use symmetric encryption, you must already hold the same key as the other party before communicating. The problem is how to hand that key over safely.

- Send it by email: unless the email path is secure, the key is stolen along with the message
- Send the password of an encrypted ZIP in a separate email: you only use the same path twice, so the security barely changes
- Hand it over in person: safe, but impossible with a stranger on the internet
On top of that, a separate key is needed for each partner, so for n people to communicate with one another you need n(n−1)/2 keys, which is 4,950 keys for 100 people.
In other words, you fall into a loop: handing over a key safely already requires a secure channel. This is called the key distribution problem. The next topics, public key encryption and key exchange, solved this problem.
Public key encryption (RSA and elliptic curves)
Public key encryption uses a pair of two keys.
- Public key: can be given to anyone
- Private key: held only by its owner
Data encrypted with the public key can be decrypted only with the paired private key.

As a padlock analogy, the public key is an open padlock that anyone can close, and the private key is the only key that can open it. You hand out the key that locks and never let the key that opens leave your hands. This way you do not need to hand over a decryption key, and the key distribution problem is avoided.
There are two representative methods.
- RSA (1977): relies on the difficulty of factoring large numbers
- Elliptic curve cryptography (ECC): relies on the difficulty of calculations on an elliptic curve (P-256, Curve25519, and so on). It gives the same strength with a much shorter key than RSA (RSA 3072-bit ≈ elliptic curve 256-bit)
However, public key encryption is orders of magnitude slower than symmetric encryption, and RSA can encrypt in one operation only data shorter than the key length (a few hundred bytes) (we try this in Part 3). So in practice it is used for handing over keys and for signatures. This is why “HTTPS encrypts data with RSA” at the beginning is wrong.
Key exchange (DH and ECDHE)
The way today’s TLS shares a symmetric key is key exchange.

In Diffie-Hellman (DH) key exchange (1976), each side creates a secret value and exchanges only a public value calculated from it. Combining the other side’s value with your own secret value gives the same value on both sides.
Here is the analogy with paint.
- Agree on a common color (yellow)
- Each side mixes in its own secret color (yellow + red = orange, yellow + blue = green)
- Exchange the mixed colors (orange and green)
- Mix your own secret color into the color you received, and both end up with the same brown
You cannot extract the original colors from a mixed color, so an eavesdropper cannot make the same color.
The version done on an elliptic curve is called ECDH, and the version that uses a one-time value for each connection is called ECDHE (the E stands for Ephemeral). In TLS 1.3, ECDHE such as X25519 is the standard.
However, DH does not verify the other party. To prevent the man-in-the-middle attack from Part 1, you need certificates and signatures.
Forward secrecy and TLS’s hybrid design
Up to TLS 1.2, there was also a method in which the client encrypted the key material it created with the server’s RSA public key and sent it (RSA key exchange).

With this method, if an attacker records the encrypted traffic and later gets the server’s private key, the attacker can decrypt all past traffic.
ECDHE, on the other hand, discards the per-connection secret value after use, so even if the private key leaks later, past traffic cannot be read. This property is called forward secrecy. TLS 1.3 removed RSA key exchange. The idea is not to keep a key that would hurt if it leaked in the first place.
Today’s TLS is a hybrid design that combines the following three things.
- Key exchange (ECDHE) creates the material for the symmetric key
- A certificate and signature verify that the other party is genuine
- From then on, the data is protected with symmetric authenticated encryption (AES-GCM and others)
Public key technology is used only at the start, and the actual data is protected with a symmetric key.
Key points
• With RSA key exchange, if the private key leaks, even recorded past traffic can be read
• ECDHE discards its one-time values, so past traffic stays protected
• TLS combines “key exchange + certificate and signature + symmetric AEAD”
Hash functions (SHA-2 and SHA-3)
A hash function calculates a fixed-length value (the hash value) from data of any length.

A hash function used in cryptography is required to have four properties.
- One-way: the original data cannot be recovered from the hash value
- Collision resistance: you cannot find different data that gives the same hash value
- A one-character difference in the original data changes the hash value completely
- The output length is fixed, regardless of the input length
The current standard is SHA-2 (SHA-256, SHA-384, SHA-512, and so on), and SHA-3 (2015, FIPS 202), which has a different structure, has also been standardized. Hashes are used for checking downloaded files, certificate fingerprints, preprocessing for signatures, and more.
For storing passwords, use dedicated methods that are deliberately slow to compute (PBKDF2, bcrypt, Argon2, and so on).
Why MD5 and SHA-1 cannot be used
What happens when collision resistance is broken?
| Year | Event | Meaning |
|---|---|---|
| 2004 | A collision (different data with the same hash value) is found in MD5 | Collision resistance was broken |
| 2008 | Researchers demonstrate that MD5 collisions can be used to create a fake CA certificate that browsers trust | Forging certificates became real |
| 2012 | The Flame malware forges a Microsoft signature using an MD5 collision and spreads disguised as Windows Update | It was used in a real attack |
| 2017 | SHAttered: the first SHA-1 collision. Google and CWI publish two different PDFs with the same hash value | SHA-1 was also practically broken |
| 2017 | Major browsers stop trusting server certificates signed with SHA-1 | SHA-1 disappears from public certificates |
| 2020 | SHA-1 is a Shambles: a chosen-prefix collision is used to forge PGP keys (computing cost about US$45,000) | Forgery with chosen content became possible |
| 2026 | Under the CA/Browser Forum requirements, SHA-1 signatures on certificates and CRLs are fully retired by September 15 | Exit from the public PKI |
If collisions can be created, you can have someone sign a harmless document and reuse that signature on a harmful document with the same hash value. MD5 and SHA-1 still work for checking accidental corruption, but for tamper protection and signatures, use SHA-256 or stronger.
MACs and digital signatures
Here is an important pitfall. Attaching a hash value alone does not prevent tampering. An attacker can rewrite the body and then recalculate and swap in the hash value as well.

So you attach a value that only a key holder can create.
- MAC (message authentication code): the sender and the receiver hold the same shared key, and a value is calculated from the body and the key. The representative is HMAC (RFC 2104). An attacker who does not know the key cannot produce a correct value, but you cannot tell which of the two key holders made it
- Digital signature: the sender signs the hash value of the body with their own private key, and the receiver verifies it with the public key. Only the owner of the private key can make it, so it can show the creator even to a third party
Note that “a signature is a hash encrypted with a private key” is an analogy that holds only for RSA and does not apply to ECDSA and others. “Encrypt with the public key, sign with the private key” from the beginning is the correct understanding.
Differences between a hash, a MAC, and a signature
| Item | Hash | MAC (HMAC) | Digital signature |
|---|---|---|---|
| Key used | None | Shared key (both parties hold the same key) | Sign with a private key, verify with a public key |
| Who can create it | Anyone | Everyone who has the key | Only the owner of the private key |
| Who can verify it | Anyone | Only those who have the key | Anyone who has the public key |
| What you learn | Accidental corruption | Whether it was tampered with | Whether it was tampered with, and who created it |
| Proof to a third party | Not possible | Not possible | Possible |
| Speed | Fast | Fast | Slow |
| Main uses | File checks, fingerprints | TLS key derivation and verification, API authentication | Certificates, TLS handshakes, code signing |
The difference is “who can create it” and “who can verify it.” HMAC is a MAC that uses a shared key and is a different technology from a signature, which uses public key cryptography. In TLS 1.3, signatures are used to verify the certificate and the handshake, and HMAC is used for key derivation (HKDF) and for the final handshake check (Finished).
Signature algorithms (RSA, ECDSA, Ed25519)
| Algorithm | Underlying mechanism | Features | Where it can be used and cautions |
|---|---|---|---|
| RSA (PKCS#1 v1.5) | RSA | The oldest, with high compatibility | Still the mainstream for signing public certificates. Not used for TLS 1.3 handshake signatures (an exception for client certificates on old devices: RFC 9963) |
| RSA-PSS | RSA | A newer format that adds a random value (salt). Has a security proof | Signatures when using an RSA key in TLS 1.3 |
| ECDSA | Elliptic curve (P-256 and others) | Small, fast keys and signatures. Needs a one-time random number for each signature | Can be used in public certificates. Reusing the random number leaks the private key |
| Ed25519 (EdDSA) | Elliptic curve (Curve25519 family) | Fast and does not depend on random numbers (deterministic). Hard to implement incorrectly | SSH keys, software signing. Cannot be used for public TLS certificates |
| ML-DSA | Lattice (PQC) | Considered unbreakable even by quantum computers. Signatures are large, several KB | FIPS 204 (2024). Use in certificates is still ahead |
Under the CA/Browser Forum requirements, the keys usable in public server certificates are only RSA (2048 bits or more) and ECDSA (P-256, P-384, P-521). The sizes of signatures actually made with OpenSSL 3.5 were 384 bytes for RSA 3072-bit, about 70 bytes for ECDSA P-256, 64 bytes for Ed25519, and 3,309 bytes for ML-DSA-65.
Key length and strength
| Security strength | Symmetric keys and hashes | RSA and DH / elliptic curves | Status (NIST and CRYPTREC) |
|---|---|---|---|
| 80 bits or less | 2TDEA, SHA-1 (for signatures) | RSA 1024 / 160 bits | Not allowed |
| 112 bits | SHA-224 | RSA 2048 / P-224 | Until 2030. Avoid for anything new |
| 128 bits | AES-128, SHA-256 | RSA 3072 / P-256, X25519 | Minimum from 2031 |
| 192 bits | AES-192, SHA-384 | RSA 7680 / P-384 | For long-term protection |
| 256 bits | AES-256, SHA-512 | RSA 15360 / P-521 | For long-term protection |
(Sources: NIST SP 800-57 Part 1 Rev.5 (2020), SP 800-131A Rev.2 (2019), the CRYPTREC Cryptographic Algorithm List (revised in March 2026, adding a PQC list that includes ML-KEM), and its “Criteria for Setting Cryptographic Strength Requirements (Algorithm and Key Length Selection)”)
- RSA 2048 has 112-bit strength, and under the standards in the table above (CRYPTREC and NIST SP 800-131A Rev.2) it can be used for new encryption and signing only until 2030. For keys you create from now on, choose RSA 3072 or larger, or P-256 or larger
- NIST IR 8547 became final in October 2026. It makes public-key schemes that are weak against quantum computers, such as RSA and elliptic curves (including 112-bit strength ones such as RSA 2048), deprecated after 2030 and disallowed after 2035. This schedule replaces the one planned in SP 800-57, under which 112-bit public-key schemes would be disallowed from 2031 (112-bit symmetric schemes are disallowed in 2030). SP 800-131A Rev.3 is still a draft, and items such as ending ECB are still proposals
Random numbers
The security of cryptography assumes that keys and nonces are made from unpredictable random numbers.

TLS also uses random numbers everywhere: for key pairs, ECDHE one-time values, and per-signature ECDSA values. If the random numbers are biased, security collapses even when the algorithm and key length are correct.
- 2008: A mistake in a fix to Debian’s OpenSSL left the source of randomness as little more than the process ID, so only tens of thousands of possible keys could be generated
- 2010: A game console used the same value for every ECDSA signature, so the private key could be computed from the signatures
- There are also cases where embedded devices just after startup lacked a source of randomness and ended up with duplicate keys
For random numbers, use the OS cryptographic random number generator (getrandom() on Linux, BCryptGenRandom on Windows), and do not use rand() or PowerShell’s Get-Random.
Post-quantum cryptography (PQC)
Finally, a topic a little further ahead. Once practical quantum computers exist, it is expected that today’s public key cryptography, such as RSA, DH, and elliptic curve cryptography, will be broken. The impact on symmetric encryption and hashes is relatively small and can be handled with longer keys (such as AES-256).

The pressing problem is the attack of recording today’s traffic and decrypting it with a future quantum computer (Harvest Now, Decrypt Later). For information that must stay secret for a long time, key exchange needs to be migrated first. Signatures can be switched in time if you switch before the day they can be broken.
- In August 2024, NIST standardized ML-KEM (FIPS 203) for key establishment, and ML-DSA (FIPS 204) and SLH-DSA (FIPS 205) for signatures
- In TLS, the hybrid key exchange X25519MLKEM768, which combines X25519 and ML-KEM-768, is used by major browsers and OpenSSL 3.5 and later (Part 7)
- Migrating signatures and certificates is still ahead
Remember: key exchange is the urgent part. Recorded traffic cannot be protected afterward.
Think about it
- Suppose your company has a practice of “encrypting a ZIP file and sending the password in a separate email.” How far does that solve the key distribution problem?
- Is the explanation “We distribute the SHA-256 hash value together with the file, so we can tell if it was tampered with” correct? Think about where the hash value is obtained from.
- Do any of your devices or servers use an RSA 1024-bit key, a SHA-1 signature, or TLS 1.2 RSA key exchange? What do you need to replace by 2030?
Hint: The tables “Differences between a hash, a MAC, and a signature (who can create and verify),” “Forward secrecy,” and “Key length and strength” in this article are good clues.
Summary
- The actual data is encrypted with symmetric encryption (AEAD such as AES-GCM). Do not use ECB
- Symmetric keys have the key distribution problem. Public key encryption and key exchange solve it
- Today’s TLS is ECDHE + certificate and signature + AEAD. ECDHE gives forward secrecy
- A hash value alone cannot prevent tampering. Only a digital signature can also show who created it
- Do not use MD5 or SHA-1. Choose RSA 3072 or larger, or P-256 or larger, for new keys
- PQC migration is starting with key exchange
Next time, we run the components seen here for real with openssl and PowerShell.
Watch the video
This part is also explained in a YouTube video (about 21 min).
All parts of the series are in the Certificate Fundamentals playlist on YouTube.
The Certificate Fundamentals series (11 parts)
All 11 parts with a reading guide: Certificate Fundamentals
- Why Do We Need Certificates?
- Cryptography basics (this article)
- Trying it with openssl and PowerShell
- Inside an X.509 certificate
- PKI and how trust works
- Certificate types and issuance
- How TLS works
- Lifecycle and automation
- Private PKI and the cloud
- Certificate troubleshooting
- Certificate design exercises
This series is the English edition of 【証明書入門】, originally written in Japanese.


コメント