← Cryptography guide

K036 / Asymmetric encryption, signatures and key exchange

RSA-OAEP

RSA OAEP padding · Survey date 2026-12-05

OAEP is a padding scheme for RSA encryption proposed by Bellare and Rogaway and standardized in PKCS #1 v2/RFC 2437.

CRYPTOGRAPHY LAB / K036

Cryptography Lab · RSA-OAEP

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Limited implementation

RSA-OAEP encoding / decoding only (SHA-256; no RSA exponentiation)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
OAEP is a padding scheme for RSA encryption proposed by Bellare and Rogaway and standardized in PKCS #1 v2/RFC 2437. Source document ↗
Classification and reversibility
Asymmetric RSA encryption with OAEP padding applied before encryption and removed after decryption. Source document ↗
Key or secret requirements
Uses RSA public/private keys; public key is not secret. Source document ↗
Operating principle and structure
Message, random seed and hash form the 0x00 / maskedSeed / maskedDB padding block using a Feistel-like structure and MGF1. Source document ↗
Key size, block size and parameters
For RSA modulus size k and hash length h_len, max plaintext is k − 2*h_len − 2. Source document ↗
Security strength and recommendation
New applications are required to support RSAES-OAEP. Source document ↗
Known attacks and vulnerabilities
Manger attack exploits errors revealing whether the first decrypted byte is zero; use constant-time decryption and a single error. Source document ↗
Standards and certification
Standardized in PKCS #1 v2 and RFC 2437. Source document ↗
Typical uses
Encrypts short data slightly smaller than modulus, on the order of hundreds of bytes. Source document ↗
Implementations, libraries and tools
Libraries such as Crypto++ allow selecting OAEP hash through template parameters. Source document ↗
Decryption or decoding
Call Decrypt with key object and OAEP padding such as OaepSHA256. Source document ↗
Advantages
Random seed gives probabilistic encryption; identical plaintext differs, and all-or-nothing structure releases information only when valid. Source document ↗
Limitations and cautions
OAEP does not authenticate messages; anyone can encrypt with the public key. Combine with signatures when authenticity is needed. Source document ↗
Distinguishing encryption, encoding and hashing
OAEP is RSA asymmetric encryption padding, not standalone hashing or encoding; hash/MGF are internal components. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Sender OAEP-pads and RSAES-OAEP-encrypts a short message with recipient public key. Recipient decrypts with private key and verifies/removes padding. Random seed makes each encryption differ.

Procedure

Check message length, OAEP-pad using hash/MGF1 and random seed, then RSA public-key encrypt. Private-key decrypt, verify/reverse OAEP and extract plaintext, returning a single padding error. Encoding is separate keyless format conversion.

Scenario

Wrap small symmetric/session keys or encrypt short confidential data. For large data use AES-GCM and protect only its key with RSA-OAEP in a hybrid design; combine digital signatures when authenticity is needed.

Pitfalls and alternatives

Distinguish from encoding/hashing; prefer RSAES-OAEP over PKCS#1 v1.5. Padding errors or timing differences expose Manger/Marvin-type attacks; use constant-time and uniform errors. Recommend keys ≥2048 bits, SHA-256 or stronger, short messages/hybrid encryption and separate signatures.

References