I'm trying to code up a encrypted communication program. Originally I was thinking that I would use public key cryptography and then I would keep the public keys in a database where users could query the database for another user's public key to encrypt their message. However this allows me to read their message if I ever sent them my public key instead of the their intended recipient's public key.

Is it possible to have forward secrecy if they grab the public key from the central server, which I control? It seems to me that if you use some forward secrecy algorithms like STS I would still be able to send both users my public key and they would be none the wiser.


1 Answer 1


It's not possible to exchange public keys over an untrusted channel without the help of a trusted third-party. Even STS assumes that either: a) the public keys were exchanged in advance; or b) certificates are used to help establish key trust (so either a CA, Web of Trust or similar is needed). In your scenario, you're acting as the trusted third-party, asserting to each user that a given key belongs to him/her, and that you're not secretly performing a man-in-the-middle attack (sometimes called institutional MitM). In other words, you're correct in your assumptions.

I'd suggest looking at this answer for some insights on the subject of public key trust. I'm afraid there's little I can suggest you in order to improve over the existing models though...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .