# Diffie Hellman Algorithm in Cryptography

Cryptography | Diffie Hellman Algorithm: In this tutorial, we will briefly study the basic Diffie Hellman and its examples aim to capture. We will cover the types of messages in Diffie Hellman. By Monika Sharma Last updated : May 24, 2023

## Diffie Hellman Algorithm

**Diffie Hellman key exchange algorithm** is a method for securely or secretly exchanging cryptographic keys or a key use in encryption or decryption over a public communications channel or away. Keys are not eventually exchanged – they are joint and derived. It is named after their inventors who invent this is Whitfield Diffie and Martin Hellman.

If Alice and Bob want to communicate with each other, they firstly discuss a variable between them a large prime number "p", and a generator or base "g" (where 0 < g < p).

Alice chooses "a" secret integer as her private key and then calculates g^a mod p which is her public key. Bob chooses his private key "b", and calculates his public key in the same way Alice find its public key.

Alice and Bob then exchange each other‘s public keys. Alice now knows "a" and Bob's public key g^b mod p as to encrypt the message. She is not able to find the value of b from Bob's public key because this is a hard or complex mathematical problem known as the discrete logarithm problem in mathematics. She can then find (g^b)^a mod p = g^ab mod p.

Bob knows "b" and "g^a", so he can find "(g^a)^b mod p = g^ab mod p". Therefore both Alice and Bob know a key called shared secret key "g^ab mod p". An eavesdropper Eve who was listening in on the communication knows p, g, Alice's public key (g^a mod p) and Bob's public key (g^b mod p). She is unable to find or calculate the shared secret key from these values.

In the mode of static-static, both Alice and Bob obtain their private/public keys over multiple communications which use this. Therefore the resulting shared secret key will be the same every time. In ephemeral-static mode only one party will generate or create a new private/public key every time, thus a new shared secret will be generated or created.

## History of the Diffie-Hellman Key Exchange

The **Diffie-Hellman key exchange** traces its started back to the 1970s. While the area of cryptography had developed significantly throughout the earlier twentieth-century of the era, these advancements were mainly focused in the area of symmetric-key cryptography of the crypto.

It wasn't until 1976 that public-key algorithms mixed in the public key, when Whitfield Diffie and Martin Hellman published their paper, “New Directions in Cryptography”. The collaboration outlined the way of mechanisms behind a new system, which would come to be known as the **"Diffie-Hellman key exchange of Bob and Alice"**.

The work was partly motivated by earlier developments made by **"Ralph Merkle"**. The so-called **"Merkle's Puzzles"** include one party creating and sending several cryptographic puzzles or the text to the others. These puzzles or text would take a middle amount of computational resources to solve the puzzle.

## Diffie Hellman Algorithm Limitation

The most serious limitation of **Diffie-Hellman** in its basic or "pure" form is the absence of authentication. Communications using Diffie-Hellman all by itself are vulnerable to man in the middle attacks used in any cipher. Ideally, Diffie-Hellman should be used or need in conjunction with an admit authentication method such as digital signatures to verify the identities of the person using this signature in a bank or somewhere over the public communications medium. Diffie-Hellman is well suited for use in data communication but is less often used for data stored or archived over long periods in this kind of cipher.

Related Tutorials

- Introduction to Cryptography
- Types of Cryptography: Symmetric and Asymmetric
- Cryptography: Caesar Cipher and its Python Implementations
- Substitution Techniques and Its Types | Cryptography
- Cryptographic Techniques: Vigenére Cipher, Playfair Cipher, Hill Cipher
- Cryptography Transposition Techniques
- Playfair Cipher in Cryptography
- Feistel Cipher in Cryptography
- Elliptic Curve Cryptography
- Message-Digest Algorithm 5 (MD5) in Cryptography
- Cryptography Security: Goals, Attacks, and Principles
- Difference Between Stream Ciphers and Block Ciphers
- Caesar Cipher in Cryptography
- Vigenère Cipher in Cryptography
- Vernam Cipher in Cryptography

Comments and Discussions!