Applied Cryptography

Week 4

IND-CPA security for Symmetric Encryption

IND-CPA

Doesn’t model integrity among other things.

PRP-PRF Switching Lemma

This is PRP security:

PRP sec

PRF security: distinguish between random key and a random function.
PRP security: distinguis between random key and random permutaiton.
A function is not a permutation, but a permutation is a function.

This is PRF security:

PRF

If the input is the same as from previous values, then output the same as then, if not then choose new function. Did not get this fully.

Lemma:
The absolute difference between these definitions is q2/2n+2.
(The “+2” is from the advantage definition to normalize so it goes from 0 to 1)

gjemli

Pr[b=0] = 1/2
Pr[b=1] = 1/2
Pr[b’=1|b=0] = probability that b’=1, given that b=0

proof

Proof of PRF switching lemma:

proof

proof2

Both games together: (Always the same except a repeated value occurs in G2 as Yi)

proof

proof

Difference Lemma

difference lemma

Complete the switching lemma proof

proof

These 2 lemmas occur again and again and again so try to understand it.

Proof of Security for CTR mode

IND-CPA security for CTR mode: G0

cpasec

IND-CPA security for CTR mode: G1

cpasec

This is no longer using a block cipher, he is using a random permutation. The adversary can’t tell a difference between game G0 and G1. Any adversary that could, he could then distinguish the block cipher from a random permutation, that would break the security, that is not possible.

IND-CPA security for CTR mode: G2

cpasec

Here we change the random permutation with a random function.

IND-CPA security for CTR mode: G3

cpasec

Here the advantage of the adversary is 0. This is essentially a one-time pad.
As long as there is no repeating counter value between G2 and G3, then they are equal (can’t tell them apart).

Intuition of the images:

Formal proof

proof

bounding |p0 - p1|

img

The IND-CPA challenger outsources the ciphertext it needs to encrypt a message to the PRP challenger C.

If d = 1 in the PRP challenger, then its the same game as G1. Because it just does a random permutation.

The challenger doesn’t use its key. The keyGen is in the Challenger C, it isn’t on the slides but it should be there.
He uses the key for the encryption.

text

sdaf

Bounding |p1 - p2|

ad

ads

asd

Bounding |p2 - p3|

When d is 0, we are in game G2. When d is 1, we are in game G3.

ad

The probability of Z is very small, the counter values are chosen uniformly at random. So to get a value twice is very unlikely.

gamli

Combining everything

ok

Lecture 10

Padding

Applies an injective map pad() to messages prior to CBC mode encryption, remove padding after decryption.

If the message was already block length. We need to add a complete block that is only padding. That block is 16 copies of OXOF. 16 because the block size in AES is 128 bits which is 16 bytes.

If the padding would be wrong, then the server could send a error message “bad padding”. The padding could be incorrectly formated because an adversary changes something.
That opens the door to a padding oracle attack.

padding

blocks

The target block could be any block from the ciphertext. Doesn’t necessarily have to be the last block. C(t) does not have to be the last block in the ciphertext.

poodle

We need to get 0x00, that means padding is valid. By chance we could also hit 0x01, 0x01 in the last 2 or 0x02, 0x02, 0x02 in the last three. But that is highly unlikely and we could check that with one more query.

poodle

Then we continue from there, set the last byte to 0x01 and change the second last byte until you get “valid”, which means you have recovered 2 bytes.

Worst case cost of this attack: 256 queries to the oracle for each byte you want to recover.

This is a plaintext recovery attack, not a key recovery attack.

Good explanation