Viewable With ANY Browser

Note: My Web pages are best viewed with style sheets enabled.


PGP: Key Encryption

Copyright © 1998-2001, 2003, 2005, 2006, 2008, 2011 by David E. Ross

Why Encrypt?

Single-Key Encryption

Public Key/Private Key Encryption

Combining Single-Key and Public Key/Private Key Encryption

Basic Principles

If you seek details on the mechanics of PGP and the encryption algorithms it uses, this is not the place. There are many excellent sources of that information elsewhere on-line. Here, however, you will find some understanding of the PGP terminology.

Nothing sinister should be inferred when someone wants to keep personal data and private communications secret. Like sealing a personal letter into an envelope for postal mail or locking a checkbook into a desk drawer, PGP encryption seals E-mail and keeps files safe. Of course, if proper care is taken when using PGP, it is far stronger than any envelope or desk drawer.

Someone who read this page wrote to me, suggesting that all messages and files should be encrypted, thereby confusing any snoop by hiding important data among trivial data. This concept was used by Edgar Allen Poe in his The Purloined Letter. To me, this would be more bother than it is worth. Since I am not a drug dealer, pornographer, terrorist, spy, or otherwise committing a felony, I do not really need to hide my important data. Encryption is sufficient. The effort and cost for others to decrypt my encrypted files exceed the value of the data I have secured.

That same writer expressed concern that the mere use of encryption could be dangerous. "A corrupt or corrupted regime will use your use of encryption as de facto evidence of criminal/treasonous behavior." This is indeed valid. In some nations, the mere use of encryption may be a crime, although that cannot be confirmed. He then argues that more widespread and routine use of encryption would temper such suspicions.

Why Encrypt?

If you listen to the police and FBI, you would believe that only unsavory individuals such as drug dealers, pornographers, terrorists, and spies use PGP to encrypt their E-mail and computer files. However, ordinary individuals might want to use PGP, too. graphic with envelope and key

Of course, a little thought would add more entries to this list. If such information were hardcopy on paper, it would be in a filing cabinet with a lock or even in a safe. PGP encryption provides an electronic safe where this information can still reside on a computer or even in a company's computer network, where access remains convenient.

Single-Key Encryption

envelope with a lock If you take an arbitrary large number (or a string of characters and treat it as a number) and use it as input to a mathematical operation on some target data (also treated as a number) to scramble the latter, the former is an encryption key. Treating even text data as a number is easy if you consider that all characters are represented inside a computer as numbers. (See my Escaped Characters.) For example, a string of 100 characters (the key) can be converted to a number and added to the target data after it too is converted into a number. If the target data contains more than 100 characters, the process can be repeated with the same key over groups of 100 characters. This is a very simple form of encryption. Decryption could use the same key; the operation would merely be subtraction instead of addition. Since the same key is used for both encryption and decryption, this is a symmetric method. Obviously, you must keep the key confidential, sharing it in some safe manner only with the person who exchanges encrypted messages with you.

Public Key/Private Key Encryption

Use of public and private keys, showing the progression from plain text to encrypted and back to plain text PGP is an asymmetric (not symmetric) method. It uses one key (the public key) to encrypt the target data, using a mathematical operation far more complicated than merely adding the two together. A different key (the private key) is used by a different mathematical operation to decrypt the target data. There is no practical mathematical operation that can take the public encryption key and use it for decryption. (While the operation to use a public key to decrypt is known, its practical use within a person's lifetime would require more computer power than exists today.) Thus, you do not need a safe method of sharing a key with someone who exchanges encrypted messages with you. Instead, you send that other person your public key for him to use when he sends an encrypted message to you. You do not care who else sees that public key because no one can use it to decrypt the messages. You then use your private key (which you do not share with anyone) to decrypt the messages. Likewise, that other person sends you his public key for you to use when you send him a message. From this, we get the term public key/private key encryption.

Note that you really need only one pair of keys. Everyone can use your public key to encrypt data to send to you. You do not need a separate key for each individual. No one can decrypt those data — not those who have your public key, not even the person who used your public key to encrypt the data. Only your private key can be used to decrypt data that were encrypted with your public key. Further, PGP requires a passphrase when using your private key. A passphrase is a long password that can contain blanks and punctuation; some individuals use complete sentences for their passphrases. Your private key is itself symmetrically encrypted when stored on your computer, and your passphrase is the key used to encrypt and decrypt it.

Because your public key cannot be used to decrypt a file intended for you, you really do not care who has your public key. Not only your friends but also your enemies can have your public key. Your wife can have the same public key as your girlfriend. You really do not care if both the police and the criminals have your public key. On the other hand, you must carefully guard your private key, which is used to decrypt what your public key has encrypted. You must also separately guard your passphrase in case your private key is compromised.

Remember: You need the other person's public key to encrypt a message to him. He needs your public key to encrypt a message to you. You both need PGP or a PGP-compatible application.

Combining Single-Key and Public Key/Private Key Encryption

Actually, PGP uses a combination of symmetric and asymmetric encryption. Asymmetric encryption is relatively slow and, for a truly secure result, requires a pair of excessively long keys. Instead, each time PGP is used, it generates a new symmetric key — the session key — which it uses to encrypt the target data using a very secure symmetric method. Message Encrypted for Two Different Individuals, showing how a single session key encrypts a message and is then appended to the message twice after being encrypted to two different public keys To avoid the obvious weakness inherent in using symmetric keys, PGP then uses an asymmetric method with the intended recipient's public key to encrypt the session key, which PGP appends to the already encrypted target data. The recipient then uses PGP and her private key to decrypt the session key, which PGP then uses to decrypt the rest of the data. The session key (as its name implies) is used only for this one encryption session and is then discarded. It is never exposed by PGP at either end of the process. To the user, this is still asymmetric public key/private key encryption and it still defies attempts to break the results.

The combination of symmetric (two-way) session keys and asymmetric private-keys/public-keys means the same file or message can be encrypted for more than one recipient without requiring a separate resulting file for each. Instead, the file is encrypted with a session key. Then, the session key is repeatedly encrypted with each recipient's public key, each result separately appended to the encrypted file. The same file with appended session keys — all encrypted — can then be distributed to all the intended recipients. A recipient's PGP can determine which encryption of the session key (if any) used that recipient's public key. Thus, the session key can be decrypted in order to use it to decrypt the file. Anyone who receives the encrypted file but who does not have a private key corresponding to any of the appended encrypted session keys cannot decrypt the file.

The ability to encrypt a file or message with more than one public key has led to the Additional Decryption Key (ADK) capability in PGP. This capability not only provides a feature needed for business use of PGP, but it also creates a security problem.

While the diagram above on the left is conceptually correct, it is technically backwards. The two instances of the encrypted session key are actually appended before the encrypted message.

Basic Principles

Confusion afflicts many new users of PGP regarding which key to use and when to use it.

Every point above also applies to encrypting and decrypting files, not just to messages.

Last updated 25 January 2011

Note: The copyright on this page extends to the uncaptioned graphic showing encryption and decryption and to the graphic captioned Message Encrypted for Two Different Individuals. Both are © 2001.

Valid HTML 4.01