Cryptography · Unit 4 · 8 hrs
Cryptographic Hash Functions and Digital Signatures
Exam-focused notes for Cryptographic Hash Functions and Digital Signatures (Cryptography, CSC327): what the TU syllabus asks and how it has actually been tested, with 12 solved past questions from this unit.
Cryptographic Hash Functions and Digital Signatures in short
Confidentiality, provided by the ciphers of Units 1 to 3, is only half the picture: a recipient also needs to know a message truly came from its claimed sender and was not altered in transit. This unit covers message authentication, the cryptographic hash functions and MACs that provide it, and the digital signature schemes built on top of them.
What this unit covers
- Message Authentication
- Message Authentication Functions
- Message Authentication Codes
- Hash Functions
- Properties of Hash functions
- Applications of Hash Functions
- Message Digests: MD4 and MD5
- Secure Hash Algorithms: SHA-1 and SHA-2
- Digital Signatures: Direct Digital Signatures, Arbitrated Digital Signature
- Digital Signature Standard: The DSS Approach, Digital Signature Algorithm
- Digital Signature Standard: The RSA Approach
Properties of Hash functions
2082 · 10 marks
Describe the properties of hash functions. Discuss how hash value is generated using SHA-1 algorithm.[10]
2081 · 5 marks
Write short notes on (any two) a. Totient value of any positive integer. b. Properties of hash function. c. Virus or Worms. [5]
Show solved answerHide answer
Short Notes (Any Two)
a. Totient Value of Any Positive Integer
Definition: Euler's Totient Function, denoted by φ(n), is defined as the number of positive integers less than n that are relatively prime (coprime) to n. Two numbers are relatively prime if their greatest common divisor (GCD) is 1.
Special Property: If n is a prime number, then:
φ(n) = n - 1
This is because all integers from 1 to (n-1) are relatively prime to a prime number.
Example: Find φ(10):
- Numbers less than 10: {1, 2, 3, 4, 5, 6, 7, 8, 9}
- Numbers relatively prime to 10 (GCD with 10 = 1): {1, 3, 7, 9}
- Therefore, φ(10) = 4
Example with prime: Find φ(7):
- Since 7 is prime: φ(7) = 7 - 1 = 6
Euler's Totient Function is widely used in RSA encryption and number theory in cryptography.
b. Properties of Hash Function
Definition: A hash function is a function that maps a message of any length into a fixed-length hash value, which serves as the authenticator in message authentication and digital signatures.
Key Properties:
| Property | Description |
|---|---|
| One-way Property | Given a hash value h, it is computationally infeasible to find any message m such that H(m) = h. |
| Weak Collision Resistance | Given an input m1, it is computationally hard to find a different input m2 such that H(m1) = H(m2). |
| Strong Collision Resistance | It is computationally hard to find any two different messages m1 and m2 such that H(m1) = H(m2). |
| Fixed-length Output | Regardless of input size, the hash function always produces a fixed-length output (e.g., MD5 produces 128-bit output). |
| Variable Input Size | A hash function can be applied to a block of data of any size. |
Example:
- MD5 produces a 128-bit (16-byte) hash value expressed as a 32-digit hexadecimal number.
- MD4 also produces a 128-bit message digest from an input of arbitrary length.
Hash functions play a fundamental role in efficient and secure information processing in cryptography.
2079 · 10 marks
Describe the properties of hash functions. Discuss how hash value is generated using SHA-1 algorithm.[10]
2078 · 5 marks
List the properties of hash function. Discuss the first pass of MD4. [5]
Digital Signature Standard
2082 · 5 marks
Describe the working mechanism of digital signature algorithm. [5]
2076 · 5 marks
Define digital signature. Describe the approaches of DSS. [5]
Message Authentication Codes
2081 · 10 marks
What is Message Authentication Code? List the operation of computing digest value in different passes of MD4. Describe about Needhom-Schroeder protocol.[10]
2076 · 5 marks
Write down any two limitations of MAC. What do policy and mechanism mean in cryptography? Describe with a scenario. [5]
Applications of Hash Functions
2080 · 10 marks
What are the applications of hash functions? Discuss how SHA-1 algorithm generates hash value from a given message.[10]
Digital Signatures
2079 · 5 marks
How direct digital signature different from arbitrated digital signature? How digital signature generation and verification is done using RSA. [5]
2078 · 10 marks
Explain the generic model of digital signature process. Consider the two prime numbers 7 and 19. Select 29 as public key and 41 as private key. Encrypt the plaintext 4 and decrypt the cipher text 3 using RSA.[10]
Show solved answerHide answer
Digital Signature and RSA
Part 1: Generic Model of Digital Signature Process
A digital signature uses asymmetric (public key) cryptography to provide authentication, integrity, and non-repudiation. The sender signs using their private key; the receiver verifies using the sender's public key.
Model
Sender side:
- Message: Sender has the original plaintext message $M$.
- Hashing: A hash function $H$ (e.g., SHA-1, MD5) is applied to $M$ to produce a fixed-length message digest $h = H(M)$.
- Signing: The digest is encrypted with the sender's private key to form the digital signature $S = E_{PR_{sender}}(h)$.
- Transmission: The message $M$ and signature $S$ are sent together.
Receiver side: 5. Recompute hash: Receiver applies the same hash function to the received message: $h_1 = H(M)$. 6. Decrypt signature: Receiver decrypts $S$ with the sender's public key to recover $h_2 = D_{PU_{sender}}(S)$. 7. Compare: If $h_1 = h_2$, the message is authentic and unaltered; otherwise it has been tampered with or is forged.
Sender: M --H--> h --Encrypt(PR_sender)--> S ; send (M, S)
Receiver: M --H--> h1
S --Decrypt(PU_sender)--> h2
compare h1 == h2 ? valid : invalid
Properties provided: Authentication, Integrity, Non-repudiation.
Part 2: RSA
Given data
- $p = 7$, $q = 19$
- Public key $e = 29$
- Private key $d = 41$
- Plaintext to encrypt: $M = 4$
- Ciphertext to decrypt: $C = 3$
Step 1: Parameters
$$n = p \times q = 7 \times 19 = 133$$ $$\phi(n) = (p-1)(q-1) = 6 \times 18 = 108$$
Check: $e \times d = 29 \times 41 = 1189$, and $1189 \mod 108 = 1189 - 11\times108 = 1189-1188 = 1$. ✓ Keys valid.
Step 2: Encrypt $M = 4$
$$C = M^e \bmod n = 4^{29} \bmod 133$$
Successive squaring mod 133:
- $4^1 = 4$
- $4^2 = 16$
- $4^4 = 16^2 = 256 \equiv 123$
- $4^8 = 123^2 = 15129 \equiv 6$ (since $15129 - 113\times133 = 15129-15029=100$... recheck)
Recheck $4^8$: $15129 \div 133 = 113.75$, $113\times133 = 15029$, remainder $= 100$. So $4^8 \equiv 100$, not 6.
Redo carefully:
- $4^4 \equiv 123$
- $4^8 = 123^2 = 15129$; $133\times113 = 15029$; $15129-15029 = 100 \Rightarrow 4^8 \equiv 100$
- $4^{16} = 100^2 = 10000$; $133\times75 = 9975$; $10000-9975 = 25 \Rightarrow 4^{16} \equiv 25$
Binary: $29 = 16+8+4+1$, so $$4^{29} = 4^{16}\cdot 4^{8}\cdot 4^{4}\cdot 4^{1} \equiv 25 \times 100 \times 123 \times 4 \pmod{133}$$
Step by step:
- $25 \times 100 = 2500;\ 2500 - 18\times133 = 2500 - 2394 = 106$
- $106 \times 123 = 13038;\ 13038 - 98\times133 = 13038 - 13034 = 4$
- $4 \times 4 = 16$
$$\boxed{C = 4^{29} \bmod 133 = 16}$$
Step 3: Decrypt $C = 3$
$$M = C^d \bmod n = 3^{41} \bmod 133$$
Successive squaring mod 133:
- $3^1 = 3$
- $3^2 = 9$
- $3^4 = 81$
- $3^8 = 81^2 = 6561;\ 6561 - 49\times133 = 6561-6517 = 44$
- $3^{16} = 44^2 = 1936;\ 1936 - 14\times133 = 1936-1862 = 74$
- $3^{32} = 74^2 = 5476;\ 5476 - 41\times133 = 5476-5453 = 23$
Binary: $41 = 32 + 8 + 1$, so $$3^{41} = 3^{32}\cdot 3^{8}\cdot 3^{1} \equiv 23 \times 44 \times 3 \pmod{133}$$
- $23 \times 44 = 1012;\ 1012 - 7\times133 = 1012 - 931 = 81$
- $81 \times 3 = 243;\ 243 - 133 = 110$
$$\boxed{M = 3^{41} \bmod 133 = 110}$$
Final Results
- Encryption of plaintext $4$: $C = 16$
- Decryption of ciphertext $3$: $M = 110$
Secure Hash Algorithms
2076 · 10 marks
Compare the SHA parameters between SHA-1 and SHA-2 families. Decrypt the cipher text DRIJ with the key $$\begin{pmatrix} 7 & 8 \ 11 & 11 \end{pmatrix}$$ using the Hill cipher. [10]
Show solved answerHide answer
SHA Parameters Comparison & Hill Cipher Decryption
Part 1: SHA Parameters Comparison (SHA-1 vs SHA-2 Family)
| Parameter | SHA-1 | SHA-224 | SHA-256 | SHA-384 | SHA-512 |
|---|---|---|---|---|---|
| Message Digest Size (bits) | 160 | 224 | 256 | 384 | 512 |
| Max Message Size (bits) | $<2^{64}$ | $<2^{64}$ | $<2^{64}$ | $<2^{128}$ | $<2^{128}$ |
| Block Size (bits) | 512 | 512 | 512 | 1024 | 1024 |
| Word Size (bits) | 32 | 32 | 32 | 64 | 64 |
| Number of Rounds | 80 | 64 | 64 | 80 | 80 |
| Collision Security (bits) | 80 | 112 | 128 | 192 | 256 |
Notes:
- SHA-1 produces a single 160-bit digest; SHA-2 is a family of hash functions with variable output sizes.
- SHA-1 is broken against collision attacks (SHAttered, 2017) and is deprecated.
- SHA-2 uses more complex round functions and better resistance to known attacks.
Part 2: Hill Cipher Decryption of "DRIJ"
Key: $K = \begin{pmatrix} 7 & 8 \ 11 & 11 \end{pmatrix}$, decryption uses $P = K^{-1}C \pmod{26}$.
Step 1: Convert ciphertext to numbers (A=0, ..., Z=25)
$$D=3,\ R=17,\ I=8,\ J=9$$
$$C_1=\begin{pmatrix}3\17\end{pmatrix},\quad C_2=\begin{pmatrix}8\9\end{pmatrix}$$
Step 2: Compute $K^{-1} \pmod{26}$
Determinant: $$\det(K)=(7\cdot 11)-(8\cdot 11)=77-88=-11\equiv 15\pmod{26}$$
Inverse of determinant: find $d$ with $15d\equiv 1\pmod{26}$. $$15\times 7=105=4(26)+1\equiv 1\pmod{26}\Rightarrow 15^{-1}\equiv 7$$
Adjugate: $$\text{adj}(K)=\begin{pmatrix}11 & -8\ -11 & 7\end{pmatrix}\equiv\begin{pmatrix}11 & 18\ 15 & 7\end{pmatrix}\pmod{26}$$
Inverse: $$K^{-1}=7\begin{pmatrix}11 & 18\ 15 & 7\end{pmatrix}=\begin{pmatrix}77 & 126\ 105 & 49\end{pmatrix}\equiv\begin{pmatrix}25 & 22\ 1 & 23\end{pmatrix}\pmod{26}$$
Step 3: Decrypt first pair "DR"
$$P_1=\begin{pmatrix}25 & 22\ 1 & 23\end{pmatrix}\begin{pmatrix}3\17\end{pmatrix}\pmod{26}$$
Row 1: $25\cdot3+22\cdot17=75+374=449$; $449\bmod 26 = 449-17(26)=449-442=7$ Row 2: $1\cdot3+23\cdot17=3+391=394$; $394\bmod 26 = 394-15(26)=394-390=4$
$$P_1=\begin{pmatrix}7\4\end{pmatrix}\Rightarrow H,\ E$$
Step 4: Decrypt second pair "IJ"
$$P_2=\begin{pmatrix}25 & 22\ 1 & 23\end{pmatrix}\begin{pmatrix}8\9\end{pmatrix}\pmod{26}$$
Row 1: $25\cdot8+22\cdot9=200+198=398$; $398\bmod 26 = 398-15(26)=398-390=8$ Row 2: $1\cdot8+23\cdot9=8+207=215$; $215\bmod 26 = 215-8(26)=215-208=7$
$$P_2=\begin{pmatrix}8\7\end{pmatrix}\Rightarrow I,\ H$$
Step 5: Assemble plaintext
$$H,E,I,H \Rightarrow \boxed{\textbf{HEIH}}$$
Verification (encrypt HEIH back): $K\begin{pmatrix}7\4\end{pmatrix}=\begin{pmatrix}49+32\77+44\end{pmatrix}=\begin{pmatrix}81\121\end{pmatrix}\equiv\begin{pmatrix}3\17\end{pmatrix}=DR$ ✓ $K\begin{pmatrix}8\7\end{pmatrix}=\begin{pmatrix}56+56\88+77\end{pmatrix}=\begin{pmatrix}112\165\end{pmatrix}\equiv\begin{pmatrix}8\9\end{pmatrix}=IJ$ ✓
Decrypted plaintext: HEIH
Make Unit 4 stick
Practice CSC327 with flashcards & quizzes