OAEP Explained: 5 Facts About the Padding That Saved RSA

OAEP explained in plain terms means understanding the padding that saved RSA, a scheme from 1994 that turns a message into a randomised block before the RSA maths touches it. The central question is why RSA needs padding at all when the maths already scrambles the message, and the answer is that raw RSA is deterministic, so the same message always gives the same ciphertext, and OAEP gives RSA the randomness it lacks, and that randomness is the whole point of the design.

OAEP is a padding scheme created by Mihir Bellare and Phillip Rogaway, presented at Eurocrypt in 1994. It encodes a message with a two-round Feistel network before RSA encryption, and it is built on the idea that a ciphertext should reveal nothing to probe, which means the design is meant for chosen-ciphertext attackers above all, and that focus is what makes it unlike the paddings of its era.

This article sets out five facts that explain what OAEP is, how it works, and where it runs in the real world.

Key takeaways

  • OAEP is a padding scheme from 1994, by Bellare and Rogaway.
  • It turns RSA from deterministic into randomised encryption.
  • It is a two-round Feistel network with hash masks.
  • It was standardised in PKCS#1 v2.0 in 1998.
  • It stops padding-oracle attacks by design.

What OAEP is

OAEP is a padding that turns a message into a randomised block with one unusual promise, and that promise is what makes it unusual among paddings. Every bit of the encoded block depends on every bit of the message and the seed, which means a flipped ciphertext bit randomises the whole decode, and because the decode is all or nothing, a tampered ciphertext yields noise.

Its signature feature is the two Feistel rounds. Most paddings just append bytes, but OAEP masks the data block with a hash of a random seed and then masks the seed with a hash of the masked block, which means the message and the randomness are tangled together, and because the tangling runs both ways, no part can be changed alone.

The design was a reaction to the Bleichenbacher attack. RSA with the old PKCS#1 v1.5 padding let attackers test whether a ciphertext decoded to a conforming block, so Bellare and Rogaway asked how a padding could remove anything to test, because an oracle with nothing to grade is no oracle at all, and that practicality is what made OAEP worth standardising.

It became one of the best-known paddings in the world, and it is named in every discussion of the field. OAEP was standardised in PKCS#1 v2.0 in 1998 and in RFC 8017, it is still the first example engineers meet when they learn that RSA needs help, which means the design survives as a tool even though it is more than thirty years old.

Our guide to SHA-3 explains the hash family OAEP’s mask function is built from, and our guide to Diffie-Hellman explains the key exchange that shares RSA’s public-key world.

How OAEP works

Everything starts with the label, which is hashed into the data block. OAEP hashes an optional label and places it at the front of the block, which means the label is bound to the message, and because the label is usually empty, most blocks start with the hash of nothing.

Each step begins with the padding string, which fills the space between label and message. OAEP pads the block with zero bytes and a single one byte, which means the message sits at the end, and because the padding is exact, the decoder can find the message by scanning for the one.

The seed mask is what makes the design work as a whole. OAEP generates a random seed and masks the data block with the mask generation function applied to it, which means the block is randomised, and because the seed is fresh every time, the same message encrypts differently on every run.

The seed mask spreads the effect further. OAEP masks the seed itself with the mask function applied to the masked block, which means the seed is hidden too, and because the two masks depend on each other, changing one bit changes everything.

The encoding is what turns the masks into a block. OAEP concatenates a zero byte, the masked seed and the masked block, which means the result is exactly the size of the RSA modulus, and because the leading zero keeps the number below the modulus, RSA can encrypt it directly.

The result comes from the RSA permutation, read out as a ciphertext. OAEP hands the encoded block to RSA, which means the ciphertext is a fixed size whatever the message, and that size is exactly what a recipient needs to decrypt and strip the padding.

A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it
A dark office desk with a laptop showing a glowing green cipher diagram, a brass key and a notebook beside it, shows how OAEP works: blocks take turns being masked and unmasked, round by round, until a ciphertext emerges.

Comparing OAEP with other RSA paddings

