The Diffie-Hellman key agreement protocol allows two users to exchange a secret key over an insecure medium without any prior secrets. It uses two public parameters, a prime number p and an integer g that is primitive root modulo p. Each user selects a private random number and computes their public number using g and p. Both users can then compute the same shared secret key using each other's public numbers and their own private number. The security relies on the difficulty of calculating the shared secret key given only the public values. However, it is vulnerable to man-in-the-middle attacks without authentication. The document provides an example of how the algorithm works and discusses advantages like public key distribution and disadvantages like lack of authentication.