Describe in detail a man-in-the-middle attack on the Diffie-Hellman key-exchange protocol whereby the adversary ends up sharing a key k A with Alice and a different key k B with Bob, and Alice and Bob cannot detect that anything has gone wrong. What happens if Alice and Bob try to detect the presence of a man-in-the-middle adversary by sending each other (encrypted) questions that only the other party would know how to answer? Solution In man-in-the-middle attack, an opponent Eve intercepts Alice\'s public key K A and sends her own public key as K A to Bob. When Bob transmits his public key K B , Eve substitutes it with her own and sends it as K B to Alice. Eve and Alice thus agree on one shared key and Eve and Bob agree on another shared key. After this exchange, Eve simply decrypts any messages sent out by Alice or Bob, and then reads and possibly modifies them before re-encrypting with the appropriate key and transmitting them to the other party. This vulnerability is present because Diffie-Hellman key exchange does not authenticate the participants. The man-in-the-middle attack may be prevented by using digital signatures and other cryptographic schemes. Bob to encrypt a message so that only Alice will be able to decrypt it, with no prior communication between them other than Bob having trusted knowledge of Alice\'s public key. Alice\'s public key is g K A mod p, g,p. . To send her a message, Bob chooses a random K B and then sends Alice g K B mod p together with the message encrypted with ( g K A ) K B mod p symmetric key. Only Alice can determine the symmetric key and hence decrypt the message because only she has K A. .