I have two separate system (client) and (server). I am having a problem which is to encrypt a message from the client and decrypt at the server. In order to do that, I am required to transmit my key along with the message through UDP packets. However, is there any possible ways to ensure the key is transmitted securely?


1 Answer 1


You don't transfer the key, not at least un-encrypted.

There are several ways to "establish a shared key" between authenticated systems.

Using key exchange schemes such as Diffie-Hellman, its elliptic-curve versions such as ECDH, X25519/X448, etc, as well as some schemes secure even if you attack it with a quantum computer such as NTRU (formerly NTRUEncrypt), Kyber, Saber.

Notice I said authenticated system. key exchange schemes require the public key of the peer - which is static if you just hard-code it into your application; a better way is to use a digital signature to sign an ephemeral key exchange public key and hard-code the digital signature verification key into the application.

All in all, there is a well-established protocol with existing free and open-source implementations called TLS, which you can use to exchange an initial key, then import that key into your UDP-based protocol.

The QUIC protocol does about just that: it doesn't design new key exchange or authentication handshake protocol, it imports the key from TLS handshake and use it in the en/de-crypting UDP packets.

  • $\begingroup$ Is there any implementation for Kyber and Saber that we can use? $\endgroup$
    – kelalaka
    Oct 10, 2020 at 10:25
  • $\begingroup$ @kelalaka csrc.nist.gov/Projects/post-quantum-cryptography/… Round 3 packages hadn't been published as of this writing. $\endgroup$
    – DannyNiu
    Oct 10, 2020 at 11:12
  • $\begingroup$ I was a bit more like libsodium. Those packages, afaik, for science only. Thanks anyway. $\endgroup$
    – kelalaka
    Oct 10, 2020 at 11:14
  • $\begingroup$ The OP wants practical stuff, so giving some libraries as a link would help those kinds of questions. Libsoidum seems the best choice for now. $\endgroup$
    – kelalaka
    Oct 10, 2020 at 11:16

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.