0
$\begingroup$

I am working on this question and I am wondering I have figured out the secret key, but my problem is I don't know how to use the secret key to decrypt the ciphertext.

Thanks for the help!

$\endgroup$
2
  • 2
    $\begingroup$ Diffie-Hellman Exchange is used for establishing a common secret between two parties, not for encrypting/decrypting $\endgroup$
    – cygnusv
    Commented Jun 8, 2016 at 6:02
  • 1
    $\begingroup$ I think more context is needed to answer the question in a meaningful way. $\endgroup$ Commented Jun 9, 2016 at 18:08

2 Answers 2

2
$\begingroup$

Diffie Hellman(DH) is a key exchange method, it is not a encryption/decryption algorithm. You have to use the secret key generated from DH in a symmetric cipher algorithm which is the algorithm used to create ciphertext from plaintext in the first place.

For example, lets say Alice and Bob make a DH key exchange to generate a secret key $K$, then Alice uses that key to send a message $M$ to Bob by encrypting it using an encrption algorithm such as AES. So Alice creates ciphertext $C =AES_{Enc}(M,K)$ and Alice sends $C$ to Bob. Then Bob takes ciphertext $C$ and decrypts it using the same algorithm and the same secret key that Alice used to get the message: $M =AES_{Dec}(C,K)$.

$\endgroup$
3
  • 1
    $\begingroup$ I'd like a mention of a KDF (PRF) in the answer. A well defined protocol would probably not directly use the agreed secret as a symmetric key. Hopefully Alice & Bob use a separate key for sending and receiving, and use an authenticated cipher or MAC on top of just performing encryption. $\endgroup$
    – Maarten Bodewes
    Commented Jun 8, 2016 at 9:04
  • $\begingroup$ @MaartenBodewes Thanks for additional info. related to the underlying protocol that Alice and Bob communicates. I just wanted to correct the misunderstanding about DH Exchange. $\endgroup$
    – Makif
    Commented Jun 8, 2016 at 10:26
  • 1
    $\begingroup$ Yes and it's a pretty clear description at the right level of understanding. Already upvoted of course! $\endgroup$
    – Maarten Bodewes
    Commented Jun 8, 2016 at 11:12
0
$\begingroup$

Two parties choose private secrets $x_1$ and $x_2$, which they then exponentiate; $2^{x_1}$ and $2^{x_2}$, and swap with each other.

Each party is now able to compute a shared secret, $s = (2^{x_1})^{x_2} = (2^{x_2})^{x_1}$, which can be used to initialize a symmetric cipher for further communication.

When these operations are carried out modulo some large prime number, it is known as the Diffie-Hellmen key exchange. Finding the shared secret without knowledge of the private secrets amounts to solving the discrete logarithm problem which is considered computationally impractical.

$\endgroup$
1
  • 1
    $\begingroup$ Actually, the value of the generator they both start off with needn't be 2, but is in general a well-known value $g$ (which is part of the description of the group). $g=2$ is used for some groups; however some groups use different values for $g$ (as for those groups, the value $2^x \bmod p$ would leak $x \bmod n$ for a surprisingly large $n$; for group23 from RFC5114 (section 2.2), $n \approx 2^{100}$) $\endgroup$
    – poncho
    Commented Jun 9, 2016 at 16:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.