You are on page 1of 16

Sheet 2: Classical Cipher

Q1.
For the Ciphertext gcuavqdtgcm produced by a Caesar cipher, What is the Plaintext? What is
the type of attack you made?
Q2.
Encrypt the message security using Hill Cipher with key *9 4; 5 7+
Q3.
Encrypt the message security using Vernam cipher with key *0x23 0xC8 0xE7 0x4A 0x68 0xB2
0x4A 0x3D]
Q4.
Consider the following simple implementation of symmetric encryption system:
//Performs simple symmetric encryption/decryption
//and returns the decrypted/encrypted message and its length
int SCrypt(BYTE inMsg[], int length, BYTE key, BYTE outMsg[])
{
for(int i=0;i<length;i++)
outMsg[i] = inMsg[i] ^ key;
return length;
}

Encrypt the following message security then decrypt the output.

Sheet 3: DES
Q1.
Draw the block diagram of the Feistel Cipher.
Q2.
Prove that Feistel Cipher is reversible.
Q3.
Draw the block diagram of DES algorithm.
Q4.
Consider the following simple implementation of symmetric encryption.
1. Draw the Encryption Block Diagram
2. Is this Cipher a Feistel Cipher
3. What is the block length?
4. What is the order of Brute Force attack?
5. Calculate SEncrypt(0x94, 0x6)
BYTE SEncrypt(BYTE p, BYTE k)
{
BYTE L0 = (p&0xF0)>>4;
BYTE R0 = p&0x0F;
BYTE K1 = (k&0xF0)>>4;
BYTE K2 = k&0x0F;
BYTE L1 = R0;
BYTE R1 = ((K1 * R0)>>4) ^ L0;
BYTE L2 = R1;
BYTE R2 = ((K2 * R1)>>4) ^ L1;
return (R2<<4)|(L2);
}
BYTE SDecrypt(BYTE c, BYTE k)
{
BYTE L2 = (c&0xF0)>>4;
BYTE R2 = c&0x0F;
BYTE K1 = (k&0xF0)>>4;
BYTE K2 = k&0x0F;
BYTE L1 = R2;
BYTE R1 = ((K2 * R2)>>4) ^ L2;
BYTE L0 = R1;
BYTE R0 = ((K1 * R1)>>4) ^ L1;
return (R0<<4)|(L0);
}


Sheet 4: Finite Fields
Q1.
Prove that the set of integer numbers and integer arithmetic cannot be used to implement a
computer based encryption/decryption technique.
Q2.
Does the set of real numbers form a field? Is it applicable to use real numbers to implement a
computer based encryption/decryption technique? Why?
Q3.
Calculate y = -11 mod 7
Q4.
Prove that a b (mod n) if n|(a-b)
Q5.
Prove that [(a mod n) + (b mod n)] mod n = (a+b) mod n
Q6.
Find 117 mod 13
Q7.
What is the multiplicative inverse of 5 mod 13, do not use Extended Euclidian algorithm.
Q8.
Write C function to calculate the GCD.
Prototype: int GCD(int a, int b)
Q9.
Calculate gcd(1970, 1066)
Q10.
Write C function to calculate both the Multiplicative Inverse of integer b in Zm.
Prototype: int MI(int m, int b)
Q11.
Show that GF(p) is a finite field, where p is prime. Show all satisfied axioms.
Q12.
Does GF(8) forms a finite field? Justify your answer?
Q13.
Calculate the multiplicative inverse of 550 in Z
1759
.
Q14.
Is GF(7) a finite field? Is is suitable to build a computer based Cipher? Justify your answer?
Q15.
Using ordinary polynomial arithmetic, calculate a+b, a-b, a*b, a/b, a mod b given that:
a = x3+x2+2
b = x2-x+1
Q16.
Does the set of polynomials with integer coefficient forms a field? Justify your answer?
Q17.
Using polynomial arithmetic with integer coefficient in Z2 calculate a+b, a-b, a*b, a/b, a mod b
given that:
a = x7+x5+x4+x3+x+1
b = x4+x2+x+1
Q18.
Does the set of polynomials with integer coefficient in Zp forms a field? Justify your answer?
Q19.
What the meaning of irreducible polynomial?
Q20.
Find the GCD of two polynomials a and b where:
a = x6+x5+x4+x3+x2+x+1
b = x4+x2+x+1
Q21.
Using polynomial arithmetic modulo m(x) with integer coefficient in Z2, calculate a+b, a-b,
a*b, a/b, a mod b given that:
m = x8+x4+x3+x+1
a = x6+x4+x2+x+1
b = x7+x+1
Q22.
List the set of residues in GF(3
2
).
Q23.
List the set of residues in GF(2
3
).
Q24.
Write a C function that perform the polynomial addition in GF(2
8
) with m(x) = x8+x4+x3+x+1.
Function prototype is: byte polyadd(byte a, byte b)
Q25.
Write a C function that perform the polynomial multiplication in GF(2
8
) with m(x) =
x
8
+x
4
+x
3
+x+1.
Function prototype is: byte polymul(byte a, byte b)
Q26.
Determine the multiplicative inverse of (x
3
+x+1) in GF(2
4
) with m(x) = x
4
+x+1.
Q27.
For GF(2
4
) with m(x) = x4+x+1. Using a generator find a x b where:
a = x
3
+x+1
b = x
2
+1

