0
$\begingroup$

I'm planning on making a chat application for fun, in C++. I just have a few questions in order to maintain forward/future secrecy across messages.

If one party is offline, but the other isn't, what do we do in this case? I've been planning on storing it in a database until the other party comes online and reads it, in which case, it's deleted from the server.

When do we regenerate the exchange? When the user's original key is lost (whether that be from uninstalling/reinstalling, corruption etc.) or another time?

How do we efficiently generate keypairs between two clients? Should we be storing the public keys in a database table, and whenever the first message is sent we use DH?

I've been planning on using AES-256-GCM once the key is derived from the DH exchange. I'm just trying to wrap my head around it all. I managed to successfully use a Diffie-Hellman exchange on my local system (albeit in RAM) but it was successful and I'm looking to branch out and expand my knowledge/experience.

$\endgroup$
3
  • 3
    $\begingroup$ Use, Libsodium. and how do you plan to mitigate from Man in the middle attack? The clients must be sure that the public keys are valid. Also, you need digital signatures since you need ephemeral public keys for each session. See Signal protocol. $\endgroup$
    – kelalaka
    Commented Apr 29, 2021 at 19:33
  • $\begingroup$ @kelalaka Libsodium looks awesome! As for MITM attacks, I haven't figured out yet, but I'll probably use TLS+websockets (I forgot the terminology for that). I haven't found much documentation on the signal protocol itself, and the Github seems to be a bit of a mess currently. $\endgroup$
    – Jake
    Commented Apr 29, 2021 at 19:39
  • 3
    $\begingroup$ This paper has a rather complete theoretical description of the signal protocol (in addition to a formal analysis). $\endgroup$
    – SEJPM
    Commented Apr 30, 2021 at 8:00

1 Answer 1

1
$\begingroup$

Make a smart chat client.

Alice’s chat client creates a session key pair and sends her public session key to Bob’s chat client as a signed message. (At this point it’s likely best to assure Bob is live in chat. But it would be okay to wait for Bob to start chatting.) Bob’s chat client responds by creating his session key pair and sending his public session key to Alice also signed. Both parties then create the same symmetric encryption key to use.

When to run the D-H key agreement again? At any point when either party feels that negotiating a new session key is important. Make appropriate rules when to auto-renegotiate.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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