RSA-OAEP
RSA encryption with Optimal Asymmetric Encryption Padding (PKCS #1 v2)
Overview
RSA-OAEP is the padding scheme that makes RSA encryption secure against chosen-ciphertext attacks, specified in PKCS #1 version 2 (RFC 8017). It remains acceptable for interoperability but is classical and much larger and slower than modern alternatives.
Raw RSA encryption is deterministic and malleable. OAEP fixes this by encoding the message with a random seed through a two-round Feistel network built from a hash function and a mask generation function (MGF1), producing a padded block that is then raised to the public exponent modulo n. The construction is IND-CCA2 secure in the random oracle model, assuming the RSA problem is hard.
The main practical risk is implementation leakage. Manger's attack showed that if a decryptor reveals whether the first byte of the decoded block was zero, through error messages or timing, an attacker can decrypt ciphertexts. Decoding must therefore be constant time and must return a single uniform error. Three key sizes are present: 2048, 3072 and 4096-bit moduli. A 2048-bit key offers roughly 112-bit classical security and 3072-bit roughly 128-bit.
History
1977–2016RSA published by Rivest, Shamir and Adleman
PKCS #1 v1.5 published
RSA-OAEP published
Bleichenbacher's padding-oracle attack on PKCS #1 v1.5
PKCS #1 v2.2 published as RFC 8017
How it works
- KeyGen picks two large primes p and q, sets n = pq, and chooses e and d with ed = 1 mod lcm(p-1, q-1).
- Encrypt pads the message with a hashed label and random seed via MGF1 masking, then computes c = m^e mod n.
- Decrypt computes m = c^d mod n and reverses the OAEP encoding.
- Any decoding failure is reported identically, in constant time.
Security notes
Broken by a large quantum computer, and keys and ciphertexts are large compared with elliptic-curve or lattice schemes. Implementations that leak decoding errors or timing are vulnerable to Manger-style attacks. Prefer HPKE or a KEM for new designs.
Typical uses
Variants in NextSSL
3| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| RSA-OAEP-2048 rsa-oaep-2048 |
legacy | out 0–190 · pk 264–288 · sk 768–1344 · ct 256 · ctx 0–64 | RFC 8017 | root |
| RSA-OAEP-3072 rsa-oaep-3072 |
legacy | out 0–318 · pk 392–416 · sk 1152–1984 · ct 384 · ctx 0–64 | RFC 8017 | root |
| RSA-OAEP-4096 rsa-oaep-4096 |
legacy | out 0–446 · pk 520–544 · sk 1536–2624 · ct 512 · ctx 0–64 | RFC 8017 | root |
Frequently asked questions
Which RSA-OAEP variants does NextSSL include?
NextSSL registers 3 RSA-OAEP variants: rsa-oaep-2048, rsa-oaep-3072, rsa-oaep-4096.
Other public-key encryption
All 32Related
The NIST Merkle–Damgård hash family behind most of today's TLS, signatures and software
ML-KEMNIST's primary post-quantum key encapsulation mechanism, standardised in FIPS 203
HPKEHybrid Public Key Encryption: a KEM, a KDF and an AEAD combined per RFC 9180
RSA PKCS #1 v1.5 encryptionLegacy RSA encryption padding, exposed to Bleichenbacher padding-oracle attacks