Digital Certificates

Is there a good website on this subject? Or, can someone explain how these things work?

Here’s what I found on a website:

The sender encrypts his message with his PRIVATE key, then sends the message to the receiver. The receiver then decrypts the message using the PUBLIC key.

Well hell, if the key is PUBLIC then anyone can decrypt the message. Right? I think there might be some typos on that website, and that really confuses the issue.

When done this way it is not supposed to keep the message secret.
Think of it as a signature. If you get a message that can be decrypted with a particular public key, you know that it was encrypted by someone who has the “other half” of the key.
If you want to keep a message secret, you do it the other way round, you encrypt with the public key and need the private key in order to decrypt.

(In reality there is an additional layer, the public key algorithm is usually applied to short digests of the message or session-specific keys, but the principle remains the same)

That’s not how it normally works. You sign messages with your private key. That way, anyone who sees the message can use your public key to verify that you did, indeed, send the message.

If you want to send an encrypted message, you sign it with the recipient’s public key. That way, only the recipient can decrypt the message.

Or, if you’re being really secure about things, you do both. Sign a message with your private key, and then encrypt it, signature and all, with the recipient’s public key. You could encrypt first and then sign, too, but then anyone who sees the encrypted message (and has your public key) can discover who sent it.

Hash: SHA1

By the way, if you’d like to test PGP encryption and signing, you can
download the PGP Freeware software. To give you something to start
with, you can save the following to a text file, and then import it
as a public key:

Version: PGP 8.1


You can then copy this entire post to the clipboard, and verify that
the signature (which can only be generated by my private key) matches
the public key in the post. Of course, since the key is in the post,
it’s a fairly trivial example.

Version: PGP 8.1


:smack: You encrypt the message with the recipient’s public key.

So if you and I are going to do “secret” business, we exchange PRIVATE keys to each other?

No. You should never share your PRIVATE key with anyone. What you do is exchange PUBLIC keys in such a way as to be certain that the public key came from the person in question. Usually email will work, although you could put the key on a floppy disk and trade them in person, if you wanted to be all cloak-and-dagger about it.

Then, when you want to encrypt a message to be sent to that person, you encrypt it with their PUBLIC key. The only thing that can decrypt the message will be their PRIVATE key. That’s the beauty of Asymmetric Encryption; You have two keys, and what is done with one key can only be undone by the other key.

So as long as you keep your private key secure, anyone with your PUBLIC key can verify that a message signed by your PRIVATE key is legit, since the PUBLIC key is the only thing that can verify data that has been signed or encrypted by the PRIVATE key. On the flip side, encrypting a file with someone’s PUBLIC key will ensure that only the holder of the PRIVATE key can decrypt it.

I should also mention the difference between encrypting and signing. Encrypting a message makes it unreadable to everyone except whoever has the mate to the key that did the encrypting. Signing, on the other hand, leaves the message intact and plainly visible to all, and simply appends a signature to the end of the message. Like encryption, this signature can only be verified by the mate of the key that did the signing.

Great info, thanks. I think I have it figured out now. :slight_smile:

However, note that signing and encrypting use the same algorithm. The differences between encrypting a message and signing it lie in what gets encrypted, which key is used for the encryption, and what gets sent to the recipient. When you want to send a private email, you use the recipient’s public key to encrypt the cleartext message, then send him only the encrypted message. When you just want to sign an email, you use your own private key to encrypt a hash of the message, then send him the cleartext message along with the encrypted hash.

In that sense, the OP was correct… almost. You could encrypt a message with your private key, and then anyone would be able to use your public key to decrypt it. It would serve the same purpose as signing the message. But typically, only a hash is encrypted; the recipient uses the sender’s public key to decrypt it, and verifies that it matches the calculated hash of the message (proving both that the sender had the right private key and that the message hasn’t been changed since it was sent).