A case of parameter injection MiTM on DHKE
You can read up on Diffie-Hellman Key Exchange in various articles, books or get started on Wikipedia. We’ll begin the discourse with a short intro anyway.
Background#
In DH key exchange scheme, two interested parties Alice and Bob participate in an exchange, at the end of which both have a shared secret. This secret is jointly computed over their inputs, one of which is kept private.
Let the two parties be Alice and Bob. Two global parameters $g$ and $p$ are decided upon at the start of the exchange. $g$ is the generator of the group $(\mathbb{Z}/p\mathbb{Z})^\times$. $p$ is a prime integer. $g$ is then said to be the primitive root modulo $p$.
Once the exchange begins,
-
Alice chooses an integer $a$, which is her private key. Alice then calculates $A \equiv g^a \pmod{p}$, which is declared as her public key, and is sent to Bob.
-
Bob does the same and chooses b , his private key and calculates $B \equiv g^b \pmod{p}$, his public key. This is sent to Alice.
-
The shared secret $S$ is computed by Alice as $S \equiv B^a \pmod{p}$ and by Bob as $S \equiv A^b \pmod{p}$. Both values are found to be equal.