Cyber Security Assignment ( Python)

Exercise 3: Python
Mark: 20%
Alice and Bob need to individually and separately generate the same encryption (secret) key to allow them
to securely exchange a message (read about Diffie-Hellman key exchange). To do this, in this case, they both
need two public numbers (𝑝 = 353 and 𝛼 = 3). Alice calculates an individual public key (π‘Œπ΄ = 40) and sends it
to Bob. Bob calculates an individual public key (π‘ŒB = 248) and sends it to Alice. To generate the secret key
(K), Alice and Bob would need their individual private keys (𝑋𝐴 and XB respectively) and the individual public
keys they received.
The relevant equations are:
π‘Œπ΄ = ∝
𝑋𝐴 π‘šπ‘œπ‘‘ 𝑝
π‘Œπ΅ = ∝
𝑋𝐡 π‘šπ‘œπ‘‘ 𝑝
𝐾𝐴 = π‘Œπ΅
𝑋𝐴 π‘šπ‘œπ‘‘ 𝑝 OR 𝐾𝐡 = π‘Œπ΄
𝑋𝐡 π‘šπ‘œπ‘‘ 𝑝
Write a python script that will crack (brute force) the values of 𝑋𝐴 and 𝑋𝐡 and use them to generate the
secret key (𝐾). You must comment your code and explain the steps. Deliverables include commented code
and screenshots showing the values (𝑋𝐴, 𝑋𝐡 and 𝐾) generated by the code.
Hint: You already know the values of (𝑝 = 353, 𝛼 = 3, π‘Œπ΄ = 40, and π‘ŒB = 248). π‘šπ‘œπ‘‘ 𝑝 means β€˜modulus π‘β€˜
(check the mathematical notation for modulus). Your range is 1 to 𝑝 βˆ’ 1, which means 1 – 352. You are
looking for the values of 𝑋𝐴 and 𝑋𝐡 such that 𝐾𝐴 = 𝐾𝐡.
____________________________________________________