Tutorial 5 Sol
Tutorial 5 Sol
Tutorial 5
1
Question 1
Solution (1)
Question 2
What is public key crypto based on?
• Public key crypto is based on mathematical one way functions
– Easy to compute output given the inputs
– Difficult to compute input given the output
• Factorisation problem
– Multiplying two prime numbers
– Given prime x and y it is easy to compute x.y = z
– Given z it is not easy to compute x and y
5
Question 2a
Question 2b
Hash Function
• A cryptographic hash function h(x) should provide
– Two functional properties
• Compression – arbitrary length input to output of small, fixed length
• Easy to compute – expected to run fast
– Three security properties
• One-way – given a hash value y it is infeasible to find an x such that h(x) = y
(also called pre-image resistance)
• Second pre-image resistance – given y and h(y), cannot find x where h(x)=h(y)
• Collision resistance – infeasible to find x and y, with x y such that h(x) = h(y)
8
Question 2c
11
Question 3b
• How could we change the padding to prevent this issue?
12
Question 3c
13
Question 4
Suppose you are using a MAC based on a block cipher in CBC
mode (Ci = E(K; Pi XOR Ci-1), IV=0 for C0), and you know the
following two messages:
M’= M0 M1
M’’ = M2 M3 M4
together with their corresponding MAC tags T’ and T’’.
15
Question 4
A CBC MAC is calculated exactly the same as when we are encrypting a message.
We just discard all the ciphertext except for the final ciphertext block, which is
our MAC
value.
First we explicitly write down the MAC tags for both M‘ and M’’:
T’ = C’1 = EK(C’0 XOR M1) = EK(EK(IV XOR M0) XOR M1) = EK(EK(M0) XOR M1)
T’’ = C’’2 = EK(C1 XOR M4) = EK(EK(C0 XOR M3) XOR M4) = EK(EK(EK(M2) XOR
M3) XOR M4)
Remember that for MACs based on a block cipher, the IV is always set to zero. So
we can essentially leave out the IV (given the anything XOR with ) stays the
same.
Question 4
We can now create a new message by setting:
M = M0, M1, M2 XOR T’, M3, M4
?
Any questions…
18