Information Security
Assignment
Name : M. Rizwan Ashraf
Roll no : BS/065/SP-22
Section : B
Submit To : Ma’am Unsa Khizer
Problem Statement #1: Diffie-Hellman Key Exchange Protocol
Tasks:
1. Steps of the Diffie-Hellman Key Exchange Protocol:
o Step 1: Agree on public parameters pp (a prime number) and gg (a primitive root
modulo pp).
o Step 2: Each party selects a private key:
Alice selects aa.
Bob selects bb.
o Step 3: Each party computes their public key:
Alice computes A=gamod pA = g^a \mod p.
Bob computes B=gbmod pB = g^b \mod p.
o Step 4: Exchange the public keys AA and BB.
o Step 5: Each party computes the shared secret key using the other’s public key:
Alice computes K=Bamod pK = B^a \mod p.
Bob computes K=Abmod pK = A^b \mod p.
o The shared secret KK will be the same for both.
2. Calculate the public keys:
o For Alice: A=gamod p=56mod 23=15625mod 23=8A = g^a \mod p = 5^6 \mod
23 = 15625 \mod 23 = 8.
o For Bob: B=gbmod p=515mod 23=30517578125mod 23=19B = g^b \mod p =
5^{15} \mod 23 = 30517578125 \mod 23 = 19.
3. Compute the shared secret key:
o For Alice: K=Bamod p=196mod 23=47045881mod 23=2K = B^a \mod p = 19^6
\mod 23 = 47045881 \mod 23 = 2.
o For Bob: K=Abmod p=815mod 23=35184372088832mod 23=2K = A^b \mod p
= 8^{15} \mod 23 = 35184372088832 \mod 23 = 2.
4. Verify the shared secret:
o Both Alice and Bob compute K=2K = 2, confirming the shared secret is the same.
Problem Statement #2: RSA Algorithm
Tasks:
1. Compute the public key and private key:
o p=13,q=17p = 13, q = 17, compute n=p×q=13×17=221n = p \times q = 13 \times
17 = 221.
o Compute ϕ(n)=(p−1)×(q−1)=12×16=192\phi(n) = (p - 1) \times (q - 1) = 12 \times
16 = 192.
o Choose e=5e = 5, such that 1<e<ϕ(n)1 < e < \phi(n) and gcd(e,ϕ(n))=1\text{gcd}
(e, \phi(n)) = 1.
o Compute dd such that e⋅d≡1mod ϕ(n)e \cdot d \equiv 1 \mod \phi(n). Using the
extended Euclidean algorithm: d=77d = 77 (since 5⋅77=385≡1mod 1925 \cdot 77
= 385 \equiv 1 \mod 192).
o Public key: (e,n)=(5,221)(e, n) = (5, 221).
o Private key: (d,n)=(77,221)(d, n) = (77, 221).
2. Encrypt the message M=10M = 10:
o Ciphertext C=Memod n=105mod 221=100000mod 221=131C = M^e \mod n =
10^5 \mod 221 = 100000 \mod 221 = 131.
3. Decrypt the ciphertext:
o Original message M=Cdmod n=13177mod 221=10M = C^d \mod n = 131^{77} \
mod 221 = 10.
4. Significance of public and private keys:
o The public key (e,ne, n) is used for encryption and can be shared openly.
o The private key (d,nd, n) is used for decryption and must be kept secret.
Together, they ensure confidentiality and integrity of communication.
Problem Statement #3: AES Encryption
Tasks:
1. Convert plaintext to hexadecimal:
o Plaintext: "HELLO1234567890".
o ASCII to hexadecimal:
H=48,E=45,L=4C,L=4C,O=4F,1=31,2=32,3=33,4=34,5=35,6=36,7=37,8=38,9=3
9,0=30H = 48, E = 45, L = 4C, L = 4C, O = 4F, 1 = 31, 2 = 32, 3 = 33, 4 = 34, 5 =
35, 6 = 36, 7 = 37, 8 = 38, 9 = 39, 0 = 30. Hexadecimal:
48454C4C4F3132333435363738393048 45 4C 4C 4F 31 32 33 34 35 36 37 38
39 30.
2. Perform the AddRoundKey step:
o The AES state is a 4x4 matrix of the plaintext in hexadecimal:
o [48, 45, 4C, 4C]
o [4F, 31, 32, 33]
o [34, 35, 36, 37]
o [38, 39, 30, 00] // padded with 00
o The AES key (in hex): 2B7E151628AED2A6ABF7158809CF4F3C2B 7E 15 16
28 AE D2 A6 AB F7 15 88 09 CF 4F 3C, arranged as a 4x4 matrix.
o Perform XOR operation between the plaintext and the key matrix.
3. AES ensures confidentiality and efficiency:
o AES uses substitution-permutation networks, combining confusion and diffusion
for strong security.
o Key expansion and multiple rounds ensure resistance to attacks.
o Its symmetric nature ensures high encryption and decryption speed.
4. Compare AES with other algorithms:
o DES: AES is more secure due to a larger key size and more complex rounds.
o RSA: AES is faster and suitable for bulk data encryption; RSA is better for secure
key exchange.
o Blowfish: AES is more widely adopted and optimized for modern systems.