Sheet 5: AES
Q1.
Draw the block diagram of AES algorithm.
Q2.
Show with derivation how Mix Columns operation is optimized for 8 Bit processors. Given that
Mix Column matrix is:
[02 03 01 01; 01 02 03 01; 01 01 02 03; 03 01 01 02]
Q3.
Show with derivation how AES Encryption is optimized for 32 Bit processors. Given that Mix
Column matrix is:
[02 03 01 01; 01 02 03 01; 01 01 02 03; 03 01 01 02]
Q4.
In S-AES Cryptosystem calculate output of following operations:
1. Nibble Substitution of the Value 0xA3B5
2. Shift Rows Result of the Value 0xA3B5
3. Mix Column Output of the Value 0xA3B5
Given that:
( )
(
(
(
(

=
(

= + + =
7
3 0 2 6
5 8 1
4 9
,
1 4
4 1
, 1
4
F E C
D
B A
Box S MixColumn x x x m

Sheet 6: More on Symmetric Cipher
Q1.
For Double DES what is the required number of key pairs to apply the brute force attack, what
is the possibility of having a false key? Justify your answer?
Q2.
Following algorithm is the implementation of RC4 algorithm given that (RCL = 256). For
simplicity if ( RCL = 8 ) calculate the Ciphertext of the plaintext HelloWorld. What is the
effect of decreasing RCL value on the security?
/* Initialization */
for i = 0 to (RCL-1) do
S[i] = i;
T[i] = K[i mod keylen];
/* Initial Permutation of S */
j = 0;
for i = 0 to (RCL-1) do
j = (j + S[i] + T[i]) mod RCL;
Swap (S[i], S[j]);
/* Stream Generation */
i, j = 0;
while (true)
i = (i + 1) mod RCL;
j = (j + S[i]) mod RCL;
Swap (S[i], S[j]);
t = (S[i] + S[j]) mod RCL;
k = S[t];

Q3.
Given below a simplified version of BBS algorithm for random number generation
p, q: prime numbers
p q 3 (mod 4)
n = p * q
X
0
= s
w
mod n
for i = 1 to
X
i
= (X
i-1
)
w
mod n

1. If p=7, q=11, w = 2, s = 2 what is the expected random sequence?
2. To secure the random sequence from future prediction only p and q must be kept secret.
What are the expected attacks?
3. What is the period length ?
4. Regarding the Number Theory, what is the effect of the value (w) on the period length ?
5. Find out the required value of (w) to produce the full period?
Q4.
Draw an illustrative diagram that describes the idea of cryptographic based random number
generators.
What is the expected period?
What is the possibility to predict the next random value if the key is kept secret?
What is the type of the random sequence distribution?
Q5.
Using the simple encryption/decryption system defined by SEncrypt/SDecrypt function,
write encryption/decryption functions that implement the CBD mode.
Using your functions Encrypt the message hello.
Q6.
Using the simple encryption/decryption system defined by SEncrypt/SDecrypt function,
write encryption/decryption functions that implement the CFB mode where s = 4 bit.
Using your functions Encrypt the message hello.
Q7.
Using the simple encryption/decryption system defined by SEncrypt/SDecrypt function,
write encryption/decryption functions that implement the OFB mode where s = 4 bit.
Using your functions Encrypt the message hello.
Q8.
Using the simple encryption/decryption system defined by SEncrypt/SDecrypt function,
write encryption/decryption functions that implement the CTR mode.
Using your functions Encrypt the message hello.
Q9.
Consider the following simple implementation of a cryptographic random number generator:
BYTE randCounter = 0;
BYTE randKey = 0x63;
//Implements Simple Cryptographic Randome
// Number Generator based on randKey value
BYTE SRand()
{
BYTE randValue;
SCrypt(&randCounter, 1, randKey, &randValue);
randCounter++;
return randValue;
}

Generate the first 5 random values.
Sheet 7: Introduction to Number Theory
Q1.
Use prime number factorization to calculate the GCD of 300 and 18.
Q2.
Calculate 5
18
mod 19
Q3.
State and Prove Fermats theorem.
Q4.
Calculate (15), (19)
Q5.
State and Prove Eulers theorem.
Q6.
Find the possible values of x that satisfy the following formulas:
5
x
1 (mod 19)
7
x
1 (mod 15)
3
x
1 (mod 6)
Q7.
Write a C function that performs the Miller Rabin test for any given number.
Function prototype is: int MRTest(byte n, int nTrials)
The function should return 1 for inclusive numbers, 0 for composite numbers.
Q8.
Assume you have a C function MRTest that performs the Miller Rabin test for any given
number. Write another C function that generates a prime value given a starting value. The
generated prime value should be greater than the provided value.
- Assume given function is: int MRTest(byte n, int nTrials);
- MRTest returns 1 for inclusive numbers, 0 for composite numbers.
- Required function prototype is: int generatePrimeValue (byte startValue)
- generatePrimeValue should return the generated prime value.

Q9.
In Q8 with your implementation if generatePrimeValue(347637) is executed, estimate how
many times the Miller Rabin test is performed until it find the next prime value?
Q10.
Apply Miller Rabin test for n = 19 use try following values of a {4, 7, 10}. Based on your results
is it a prime value? Estimate the probability of your answer?
Q11.
Using CRT given that:
M = 1813 where M = m1 x m2 = 37 x 49 {37, 49 are prime values}.
Find the CRT representation of A = 973
Find the CRT representation of B = 815
Using CRT representation find out A x B mod M
Q12.
Is 5 is a primitive roots of 11.
Q13.
Calculate the primitive roots of 7.
Q14.
Given n = 15, y = a
x
mod n. Find at least one value for x that produce all values for y between 0
and 15.
Q15.
Given n = 15, y = a
x
mod n. Find at least one value for x that produce all values for y between 0
and 15.
Q16.
Calculate (7
117
mod 21)
Q17.
Calculate (5
117
mod 7) x (5
158
mod 7)

Q18.
Prove that:
( ) ( ) ( ) ( ) ( ) mod dlog dlog dlog
n then of root primative a is a If
, , ,
n y x xy
p a p a p a
| + =

Q19.
Calculate the dlog
4,19
(11)

Sheet 8: Public Key Cryptosystems
Q1.
State and prove the RSA algorithm.
Q2.
If RSA algorithm is used and p=17, q=11, e=7. Calculate E(PU, 88), D(PR, 155)
Q3.
Calculate 7
360
mod 561
Q4.
Write a C function that compute the X
Y
mod n using Montgomery Algorithm for discrete
exponentiation.
Function prototype DWORD DEXP(DWORD x, DWORD y, DWORD n)
Where DWORD is unsigned 32 bit integer
Q5.
If RSA algorithm is used and p=17, q=11, e=7. Using CRT optimization calculate D(PR, 11).
Q7.
Mention why RSA OEAB scheme is used?

Sheet 9: Public Key Cryptosystems
Q1.
Draw a diagram that illustrates how Certificate authority is used to trust the identities and to
distribute the public key value.
Q2.
Draw a diagram that illustrates how Public Key System is used to trust the identities and to
exchange the Secrete key value.
Q3.
State and prove DH Key exchange algorithm.
Q4.
For a DH key exchange system if q = 353, = 3, X
A
= 97, X
B
= 233 compute Y
A
, Y
B
and K
Q5.
Consider the following simple implementation of RSA algorithm:
//SPKI Calculates and returns the
//discrete exponent of m^x mod n
int SPKI(int m, int x, int n)
{
int r = m;
for(int i=0;i<(x-1);i++)
r = (r * m)%n;
return r;
}

Given that the RSA key value are (n=323, e=7, d=247). If M = 15 calculate the C = E(PU, M), OM
= D(PR, C).


Sheet 10: Hash and MAC Algorithms
Q1.
Consider a hash system producing a hash value of 32 bit. If the Plaintext is 128 bit, how many
Plaintext alternatives of the same length can produce the same hash value? How many
Plaintext alternatives of the any length can produce the same hash value?
Q2.
What is the advantage of using secrete key value with HMAC algorithm instead of calculating
only the hash value.
Q3.
Using only XOR operation writes a C function that calculates a 32 bit hash value. Feel free to
add whatever calculation in your code.
Function prototype: DWORD MYHash(BYTE Data[]);
Q4.
Consider the following simple implementation of Hash function:
//Performs Simple Hashing and returns the calculated hash value
BYTE SHASH(BYTE data[], int length)
{
BYTE hash = 0x73;
for(int i=0;i<length;i++)
hash ^= data[i];
return hash;
}

Calculate the hash value of HelloWorld.
Q5.
Consider the following simple implementation of HMAC function:
//Calculates and returns a Simple HMAC value
BYTE SHMAC(BYTE key, BYTE data[], int length)
{
BYTE hash = key;
for(int i=0;i<length;i++)
hash ^= data[i];
return hash;
}

Calculate the HMAC value of HelloWorld given that the key is 0x78.

Sheet 11: Cryptography Systems
Q1.
If A need to send an encrypted message to B, B must make sure that the message comes only
from A, what they should do? Consider following constrains:
1. Only symmetric system is available at both sides
2. This is first time that A communicate with B
Note: Illustrate your answer with diagrams only, and then mention the expected attacks.
Q2.
If A need to send an encrypted message to B, B must make sure that the message comes only
from A, B must also make sure the message is not altered, what they should do? Consider
following constrains:
1. Available cryptographic systems: symmetric cryptography system, hash system
2. This is first time that A communicate with B
Note: Illustrate your answer with diagrams only, and then mention the expected attacks.
Q3.
If A need to send an encrypted message to B, B must make sure that the message comes only
from A, B must also make sure the message is not altered, what they should do? Consider
following constrains:
1. Available cryptographic systems: symmetric cryptography system, HMAC system
2. This is first time that A communicate with B
Note: Illustrate your answer with diagrams only, and then mention the expected attacks.
Q4.
If A need to send an encrypted message to B, B must make sure that the message comes only
from A, B must also make sure the message is not altered, what they should do? Consider
following constrains:
1. Available cryptographic systems: symmetric cryptography system, hash, asymmetric
cryptography system
2. This is first time that A communicate with B
Note: Illustrate your answer with diagrams only, and then mention the expected attacks.

You might also like