I understand how public key infrastructure works.

There is a private and public key, and someone may use the public key to encrypt data that can only be decrypted with the private key.

However there seems to be a flaw with this...

When you want someone, E.g Bob to send you a secret message, you send the key to him: Public key ==> Bob

Bob then encrypts the data and sends it back to me.

Data ==> Public key ==> back to me

But what happens if at the first stage Public key ==> Bob an attacker modifies the public key to one he has the private key to, then decrypts the data Bob unknowingly sends?

How is this prevented?

  • 1
    Public key cryptography (PKC) uses public and private keys as you describe. Public key infrastructure (PKI) builds on this to distribute the public keys in a secure way which does NOT consist simply of 'Public key ==> Bob' exactly to prevent substitution or alteration. So apparently you don't understand PKI all that well. The brief answer is: usually a certificate signed by a CA or web-of-trust signed keys. Commented May 25, 2016 at 1:09

2 Answers 2



  • you give the public key to Bob when you physically meet him and mutually verify identities (as at a key-signing party), or

  • Bob verifies your public key through a trusted introducer (e.g. a Certification Authority)

This is the "Infrastructure" part of PKI.

  • Makes sense, thanks. So there always has to be someone at the end of the day who you just have to trust (e.g CA)?
    – Joseph
    Commented May 25, 2016 at 1:46
  • 1
    @JosephA. yes. Undertanding that such someone could be yourself
    – Ángel
    Commented May 25, 2016 at 1:54
  • Option three, variation on option one, Bob is a CA and his certificate is already in your root trust store.
    – Kevin
    Commented May 25, 2016 at 6:07
  • @Kevin Just wondering though, how is the transfer CA --> Bob protected against attackers?
    – Joseph
    Commented Jun 5, 2016 at 14:06
  • 1
    @JosephA.: Either the CA is already trusted by Bob (because its public key is built into his operating system or browser; this is called a "root CA") or the CA presents its own certificate which is signed by another CA that Bob trusts. Eventually everything chains back to a root CA.
    – Kevin
    Commented Jun 5, 2016 at 17:35

There are broadly two classes of methods: you deliver the public key in person (which assumes you yourself are immune from tampering in transit, of course), or you use a trustworthy intermediary to vouch for it, say, by signing a certificate — cryptographically or otherwise — or carrying it in a sealed and hopefully tamper-evident envelope.

In practice, private people interested in secure key exchange tend to come together and hold keysigning parties; there are well-established traditions for this sort of thing by now. In cryptographic literature, the metaphor commonly used for secure key material delivery is diplomatic pouch.

You must log in to answer this question.

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