Cryptography Sample Final Exam With Solutions
Cryptography Sample Final Exam With Solutions
1. 1. Explain the major differences between symmetric and asymmetric key cryptography.
- **Symmetric Key Cryptography:** Uses the same key for encryption and decryption. It is
faster but has a key distribution problem.
- **Asymmetric Key Cryptography:** Uses different keys (public and private) for encryption
and decryption. It is slower but solves the key distribution issue by using public keys.
2. 2. Describe the process of generating a digital signature using RSA.
- A trapdoor one-way function is easy to compute in one direction but infeasible to reverse
without specific information (the 'trapdoor').
- It is significant in public-key cryptography as it enables secure encryption and decryption,
ensuring only the private key holder can reverse the encryption.
4. 4. Explain how the A5/1 cipher generates a keystream using three registers.
- The IV ensures that identical plaintext blocks encrypt to different ciphertext blocks,
providing randomness.
- It prevents patterns in ciphertext when encrypting similar plaintexts.
6. 6. RSA Encryption: Given p = 13, q = 11, and e = 7, compute the public and private keys.
Encrypt the message M = 9 using the public key. Decrypt the ciphertext to verify your
solution.
- n = p x q = 13 x 11 = 143
- φ(n) = (p - 1)(q - 1) = 12 x 10 = 120
- e = 7, d x e ≡ 1 mod 120 → d = 103
- Public key: (e, n) = (7, 143), Private key: (d, n) = (103, 143)
- Encryption: C = M^e mod n = 9^7 mod 143 = 48
- Decryption: M = C^d mod n = 48^103 mod 143 = 9
7. 7. Hash Function: A message M = 'HELLO' is hashed using a simple hash function that
sums the ASCII values of the characters and computes modulo 11. Calculate the hash
value for M. What property of hash functions ensures the integrity of the message?
Solution
Step 1: Understand the A5/1 Cipher
The A5/1 cipher uses three Linear Feedback Shift Registers (LFSRs):
1. XXX: 19 bits
2. YYY: 22 bits
3. ZZZ: 23 bits
Each register shifts based on a majority vote of specific "control bits."
Step 2: Majority Function
The majority function is calculated using the following control bits:
X8X_8X8: The 9th bit of register XXX (indexing starts from 0).
Y10Y_{10}Y10: The 11th bit of register YYY.
Z10Z_{10}Z10: The 11th bit of register ZZZ.
The majority bit (mmm) is computed as: m=maj(X8,Y10,Z10)m = maj(X_8, Y_{10},
Z_{10})m=maj(X8,Y10,Z10) The majority function outputs:
1 if two or more control bits are 1.
0 if two or more control bits are 0.
Detailed Calculation
Initial Values
Given:
X=1011010011010100101X = 1011010011010100101X=1011010011010100101
Y=1101001011001010111010Y =
1101001011001010111010Y=1101001011001010111010
Z=10111011010110101011010Z =
10111011010110101011010Z=10111011010110101011010
Extract control bits:
X8=1X_8 = 1X8=1 (9th bit of XXX)
Y10=0Y_{10} = 0Y10=0 (11th bit of YYY)
Z10=1Z_{10} = 1Z10=1 (11th bit of ZZZ)
Compute majority bit:
m=maj(X8,Y10,Z10)=maj(1,0,1)=1m = maj(X_8, Y_{10}, Z_{10}) = maj(1, 0, 1) = 1m=maj(X8
,Y10,Z10)=maj(1,0,1)=1
Step Registers
Since m=1m = 1m=1:
1. Step XXX:
o Compute: t=X13⊕X16⊕X17⊕X18=1⊕0⊕0⊕1=0t = X_{13} \oplus X_{16} \
oplus X_{17} \oplus X_{18} = 1 \oplus 0 \oplus 0 \oplus 1 = 0t=X13⊕X16
⊕X17⊕X18=1⊕0⊕0⊕1=0
o Shift XXX: X=0101101001101010010X =
0101101001101010010X=0101101001101010010
2. Do not step YYY: Y10≠mY_{10} \neq mY10=m.
3. Step ZZZ:
o Compute: t=Z7⊕Z20⊕Z21⊕Z22=1⊕1⊕0⊕1=1t = Z_{7} \oplus Z_{20} \
oplus Z_{21} \oplus Z_{22} = 1 \oplus 1 \oplus 0 \oplus 1 = 1t=Z7⊕Z20
⊕Z21⊕Z22=1⊕1⊕0⊕1=1
o Shift ZZZ: Z=11011101101011010110100Z =
11011101101011010110100Z=11011101101011010110100
Generate Keystream Bit
Extract the last bits:
X18=0X_{18} = 0X18=0
Y21=0Y_{21} = 0Y21=0
Z22=1Z_{22} = 1Z22=1
Compute:
s=X18⊕Y21⊕Z22=0⊕0⊕1=1s = X_{18} \oplus Y_{21} \oplus Z_{22} = 0 \oplus 0 \oplus 1 =
1s=X18⊕Y21⊕Z22=0⊕0⊕1=1
Encrypt 'A'
Plaintext ('A') = 100000110000011000001.
Keystream = 000000100000010000001.
Ciphertext:
1000001⊕0000001=10000001000001 \oplus 0000001 =
10000001000001⊕0000001=1000000
Ciphertext (binary) = 100000010000001000000, which is 646464 in decimal.
Final Answer
1. First keystream bit: s=1s = 1s=1.
2. Encrypted ASCII character 'A': 646464 in decimal or 100000010000001000000 in
binary.
- Verification:
- Receiver decrypts the signature: M' = S^e mod n.
- Compares M' with the original message.
- Advantages:
- Hashing ensures fixed-size input for signatures.
- Enhances security by verifying message integrity.