assignment #2 solutions - courses.cs.washington.edu

20

Upload: others

Post on 12-Jun-2022

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Assignment #2 Solutions - courses.cs.washington.edu
Page 2: Assignment #2 Solutions - courses.cs.washington.edu

Problem 1

Block Cipher

Block Cipher

Block Cipher

Block Cipher

IV

January 27, 2011 Practical Aspects of Modern Cryptography 2

n bits k zero bits

removed

Page 3: Assignment #2 Solutions - courses.cs.washington.edu

Inverse Cipher

Inverse Cipher

Inverse Cipher

Inverse Cipher

IV

January 27, 2011 Practical Aspects of Modern Cryptography 3

Problem 1

Missing bits

Page 4: Assignment #2 Solutions - courses.cs.washington.edu

Problem 1 Let b = 𝑛

π‘š be the number of blocks.

Plaintext 𝑃0, 𝑃1, … , 𝑃𝑏, ciphertext 𝐢0, 𝐢1, … , 𝐢𝑏.

We care about πΆπ‘βˆ’1, 𝐢𝑏 , π‘ƒπ‘βˆ’1 and 𝑃𝑏 .

We know π‘˜, the number of bits removed from the penultimate block, since π‘˜ = π‘š βˆ’ (𝑛 mod π‘š).

Recall that for CBC decryption, we have plaintext block

𝑃𝑖 = Decrypt(𝐾, 𝐢𝑖) ⨂ πΆπ‘–βˆ’π‘–

1/27/2011 Practical Aspects of Modern Cryptography

Page 5: Assignment #2 Solutions - courses.cs.washington.edu

Problem 1 𝑃𝑖 = Decrypt(𝐾, 𝐢𝑖) ⨂ πΆπ‘–βˆ’π‘–

1. Compute 𝑋𝑏 = Decrypt(𝐾, 𝐢𝑏) (intermediate value of final block)

2. We also know 𝑋𝑏 = 𝑃𝑏 𝑋𝑂𝑅 πΆπ‘βˆ’1 if we have all the bits in 𝐢𝑏 .

3. Finally, we know the last π‘˜ bits of 𝑃𝑏 are 0 (pad).

4. So for each of the padding bits 𝑃𝑏,π‘šβˆ’π‘˜+1, … , 𝑃𝑏,π‘š

we have 𝑋𝑏,𝑖 = 𝑃𝑏,𝑖 XOR πΆπ‘βˆ’1,𝑖 for 𝑖 = π‘š βˆ’ π‘˜ + 1, … , π‘š

5. Since 𝑃𝑏,𝑖 = 0, then 𝑋𝑏,𝑖 = πΆπ‘βˆ’1,𝑖

1/27/2011 Practical Aspects of Modern Cryptography

Page 6: Assignment #2 Solutions - courses.cs.washington.edu

Problem 1: Ciphertext Stealing

Inverse Cipher

Inverse Cipher

Inverse Cipher

Inverse Cipher

Plaintext

Ciphertext

IV

110101

110101

00…0

Page 7: Assignment #2 Solutions - courses.cs.washington.edu

Problem 2 Decrypt a π‘˜-block segment in the middle of a long CBC-

encrypted ciphertext.

What is the minimum number of blocks of ciphertext that need to be decrypted?

Which blocks do you need to decrypt and how will you decrypt them?

1/27/2011 Practical Aspects of Modern Cryptography

Page 8: Assignment #2 Solutions - courses.cs.washington.edu

Problem 2

In CBC decryption, we have plaintext block

𝑃𝑖 = Decrypt(𝐾, 𝐢𝑖) ⨂ πΆπ‘–βˆ’π‘–

NOTE: Boundary case "πΆβˆ’1" = IV.

Each plaintext block we want requires one decryption of the corresponding plaintext plus one XOR.

So the minimum number of ciphertext blocks to be decrypted is π‘˜.

If you want plaintext blocks 𝑃𝑖 , 𝑃𝑖+1, … , 𝑃𝑖+π‘˜βˆ’1, then you need ciphertext blocks πΆπ‘–βˆ’1, 𝐢𝑖 , 𝐢𝑖+1, … , 𝐢𝑖+π‘˜βˆ’1.

If 𝑖 = 0, instead of πΆπ‘–βˆ’1 you need the IV.

1/27/2011 Practical Aspects of Modern Cryptography

Page 9: Assignment #2 Solutions - courses.cs.washington.edu

Problem 3 𝐻 is a Merkle-DamgΓ₯rd hash function w/ compression

function 𝐹. Black box takes inputs 𝐼𝑉 and 𝑦 and outputs an π‘₯ such that 𝐹 𝐼𝑉, π‘₯ = 𝑦.

Show how by using the black box at most 2π‘˜ times you can find a set of 2π‘˜ messages that all have the same hash value when input into the full hash function 𝐻.

1/27/2011 Practical Aspects of Modern Cryptography

Page 10: Assignment #2 Solutions - courses.cs.washington.edu

Problem 3 – Solution 1

Basic idea: find pairs of messages π‘₯𝑖 , π‘₯𝑖′ satisfying

𝐹 𝐼𝑉𝑖 , π‘₯𝑖 = 𝐹 𝐼𝑉𝑖 , π‘₯𝑖′ = 𝑦𝑖, 𝑖 = 1, . . , π‘˜

𝑦𝑖 = 𝐼𝑉𝑖+1 𝐼𝑉1 = 𝐼𝑉

Start at the end. Choose a random target output value π‘¦π‘˜ and a random input value π‘¦π‘˜βˆ’1 = πΌπ‘‰π‘˜ . Call the black box twice with πΌπ‘‰π‘˜ , π‘¦π‘˜ to generate π‘₯π‘˜ , π‘₯π‘˜

