CIS 5371 Cryptography 3c. Pseudorandom Functions B

advertisement
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
Download