0% found this document useful (0 votes)
39 views

Cryptography Sample Final Exam With Solutions

The document outlines a final exam covering cryptography topics, including symmetric vs. asymmetric key cryptography, RSA digital signatures, and the A5/1 cipher. It includes short-answer questions and practical problems, such as RSA encryption and hash functions, with detailed solutions provided. The exam assesses understanding of key concepts and practical applications in cryptography.

Uploaded by

nesren140
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Cryptography Sample Final Exam With Solutions

The document outlines a final exam covering cryptography topics, including symmetric vs. asymmetric key cryptography, RSA digital signatures, and the A5/1 cipher. It includes short-answer questions and practical problems, such as RSA encryption and hash functions, with detailed solutions provided. The exam assesses understanding of key concepts and practical applications in cryptography.

Uploaded by

nesren140
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Final Exam with Solutions

Section A: Short-Answer Questions


(Each question carries 5 marks)

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.

- Compute the hash of the message to ensure a fixed-size representation.


- Encrypt the hash using the sender’s private key to generate the digital signature.
- Send the signature along with the message.
- The receiver can verify the signature using the sender’s public key.
3. 3. Define the term 'trapdoor one-way function' and explain its significance in public-key
cryptography.

- 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.

- A5/1 uses three Linear Feedback Shift Registers (LFSRs): X, Y, and Z.


- The majority bit (maj) of certain bits in the registers determines which registers step.
- Each step generates one bit of the keystream by XORing the last bits of all registers.
5. 5. What is the role of an Initialization Vector (IV) in Cipher Block Chaining (CBC) mode?

- The IV ensures that identical plaintext blocks encrypt to different ciphertext blocks,
providing randomness.
- It prevents patterns in ciphertext when encrypting similar plaintexts.

Section B: Practical Problems


(Each question carries 10 marks)

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?

- ASCII values: H = 72, E = 69, L = 76, L = 76, O = 79


- Sum: 72 + 69 + 76 + 76 + 79 = 372
- Hash: 372 mod 11 = 9
- Property: Collision resistance ensures integrity by preventing two different messages from
having the same hash.
8. 8. A5/1 Cipher: Using the initial values for the A5/1 registers (X, Y, Z), calculate the first
keystream bit and encrypt the ASCII character 'A' (65 in binary).

- Majority bit: m = maj(X8, Y10, Z10)


- XOR the rightmost bits: s = X18 ⊕ Y21 ⊕ Z22
- Keystream bit: s = 1
- Encryption: 1000001 ⊕ 0000001 = 1000000
Problem Statement
Using the initial values for the A5/1 registers XXX, YYY, and ZZZ:
 X=1011010011010100101
 Y=1101001011001010111010
 Z=10111011010110101011010
Calculate the first keystream bit and encrypt the ASCII character 'A' (65 in binary:
100000110000011000001).

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.

Step 3: Step the Registers


Each register steps based on whether its control bit equals the majority bit (mmm):
 If X8=mX_8 = mX8=m, register XXX steps:
t=X13⊕X16⊕X17⊕X18t = X_{13} \oplus X_{16} \oplus X_{17} \oplus X_{18}t=X13⊕X16
⊕X17⊕X18
Shift all bits of XXX to the right and set X0=tX_0 = tX0=t.
 If Y10=mY_{10} = mY10=m, register YYY steps:
t=Y20⊕Y21t = Y_{20} \oplus Y_{21}t=Y20⊕Y21
Shift all bits of YYY to the right and set Y0=tY_0 = tY0=t.
 If Z10=mZ_{10} = mZ10=m, register ZZZ steps:
t=Z7⊕Z20⊕Z21⊕Z22t = Z_{7} \oplus Z_{20} \oplus Z_{21} \oplus Z_{22}t=Z7⊕Z20⊕Z21
⊕Z22
Shift all bits of ZZZ to the right and set Z0=tZ_0 = tZ0=t.

Step 4: Generate the Keystream Bit


Once the registers are stepped, compute the keystream bit (sss):
s=X18⊕Y21⊕Z22s = X_{18} \oplus Y_{21} \oplus Z_{22}s=X18⊕Y21⊕Z22

Step 5: Encrypt the Character


The ASCII value of 'A' is 656565 in decimal, or 100000110000011000001 in binary. To
encrypt:
Ciphertext=Plaintext⊕Keystream Bit(s)\text{Ciphertext} = \text{Plaintext} \oplus \
text{Keystream Bit(s)}Ciphertext=Plaintext⊕Keystream Bit(s)

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.

9. 9. Block Cipher Mode: Given a plaintext P = 'CRYPTO' and key K = '12345678',


demonstrate the encryption process using ECB mode.

- Divide plaintext into blocks of 8 bits: 'CR', 'YP', 'TO'.


- Encrypt each block separately using the key.
- Example (simplified): Block 'CR' (67, 82): C1 = E(67, K), C2 = E(82, K).
- Ciphertext: Concatenate encrypted blocks.
10. 10. Digital Signature Verification: Given a digital signature created using RSA (S = M^d
mod n), explain how a receiver verifies the message authenticity. Discuss the
advantages of combining a hash function with digital signatures.

- 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.

You might also like