β€² .

Now move back a block. We have π‘¦π‘˜βˆ’1, choose random πΌπ‘‰π‘˜βˆ’1 = π‘¦π‘˜βˆ’2. Run the box twice, get π‘₯π‘˜βˆ’1, π‘₯π‘˜βˆ’1

β€² .

1/27/2011 Practical Aspects of Modern Cryptography

Page 11: Assignment #2 Solutions - courses.cs.washington.edu

Problem 3 – Solution 1 We now have 4 two-block messages that hash to the

same value when F is the compression function: π‘₯π‘˜βˆ’1π‘₯π‘˜ , π‘₯π‘˜βˆ’1π‘₯π‘˜

β€² , π‘₯π‘˜βˆ’1β€² π‘₯π‘˜ , π‘₯π‘˜βˆ’1

β€² π‘₯π‘˜β€²

Repeat this procedure π‘˜ times and you’ll have made 2π‘˜ calls to the black box to generate π‘˜ pairs π‘₯𝑖 , π‘₯𝑖

β€².

To generate 2π‘˜ messages that hash to the same value, make π‘˜-block messages where the 𝑖th block is either π‘₯𝑖 or π‘₯𝑖

β€². Two choices per block, π‘˜ blocks == 2π‘˜ .

1/27/2011 Practical Aspects of Modern Cryptography

Page 12: Assignment #2 Solutions - courses.cs.washington.edu

Problem 3 – Solution 2 The β€œfixed point” solution

Choose a fixed value for 𝐼𝑉. Now call the black box to find an π‘₯ such that 𝐹 𝐼𝑉, π‘₯ = 𝐼𝑉.

Concatenate π‘₯ as many times as you want, the hash will still be 𝐼𝑉. So to get 2π‘˜ messages:

π‘₯, π‘₯π‘₯, π‘₯π‘₯π‘₯, π‘₯π‘₯π‘₯π‘₯, … , π‘₯π‘₯π‘₯ … π‘₯π‘₯π‘₯ (2π‘˜ total times)

1/27/2011 Practical Aspects of Modern Cryptography

Page 13: Assignment #2 Solutions - courses.cs.washington.edu

Problem 4 𝐺(π‘₯) = 𝐻(π‘₯) βˆ₯ 𝐻′(π‘₯), 𝐻(π‘₯) and 𝐻′(π‘₯) are hash

functions with 𝑛-bit outputs, so 𝐺(π‘₯) has 2𝑛-bit outputs.

Normally, with a birthday attack we would expect to have to generate 22𝑛/2 = 2𝑛 messages to find a collision.

However, 𝐻(π‘₯) is badly broken (as in Prob. 3) so assume

we can generate 2𝑛/2 messages that all have the same hash value in 𝐻 π‘₯ .

1/27/2011 Practical Aspects of Modern Cryptography

Page 14: Assignment #2 Solutions - courses.cs.washington.edu

Problem 4 Now compute 𝐻′(π‘₯) for each of the 2𝑛/2 that have the

same hash value in 𝐻(π‘₯).

By the birthday attack we expect to find a collision from those 2𝑛/2 messages.

1/27/2011 Practical Aspects of Modern Cryptography

Page 15: Assignment #2 Solutions - courses.cs.washington.edu

Problem 4 Was it a good idea to construct 𝐺(π‘₯) = 𝐻(π‘₯) βˆ₯ 𝐻′(π‘₯)?

1/27/2011 Practical Aspects of Modern Cryptography

Page 16: Assignment #2 Solutions - courses.cs.washington.edu

Problem 4 Was it a good idea to construct 𝐺(π‘₯) = 𝐻(π‘₯) βˆ₯ 𝐻′(π‘₯)?

Well, it depends…

1/27/2011 Practical Aspects of Modern Cryptography

Page 17: Assignment #2 Solutions - courses.cs.washington.edu

Problem 4 Was it a good idea to construct 𝐺(π‘₯) = 𝐻(π‘₯) βˆ₯ 𝐻′(π‘₯)?

Well, it depends…

YES: At the cost of computing two hashes vs. one, you get resistance if one of 𝐻, 𝐻′ breaks.

1/27/2011 Practical Aspects of Modern Cryptography

Page 18: Assignment #2 Solutions - courses.cs.washington.edu

Problem 4 Was it a good idea to construct 𝐺(π‘₯) = 𝐻(π‘₯) βˆ₯ 𝐻′(π‘₯)?

Well, it depends…

YES: At the cost of computing two hashes vs. one, you get resistance if one of 𝐻, 𝐻′ breaks, but…

NO: However, 𝐺(π‘₯) doesn’t have the security margin you’d expect of a 2𝑛-bit hash function. It’s only as strong as the better of its two components

1/27/2011 Practical Aspects of Modern Cryptography

Page 19: Assignment #2 Solutions - courses.cs.washington.edu

Problem 5

Alice Bob: π‘š = β€œplease pay the bearer $1”, 𝐻(π‘˜, π‘š).

π‘š is an exact multiple of 𝐻’𝑠 block size (so you don’t need to do any padding).

What can Bob do?

1/27/2011 Practical Aspects of Modern Cryptography

Page 20: Assignment #2 Solutions - courses.cs.washington.edu

Problem 5

Note that π‘˜ is only an input to the first application of 𝐻′𝑠 compression function (e.g. it’s the 𝐼𝑉 to the hash of the first block of π‘š)

Bob can append data to π‘š, create π‘šβ€² = π‘š βˆ₯ β€œ,000,000”, and compute 𝐻 π‘˜, π‘šβ€² from 𝐻(π‘˜, π‘š).

1/27/2011 Practical Aspects of Modern Cryptography