Definition
A pseudorandom permutation (PRP) is a keyed permutation: for each secret key, an efficient algorithm §14.1 rearranges the set of all -bit blocks, so that every block is the output for exactly one input block, and a second efficient algorithm undoes the rearrangement with the same key. Its defining property is that nobody who lacks the key and has limited computing power can tell the PRP apart from a permutation chosen uniformly at random (every rearrangement equally likely) from all rearrangements of the -bit blocks. Block ciphers §15.3 are modeled as PRPs.
The idea
A block cipher encrypts one block, 16 bytes for AES (the Advanced Encryption Standard), under a secret key. The receiver holds the same key and must get back exactly the block that was sent. That works only if, under that key, no two different blocks encrypt to the same result. A map from a finite set to itself with this property is a permutation: a rearrangement of the set.
Picture a codebook for one key: two columns that pair each of the possible blocks with exactly one ciphertext block, where every ciphertext block also appears exactly once. Encryption looks a block up in the left column; decryption looks it up in the right column. The picture is inaccurate in one respect: for the book has lines and cannot be written down, so the cipher computes each line from the key when it is needed.
Invertibility is easy to get and worth nothing on its own. The identity map, which leaves every block unchanged, is a permutation. So is bitwise XOR (exclusive or) with the key, which flips each bit of the block where the key has a 1 bit. Security needs a second property: the codebook that the key selects must look, to anyone without the key, like a codebook chosen uniformly at random from all possible codebooks. There are possible codebooks, where , read “ factorial”, is the product , the number of ways to put items in order. For , writing down one codebook takes about bits, while an AES key has at most 256 bits. A key therefore selects one of a vanishingly small fraction of all codebooks, and the PRP property says that membership in this fraction cannot be recognized with feasible effort.
How it works
A PRP is a pair of algorithms. Encryption takes a key of bits and an -bit block and returns the -bit block . Inversion takes and an -bit block and returns , the unique block with .
Security is defined by the same kind of experiment as for a pseudorandom function §15.1: a game in which an adversary, the party that tries to tell two worlds apart, sends queries and receives answers, and must finally say which world it is in.
A challenger flips a fair coin in secret to choose the real or the ideal world.
Real world: the challenger picks a key uniformly at random and answers each query with .
Ideal world: the challenger answers each new input with a block chosen uniformly at random among the blocks not yet given as an answer, records the pair, and repeats the recorded answer for a repeated input. A table filled in this way, on demand, behaves exactly like a permutation chosen uniformly at random at the start.
The adversary outputs 1 or 0. Its advantage is the difference between the probabilities that it outputs 1 in the two worlds, taken as a positive number.
In a strong PRP experiment the adversary may also send inverse queries: in the real world they are answered with , in the ideal world with the inverse of the random permutation. The strong version models an attacker who can obtain decryptions of blocks of the attacker’s choice.
A random permutation and a random function behave alike until the random function gives two different inputs the same output, which a permutation never does. With queries such a repeat happens with probability at most , by the birthday bound §5.6. This is the PRP/PRF switching lemma, where PRF stands for pseudorandom function: a PRP with long blocks can be used wherever a PRF is needed, at that small extra cost.
Invertibility for every key can come from the structure of a cipher rather than from its parts. A Feistel network splits the block into a left half and a right half , and each round replaces by , where is a keyed function that need not be invertible. Given the output , the round is undone by computing . Luby and Rackoff proved in 1988 that three Feistel rounds with independent pseudorandom functions as give a PRP, and that four rounds give a strong PRP [362]. AES uses a different structure, in which every step is itself invertible; the AES round structure §15.4 entry describes it.
Worked example
A permutation and its inverse. Blocks of bits take values: 00, 01, 10, 11. Let one key select the permutation 00 10, 01 00, 10 11, 11 01. Each of the four values appears exactly once on the right, so reading the pairs backwards gives the inverse: 10 00, 00 01, 11 10, 01 11. A receiver of the ciphertext block 11 returns 10.
A map that cannot be decrypted. Change the second pair to 01 10. Now 00 and 01 both map to 10, and no block maps to 00. A receiver of 10 cannot tell which of the two blocks was sent.
Counting. A permutation of 4 values has 4 choices for the image of 00, then 3 unused values for 01, then 2 for 10, then 1 for 11: permutations. A function from the 4 values to the 4 values chooses each of the 4 images freely: functions. Only of all functions are permutations.
The switching cost, exactly. An adversary queries two different 2-bit inputs and outputs 1 if the two answers differ. A random permutation always gives different answers, so the adversary outputs 1 with probability 1. A random function gives the second input the first input’s answer with probability , so the adversary outputs 1 with probability . The advantage is . The switching bound gives , the same value.
The switching cost for AES. Here . After blocks, which is bytes or 64 GiB, the bound is , just below . After blocks it is close to : by then the absence of repeated outputs gives the permutation away.
A Feistel round undone. Take 4-bit blocks with 2-bit halves and a round function that is not invertible: , , , . For the input the round outputs . To undo the round, read from the left half of the output and compute . The input is recovered, although maps both 00 and 01 to 11.
Stated precisely
Let be a keyed function such that for every key the map is a permutation of and its inverse is efficiently computable from . Let be the set of all permutations of ; it has members. Write for the event that adversary , allowed to query , outputs 1, and when may query both and . With uniform over and uniform over , is a -secure PRP if for every that runs for at most steps and makes at most queries. is a -secure strong PRP if the same holds for , with queries in both directions counted.
Switching lemma. Let be a function chosen uniformly from all functions from to . For every adversary that makes at most queries, The two functions answer identically unless repeats an output, and among uniform -bit outputs a repeat has probability at most . Hence , where is the same difference of probabilities with in place of .
Why invertible. Decryption under is the map , which exists exactly when is one-to-one. A one-to-one map from the blocks to the same blocks produces different outputs, so it uses every block exactly once as an output (the pigeonhole principle) and is a permutation.
The security claims rest on these assumptions.
A uniform, independent, secret key. is chosen uniformly at random, independently of any other key, and does not leak.
Query access only. The adversary sees only the answers to its queries, not timing, power consumption or any other side channel §1.29.
Bounded resources: at most steps and queries.
Direction of queries. The plain definition gives the adversary no inverse queries; the strong definition gives them and counts them.
No block cipher in use has a proof of PRP security. For AES it is a conjecture supported by more than two decades of public cryptanalysis in which no attack on the full cipher has come near practical cost, and the security proofs of modes of operation start from that conjecture.
Limits and common mistakes
Invertible does not mean secure. Being a permutation is the format requirement and pseudorandomness is the security requirement. The identity map and XOR with the key meet the first and fail the second.
A PRP handles one block and is deterministic. Two equal blocks encrypted under one key give two equal ciphertext blocks, so applying a PRP block by block to a message reveals which blocks are equal. Messages need a mode of operation, as the block cipher and counter mode §15.5 entries explain.
Plain PRP security says nothing about an attacker who can obtain the inverses of chosen blocks. When a design lets an attacker have blocks of their choice decrypted, the strong PRP definition is the relevant one.
The never-repeat behavior limits how much data one key may process when the proof of a mode treats the cipher as a PRF. With -bit blocks the behavior becomes visible after about blocks. For 64-bit block ciphers such as Triple DES (Triple Data Encryption Standard) that is blocks, which is bytes or 32 GiB; the Sweet32 attack of 2016 [363] exploited this against long-lived encrypted connections. For 128-bit blocks the corresponding amount is blocks.
The model assumes independently chosen keys. Attacks that use encryptions under several keys with a known relation between them, called related-key attacks, lie outside it, as do leaks through timing or power consumption.
A PRP provides no integrity §1.9: it does not let a receiver detect that a ciphertext block was altered. Any altered block still decrypts to some block.
Questions answered
Why must a permutation be invertible for each key?
A keyed permutation must be invertible for each key because it models a block cipher, and decryption under a key must return exactly the block that was encrypted under that key. If two different plaintext blocks gave the same ciphertext block under some key, a receiver holding that key could not tell which of the two was sent, so that key could not be used. On the finite set of -bit blocks, a map from the set to itself that is one-to-one produces different outputs and therefore uses every block exactly once; such a map is a permutation, and every ciphertext block decrypts to exactly one plaintext block. Invertibility must hold for every key, because the key is chosen at random and any key may be the one in use, and the inverse must be efficient to compute with the key, because it is the decryption algorithm.
Invertibility is only the correctness requirement. The security requirement of a pseudorandom permutation (PRP) is separate: without the key, the permutation must be impossible to tell apart, with feasible effort, from one chosen uniformly at random. The identity map is invertible and offers no security at all.
Related entries: Pseudorandom function (PRF) (§15.1), Block cipher (§15.3), Birthday bound (§5.6), AES round structure (§15.4), Counter mode (CTR) (§15.5). Further reading: [47, 66, 362, 363].