Course contentsShow
← Security
Lesson 146 of 3,0524. Asymmetric Cryptography and PKIFree lesson

OAEP: Optimal Asymmetric Encryption Padding

Modern RSA padding with OAEP: how it provides semantic security and resistance to padding oracle attacks.

OAEP: Optimal Asymmetric Encryption Padding

What you'll learn: How OAEP fixes RSA's security vulnerabilities by providing randomized padding that prevents clever attacks.

Why We Need OAEP

Remember PKCS#1 v1.5 padding from the last lesson? It has weaknesses that attackers can exploit—especially padding oracle attacks where an attacker tricks a system into revealing whether padding is valid, slowly leaking information about encrypted messages.

OAEP (Optimal Asymmetric Encryption Padding) is the modern, secure replacement that fundamentally changes how RSA encryption works.

How OAEP Works

Think of OAEP like wrapping a gift in multiple randomized layers before putting it in a box:

  1. Randomness injection: OAEP adds random data to your message before encryption
  2. Hash-based mixing: It uses cryptographic hash functions to thoroughly scramble the message and randomness together
  3. Structural masking: The result looks completely random—even encrypting the same message twice produces different ciphertext

This randomization provides semantic security: identical plaintext messages produce different ciphertexts every time. An attacker can't tell if you encrypted "YES" or "NO" twice by comparing ciphertexts.

Protection Against Attacks

OAEP defeats padding oracle attacks because:

  • Attackers can't craft valid ciphertexts by manipulating bits
  • Invalid padding reveals no useful information about the plaintext
  • The hash functions create dependencies that make tampering detectable

It's like sealing your message with tamper-evident packaging—any modification breaks the entire structure in unpredictable ways.

Key Takeaway: OAEP is the secure RSA padding standard that uses randomness and cryptographic hashing to provide semantic security and eliminate padding oracle vulnerabilities—always prefer OAEP over legacy PKCS#1 v1.5 padding.