Tribhuwan University

Institute of Science and Technology

2080

Bachelor Level / Third Year / Fifth Semester / Science

B.Sc in Computer Science and Information Technology (CSC327)

(Cryptography)

Full Marks: 60

Pass Marks: 24

Time: 3 Hours

Candidates are required to give their answers in their own words as for as practicable.

The figures in the margin indicate full marks.

Section A

Long Answers Questions

Attempt any TWO questions.
[2*10=20]
1.
Define discrete logarithms. How key generation, encryption and decryption is done in RSA. In a RSA cryptosystem, given p=13 and q=7, determine private key, public key and perform encryption and decryption for the text M='hi' using 0 to 25 for letters from a to z.[10]

Discrete Logarithms and RSA Cryptosystem

Discrete Logarithms

Discrete Logarithm is defined as: Given a prime number pp, a generator gg, and a value yy, find xx such that gxmodp=yg^x \mod p = y.

  • It is the inverse of modular exponentiation
  • Computing discrete logarithms is computationally hard, which forms the basis of many asymmetric cryptosystems (like Diffie-Hellman, ElGamal)
  • Example: If 3xmod7=63^x \mod 7 = 6, then the discrete logarithm x=3x = 3

RSA Key Generation, Encryption and Decryption

A. Key Generation

  • Step a: Choose two large prime numbers pp and qq
  • Step b: Compute n=p×qn = p \times q
  • Step c: Compute Euler's totient function ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1)
  • Step d: Choose public exponent ee such that 1<e<ϕ(n)1 < e < \phi(n) and gcd(e,ϕ(n))=1\gcd(e, \phi(n)) = 1
  • Step e: Compute private exponent dd such that ed1modϕ(n)e \cdot d \equiv 1 \mod \phi(n)
  • Public Key = (e,n)(e, n)
  • Private Key = (d,n)(d, n)

B. Encryption

Ciphertext: C=MemodnC = M^e \mod n

C. Decryption

Plaintext: M=CdmodnM = C^d \mod n


Numerical Solution: p = 13, q = 7, M = 'hi'

Step a: Compute n

n=p×q=13×7=91n = p \times q = 13 \times 7 = 91

Step b: Compute ϕ(n)\phi(n)

ϕ(n)=(p1)(q1)=12×6=72\phi(n) = (p-1)(q-1) = 12 \times 6 = 72

Step c: Choose e

Choose ee such that gcd(e,72)=1\gcd(e, 72) = 1 and 1<e<721 < e < 72

Let e=5e = 5 (since $\gcd(5, 72) = 1$)

Step d: Compute d

Find dd such that ed1mod72e \cdot d \equiv 1 \mod 72

5d1mod725 \cdot d \equiv 1 \mod 72

d=29(since 5×29=145=2×72+11mod72)d = 29 \quad (\text{since } 5 \times 29 = 145 = 2 \times 72 + 1 \equiv 1 \mod 72)

Keys:

  • Public Key = (e,n)(e, n) = (5,91)(5, 91)
  • Private Key = (d,n)(d, n) = (29,91)(29, 91)

Step e: Convert plaintext M = 'hi' to numbers (a=0, b=1, ..., z=25)

  • h = 7
  • i = 8

Step f: Encryption (C=Memodn)(C = M^e \mod n)

For h (M = 7):

C1=75mod91C_1 = 7^5 \mod 91

72=497^2 = 49 74=492=2401mod91=240126×91=24012366=357^4 = 49^2 = 2401 \mod 91 = 2401 - 26 \times 91 = 2401 - 2366 = 35 75=74×7=35×7=245mod91=2452×91=637^5 = 7^4 \times 7 = 35 \times 7 = 245 \mod 91 = 245 - 2 \times 91 = 63

C1=63C_1 = 63

For i (M = 8):

C2=85mod91C_2 = 8^5 \mod 91

82=648^2 = 64 84=642=4096mod91=409645×91=40964095=18^4 = 64^2 = 4096 \mod 91 = 4096 - 45 \times 91 = 4096 - 4095 = 1 85=84×8=1×8=88^5 = 8^4 \times 8 = 1 \times 8 = 8

C2=8C_2 = 8

Ciphertext = (63, 8)


Step g: Decryption (M=Cdmodn)(M = C^d \mod n)

For C1=63C_1 = 63:

M1=6329mod91M_1 = 63^{29} \mod 91

63mod91=6363 \mod 91 = 63 632=3969mod91=396943×91=39693913=5663^2 = 3969 \mod 91 = 3969 - 43 \times 91 = 3969 - 3913 = 56 634=562=3136mod91=313634×91=31363094=4263^4 = 56^2 = 3136 \mod 91 = 3136 - 34 \times 91 = 3136 - 3094 = 42 638=422=1764mod91=176419×91=17641729=3563^8 = 42^2 = 1764 \mod 91 = 1764 - 19 \times 91 = 1764 - 1729 = 35 6316=352=1225mod91=122513×91=12251183=4263^{16} = 35^2 = 1225 \mod 91 = 1225 - 13 \times 91 = 1225 - 1183 = 42

6329=6316×638×634×631=42×35×42×63mod9163^{29} = 63^{16} \times 63^8 \times 63^4 \times 63^1 = 42 \times 35 \times 42 \times 63 \mod 91

42×35=1470mod91=147016×91=14701456=1442 \times 35 = 1470 \mod 91 = 1470 - 16 \times 91 = 1470 - 1456 = 14 14×42=588mod91=5886×91=588546=4214 \times 42 = 588 \mod 91 = 588 - 6 \times 91 = 588 - 546 = 42 42×63=2646mod91=264629×91=26462639=742 \times 63 = 2646 \mod 91 = 2646 - 29 \times 91 = 2646 - 2639 = 7

M1=7=hM_1 = 7 = \textbf{h}

For C2=8C_2 = 8:

M2=829mod91M_2 = 8^{29} \mod 91

84mod91=18^4 \mod 91 = 1 (calculated above) $8^{29} = 8^{28} \times 8^1 = (8^4)^7 \times 8 = 1^7 \times 8 = 8$

M2=8=iM_2 = 8 = \textbf{i}


Conclusion

Decrypted message = 'hi', which matches the original plaintext, confirming that RSA encryption and decryption work correctly with the generated keys.

2.
Write down the encryption and decryption process at 2-DES and 3-DES. Explain the Fiestal cipher structure. Divide 5x2+4x+65x^2 + 4x + 6 by 2x+12x + 1 over GF(7).[10]
3.
What are the applications of hash functions? Discuss how SHA-1 algorithm generates hash value from a given message.[10]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
Show encryption and decryption of "csit" using hill cipher having key, [5]
5.
Give the formal definition of authentication system. Describe about one way and mutual authentication system.
[3257]\begin{bmatrix} 3 & 2 \\ 5 & 7 \end{bmatrix}
[5]
6.
List the stage of certificate life cycle. What are the types of firewalls? [5]
7.
What is malicious logic? How zombies are different from trojan horses? [5]
8.
How Miller Rabin test is used for primality testing? Show whether the number 561 passes the test. [5]
9.
Show that the set of integers is Ring under addition and multiplication. [5]
10.
How substitution ciphers are different from transposition ciphers? Given a message M="CSIT PROGRAM IS A HOT CAKE", encrypt M using Rail Fence cipher with rail size 3. [5]
11.
Describe about IPSec. List the five services of PGP. [5]
12.
How does meet in middle attack work in Diffie Helman key exchange protocol? Explain. [5]