1
$\begingroup$

With its public and private key(s), Wireguard looks a bit like PGP. But it is used for encryption of network packets and not normal text messages. I'm on a system with Wireguard already installed and don't want to install more programs than necessary.

How, can I use a public Wireguard key to encrypt a text message which I then can decrypt with a private key?

$\endgroup$
2
$\begingroup$

Wireguard is not PGP. In particular, Wireguard doesn't do several things that PGP does, because doing those things is very difficult to do securely. One of those things is encrypting anything with a public key: Wireguard only does elliptic-curve Diffie-Hellman key agreement.

In general, you should never encrypt a message with asymmetric cryptography (public/private keys) directly. You should either use a Key Encapsulation Mode (KEM), or a Diffie-Hellman style key agreement exchange (probably elliptic-curve based). You then use the resulting shared secret key to encrypt messages using an Authenticated Encryption with Associated Data (AEAD) symmetric cipher, like AES-GCM or ChaCha20-Poly1305 (Wireguard does this).

Asymmetric cryptography is good for key exchange, either with a KEM or a DH agreement. It's also good for signing and verification of messages. It's not good for encryption.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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