I have a doubt about the Diffie-Hellman problem:
Is it possible to send a message to someone using only the Diffie–Hellman key exchange?
Since it's called a key exchange can you only make a key?
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.
Sign up to join this communityI have a doubt about the Diffie-Hellman problem:
Is it possible to send a message to someone using only the Diffie–Hellman key exchange?
Since it's called a key exchange can you only make a key?
What exactly do you doubt about the CDH or DDH problems?
Is it possible to send a message to someone using only the Diffie–Hellman key exchange?
You cannot "send" a message using DHKE but you may use its resulting shared secret as a one-time-pad (by multiplication; not XOR) to "encrypt" a message encoded as a group element. When the sender uses a unique key per message, this is called ElGamal.
To encrypt a larger message we'll step back to Diffie-Hellman and use the hash of its shared secret as our key for a symmetric stream cipher. This is called hybrid encryption.
However neither scheme above authenticates our messages, thus an active adversary may tamper with our messages and depending on our application may recover our messages. Along the symmetric route we just need to replace encryption with authenticated encryption.
Instead of reinventing the wheel, this function is known to libsodium as crypto_seal_box
. If you want to send many messages, you may prefer one handshake per session and use streams.
You probably don't want to use a single DHKE, but perhaps two or three. Two if you need forward secrecy and three if you want forward secrecy and mutual authentication. The Noise protocol elaborates on many variations and Signal uses an extension of triple-DH. All of these options require the receiver to send the sender at least one message per handshake.
Diffie–Hellman is a method for key exchange, not encryption. Typically, you use it to determine a shared secret with your partner, then use that shared secret as a key (or to derive a key) for a symmetric encryption scheme, such as AES. The symmetric cryptosystem is what you use to transmit the actual message.
This two-step process of first exchanging keys, then sending the actual encrypted message, is known as a hybrid cryptosystem.