CIS 5371 Cryptography
3c. Pseudorandom Functions
Based on: Jonathan Katz and Yehuda Lindell Introduction to Modern Cryptography
1
Definition
โข A ๐๐๐ฆ๐๐ ๐๐ข๐๐๐ก๐๐๐ ๐น is a two input function
โ
โ
โ
๐น โถ 0,1 × 0,1 โ 0,1
where the first input is called the key, denoted ๐,
.and the second is just called input.
2
Definition 3.23
โข
Let ๐น be an efficient length preserving keyed
function. ๐น is a pseudorandom function if
๏ข PPT distinguishers D, ๏ค a negl function
such that
| Pr ๐ท๐น๐
โ
1๐ = 1 โ Pr ๐ท ๐
โ
1๐ = 1 | โค negl(๐)
โ
where ๐ โ 0,1 is chosen uniformly at random
and f is chosen at random from the set of all
functions mapping n-bit strings to n-bit strings.
3
A secure fixed length
encryption scheme
๐น๐๐๐ โ ๐๐๐๐๐๐ ๐ ๐ก๐๐๐๐ ๐
๐๐ ๐๐ข๐๐๐๐๐๐๐๐
๐๐๐ฆ๐๐ ๐๐ข๐๐๐ก๐๐๐
๐๐๐
๐๐๐๐๐๐ก๐๐ฅ๐ก
๐๐๐
๐๐๐โ๐๐๐ก๐๐ฅ๐ก
4
Existence of pseudorandom
functions
โข We cannot prove that pseudorandom
functions exist!
โข In practice there exist very efficient
primitives called block ciphers that are
widely believed to behave as
pseudorandom functions.
5
CPA secure encryption using PRF
Protocol ฮ = (Gen, Enc, Dec)
Let ๐น be a pseudorandom function. Define a
private-key encryption scheme for messages of
length ๐ as follows:
โข Gen: on input 1๐ choose ๐ ๏ฌ {0,1}๐ uniformly at
random and output ๐ as key.
โข Enc: on input a key ๐ ๏ {0,1}๐ and a message
m๏{0,1}๐ , choose choose ๐ ๏ฌ {0,1}๐ uniformly at
random and output the ciphertext
๐ โ ๏ก๐, ๐น๐ ๐ ๏
๐๏ฑ .
โข Dec: on input a key ๐ ๏ {0,1}๐ and a ciphertext
c = ๏ก๐, ๐ ๏ฑ, output the plaintext
๐ โ ๐น๐ ๐ ๏
๐ .
6
Theorem 3.25
Let ๐น be a pseudorandom function.
Then protocol ๏ is a fixed-length private-key
encryption scheme for messages of length n that
has indistinguishable encryptions under CPA.
7
A secure fixed length encryption
Proof
Let ฮ be an encryption that is exactly the same
as ฮ but that uses a truly random function ๐.
Then,
โ Adversary A (even inefficient) that makes at
most ๐ ๐ queries to the oracle, we have
Pr PrivK
cpa
1
๐(๐)
๐ด, ฮ ๐ = 1 =
+ ๐+1
2
2
8
A secure fixed length encryption
Proof
We have: Pr PrivK
Let
cpa
๐ ๐ โ Pr[PrivK
cpa
๐ด, ฮ ๐ = 1 =
1
2
+
(๐ด, ฮ ) ๐ = 1] โ
1
2
.
Then Pr[PrivK cpa (๐ด, ฮ )
๐ = 1] =
1
2
๐(๐)
.
2๐+1
+ ๐(๐).
If ๏ฅ is negligible then we should not be able to
distinguish these.
Otherwise a gap between them would make it
possible to distinguish truly random from
pseudorandom.
9
A secure fixed length encryption
Reduction
Distinguisher D with oracle O: {0,1}๐ ๏ฎ {0,1}๐
Adversary A with
Protocol ฮ or ฮ
1๐
1๐ , ๐๐๐๐๐๐ O
Choose ๐ ๏ฌ {0,1}
uniformly at random
Query O ๐ to get ๐
๐
๐๐๐๐๐ฆ๐๐ก ๐
(๐, ๐ ๏
๐)
Query encryption oracle to
get encryptions of chosen
plaintexts
๐0 , ๐1
๐๐กโ๐๐: (๐, ๐ ๏
๐)
1 if ๐ โฒ = ๐
0 if ๐ โฒ ๏น ๐
choose a random bit ๐
Query O ๐โฒ to get ๐ โฒ
return ๐๐ = ๏ก๐โฒ, ๐ โฒ ๏
๐๐ ๏ฑ
๐๐
Repeat: Query to get
encryptions of chosen
plaintexts
๐โฒ
10
A secure fixed length encryption
Proof
From,
Pr ๐ท ๐น๐ (โ) 1๐ = 1 = Pr[PrivK
cpa
Pr ๐ท ๐(โ) 1๐ = 1 = Pr[PrivK
cpa
1
(๐ด, ฮ )(๐) = 1] = 2 + ๐ ๐
and
๐ด, ฮ
๐ = 1] .
Then,
| Pr[๐ท๐น๐(โ) 1๐ = 1 โ Pr[๐ท ๐ (โ) 1๐ = 1]| โฅ
โฅ
1
2
+ ๐ ๐ โ
1
2
๐ ๐
โ ๐+1
2
= ฮต ๐
๐(๐)
โ ๐+1
2
that must be negligible.
So ฮต ๐ is negligible.
11
A secure variable length
encryption
The messages ๐1 , . . . , ๐๐ can be securely
encrypted as
๏ก๐1 , ๐น๐ ๐1 ๏
๐1 ๏ฑ , . . . , ๏ก๐๐ , ๐น๐ ๐๐ ๏
๐๐ ๏ฑ.
12
Corollary 3.26
Let ๐น be a pseudorandom function.
Then the scheme sketched in the previous slide
is an arbitrary length private-key encryption
scheme that has indistinguishable encryptions
under CPA.
13
Pseudorandom permutations
โข
Let
โ
โ
โ
๐น โถ 0,1 × 0,1 โ 0,1
be an efficient, length preserving, keyed function.
๐น is called a ๐๐๐ฆ๐๐ ๐๐๐๐๐ข๐๐ก๐๐ก๐๐๐ if for every ๐,
the function ๐น๐ โ is one-to-one ๐ ๐ ๐น ๐๐ a ๐๐๐๐๐๐ก๐๐๐ .
โข A keyed permutation is efficient if there is a
polynomial-time algorithm that will compute
function ๐น๐ โ1 ๐ฅ given ๐ and ๐ฅ .
โข A pseudorandom permutation is defined in a
manner analogous to Definition 3.23, by replacing the
term โfunctionโ by โpermutationโ.
14
Definition 3.28
Strong Pseudorandom permutations
โข
Let F be an efficient keyed permutation. We say that
๐น is a strong pseudorandom permutation if,
๏ข PPT distinguishers D, ๏ค a negl function such that
| Pr
โ1
๐น
โ
,
๐น
(โ)
๐
๐
๐ท
1๐
= 1 โ Pr
โ1 (โ)
๐
โ
,๐
๐ท
1๐ = 1 |
โค negl(๐)
where ๐ โ {0,1}โ is chosen uniformly at random and f
is chosen at random from the set of all permutations
on n-bit strings.
โข The analogue for strong pseudorandom permutations
are block ciphers.
15
Pseudorandom permutations
modes of operation
1. Electronic Code Book (ECB)
2. Cipher Block Chaining (CBC)
3. Output Feedback (OFB)
4. Counter(CTR)
16
Pseudorandom permutations
๐1
๐2
๐3
๐น๐
๐น๐
๐น๐
๐1
๐2
๐3
Electronic Code Book (ECB)
17
Pseudorandom permutations
IV
IV
๐1
๐2
๐3
๏
๏
๏
๐น๐
๐น๐
๐น๐
๐1
๐2
๐3
Cipher Block Chaining (CBC)
18
Pseudorandom permutations
IV
๐น๐
IV
๐1
๏
๐1
๐น๐
๐2
๏
๐2
๐น๐
๐3
๏
๐3
Output Feedback (OFB)
19
Pseudorandom permutations
ctr
๐1
ctr
ctr+1
ctr+2
ctr+3
๐น๐
๐น๐
๐น๐
๏
๐1
๐2
๏
๐3
๐2
๏
๐3
Counter mode (CTR)
20
Pseudorandom permutations
modes of operation
Electronic Code Book (ECB)
๐1 , ๐2 , โฆ , ๐๐ ๏ฎ ๐น๐ ๐1 , ๐น๐ ๐2 , โฆ , ๐น๐ ๐๐
Encryption is deterministic : no CPA-security
Worse: ECB-mode does not have indistinguishable
encryptions in the presence of an eavesdropper: if
a block is repeated in the plaintext, the same block
will be repeated in the ciphertext.
21
Pseudorandom permutations
modes of operation
Cipher Block Chaining (CBC)
๐๐ = ๐น๐ (๐๐โ1 ๏
๐๐ ).
Encryption is probabilistic . ๐น๐ must be invertible.
It has been shown that we get CPA-security if ๐น๐
is a pseudorandom permutation.
Drawback: encryption is sequential.
[Chained CBC: the last block of the previous ciphertext is the
IV of the next ciphertext. Used in SSL 3.0 & TLS 1.0]
22
Pseudorandom permutations
modes of operation
Output Feedback (OFB)
๐๐ = ๐น๐ (๐๐โ1 ), ๐๐ = ๐๐ ๏
๐๐ .
Unsynchronized stream-cipher mode.
Encryption is probabilistic.
It can been shown that we get CPA-security if
๐น๐ is a pseudorandom permutation.
Drawback: both encryption and encryption are
sequential.
23
Pseudorandom permutations
modes of operation
Counter(CTR) -- randomized counter mode
๐๐ = ๐น๐ (ctr + ๐), ๐๐ = ๐๐ ๏
๐๐ ,
๐น๐ need not be invertible.
Encryption is probabilistic .
It can been shown that we get CPA-security if ๐น is
a pseudorandom function.
Both encryption and encryption can be fully
parallelized.
We do not require that ๐น is a permutation (that is,
it need not be invertible).
24
Chosen Ciphertext Attacks (CCA)
In a CCA the adversary not only can encrypt
messages of his choice (CPA) but also can decrypt
ciphertexts of his choice (with one exception
discussed later).
Formally this is captured by giving the adversary
access to a decryption oracle (as well as the
encryption oracle).
Let ๏= (Gen, Enc, Dec) be a private-key encryption
scheme, ๐ด an adversary and ๐ the value of the
security parameter.
25
CCA indistinguishability experiment
cca
PrivK (A, ฮ )(๐)
1.
3.
4.
3.
A key ๐ is generated running Gen 1๐ .
The adversaryA is given input 1๐ and ๐๐๐๐๐๐ ๐๐๐๐๐ ๐ ๐ก๐
En๐๐ โ ๐๐๐ De๐๐ โ ๐๐๐ outputs a pair of messages ๐0
and ๐1 of the same length.
A random bit ๐ ๏ฌ 0,1 is chosen and then a ciphertext
๐๐ ๏ฌ En๐๐ ๐๐ is computed and given to A.
The adversary A continues to have ๐๐๐๐๐๐ ๐๐๐๐๐ ๐ ๐ก๐
Enc๐ โ ๐๐๐ De๐๐ โ ๐๐ข๐ก ๐๐ ๐๐๐ก ๐๐๐๐๐ค๐๐ ๐ก๐ ๐๐ข๐๐๐ฆ ๐ท๐๐๐ โ
on the challenge ciphertext ๐๐ itself. Eventually A
outputs a bit ๐ โฒ .
The output of the experiment i๐ 1 if ๐ = ๐ โฒ and 0 otherwise.
26
Indistinguishable encryptions
under CCA --Definition
A private-key encryption scheme ฮ has
indistinguishable encryptions under CCA if
โ PPT adversaries A, โ ๐ negl function with:
Pr[PrivK
cca
(A, ฮ )(๐)=1] โค
1
2
+ negl(n)
where the probabilities is taken over the
coins used in the experiment.
27
Insecurity of the encryption
schemes that we have studied
1. .All earlier discussed private-key encryption
schemes are not CCA-secure.
2. Example.
Let ๐ โ ๏ก๐, ๐น๐ ๐ ๏
๐๏ฑ , and suppose A chose๐
๐0 = 0๐ and ๐1 = 1๐ , to get the ciphertext ๏ก๐, ๐ ๏ฑ. The
adversary flips the first bit of ๐ to get ๐ โฒ an asks for the
plaintext of ๐ โฒ = ๏ก๐, ๐ โฒ๏ฑ โ ๐ .
If he gets 10๐โ1 then ๐ = 0; if he gets 01๐โ1 then ๐ = 1.
4. CCA implies non-malleability : by trying to modify the
ciphertext the result is either an invalid ciphertext or one
that decrypts to a plaintext that has no relation to the
original.
28
© Copyright 2026 Paperzz