OAEP is one of several ways to pad RSA, and each was built with a different emphasis. PKCS#1 v1.5 is the old padding that simply appends bytes, raw RSA is the unpadded maths that encrypts the message as it is, and OAEP is the one built to be provably secure against chosen-ciphertext attack, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect OAEP PKCS#1 v1.5 Raw RSA
Randomness Fresh seed None None
Structure Feistel masks Fixed bytes None
Oracle resistance By design Vulnerable Not applicable
Standard PKCS#1 v2.0 PKCS#1 v1.5 None
Best for RSA encryption Legacy only Never use

The practical result is that OAEP is the right choice for RSA encryption, PKCS#1 v1.5 belongs to legacy systems only, and raw RSA should never be used at all.

Where OAEP is used

TLS uses it for RSA key transport. Older TLS versions that encrypt the premaster secret with RSA use OAEP, because a padding oracle in a handshake would leak the session, and that risk is the reason OAEP earns its keep in transport security.

Key wrapping uses it to move keys. Systems that encrypt a symmetric key under an RSA public key choose OAEP, because a wrapped key must survive tampering, and that survival is the reason OAEP appears in key management.

Libraries use it as the default RSA padding. Cryptographic libraries offer RSA-OAEP as the recommended mode, because the old padding is known broken, and that break is the reason OAEP appears in every serious toolkit.

Standards use it as the reference padding. PKCS#1 v2.2, published as RFC 8017, specifies OAEP as the RSA encryption padding, because a standard needs one safe choice, and that choice is the reason OAEP runs in real products rather than only in papers.

Teaching uses it as the padding example. Courses introduce OAEP when they explain that RSA alone is not a cryptosystem, because it is the clearest case of the idea in a real scheme, and a student who understands OAEP understands why padding matters.

Strengths and limits

The greatest strength of OAEP is its proof. A padding proven secure against chosen-ciphertext attack in the random oracle model gives RSA encryption a guarantee the old padding never had, and that strength is real, measured in the decades it has survived and confirmed by the standards that mandate it.

It is also a strength that the design is all or nothing. A ciphertext that decodes to noise when tampered with gives attackers nothing to grade, and that property is worth more than cleverness in a field where a padding that leaks a single bit is a padding nobody trusts.

The limits are real, though, and the biggest is the implementation. OAEP’s decoding has failure modes that can leak through errors or timing, which means a careless decoder reopens the oracle the padding closed, and a system that uses OAEP must implement it with constant-time care instead.

OAEP checklist

  • Use OAEP for RSA encryption, never for signatures or raw RSA.
  • Remember it is a two-round Feistel network with hash masks.
  • Note the seed is fresh and random on every encryption.
  • Compare it with PKCS#1 v1.5 to see two kinds of padding.
  • Study the masks, which are what make decoding all or nothing.
  • Check the hash, since MGF1 must match on both sides.
  • Keep real secrets behind proper key management, not padding alone.
  • Read RFC 8017 to see how the scheme was standardised.
  • Choose a constant-time decoder when OAEP must resist timing.

Frequently asked questions

What is OAEP in simple terms?

It is a 1994 padding that randomises a message with two hash masks before RSA encrypts it, so tampering with the ciphertext randomises the decoded message.

Who created OAEP?

Mihir Bellare and Phillip Rogaway, who presented it at Eurocrypt in 1994.

How is OAEP different from PKCS#1 v1.5?

The old padding appends fixed bytes that attackers could probe, but OAEP masks the message with a fresh random seed, so there is nothing to probe.

Is OAEP still secure?

It is proven secure in the random oracle model, though decoders must be constant-time, since error and timing differences can reopen an oracle.

Where is OAEP used?

In TLS key transport, in key wrapping, in cryptographic libraries, in the PKCS#1 standard, and in teaching about RSA.

When should I use OAEP?

Whenever RSA encrypts data, when a padding oracle must be closed, or when you study provably secure encryption.

The bottom line

OAEP explained in one line is this: the padding that saved RSA, a 1994 design of two Feistel rounds and fresh randomness that closed the padding oracle and taught the field that RSA alone is not a cryptosystem.

It is proof that randomness plus structure beats structure alone, and the reason it still matters is that every RSA padding designed since has been judged partly by the lesson OAEP taught.

This article is general information about how OAEP works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top