RSA Padding Schemes: PKCS#1 v1.5
What you'll learn: Why encrypting data directly with RSA is dangerous and how PKCS#1 v1.5 padding attempts to fix it.
The Problem with Raw RSA
Remember that RSA encryption is just mathematical operations on numbers. If you encrypt the same message twice with the same public key, you get identical ciphertexts — that's a huge information leak! Even worse, raw RSA is deterministic and vulnerable to mathematical attacks.
Think of it like sealing an envelope with just tape — anyone can see the outline of what's inside.
What PKCS#1 v1.5 Adds
PKCS#1 v1.5 (Public-Key Cryptography Standards #1 version 1.5) adds padding with random bytes before RSA encryption. The format looks like:
0x00 || 0x02 || random_bytes || 0x00 || actual_message
- Fixed header bytes (0x00, 0x02) identify this as encryption padding
- Random bytes (at least 8 bytes) make each encryption unique
- Separator byte (0x00) marks where the message starts
- Your actual message follows
This randomness means encrypting "hello" twice produces completely different ciphertexts — much better!
The Remaining Vulnerability
Unfortunately, PKCS#1 v1.5 has a critical flaw: padding oracle attacks. If a server tells you whether padding is valid or invalid (even through timing differences), attackers can decrypt messages by sending thousands of modified ciphertexts and observing the responses. This is called the Bleichenbacher attack, discovered in 1998.
Modern systems use OAEP padding instead, which you'll learn about later.
Key Takeaway: PKCS#1 v1.5 padding adds essential randomness to RSA encryption, preventing identical ciphertexts, but remains vulnerable to padding oracle attacks — it's deprecated for new systems but still widely deployed in legacy software.