![]() |
|
By ColonelZen, Section General Articles
An Overview of GPG
by T. W. Zellers GPG stands for Gnu Privacy Guard. It is a program from the FSF which allows you to encrypt and verify signed files created by others all without a shared secret which would allow others to impersonate you or get access to your encrypted files. I am by no means expert at GPG or encryption generally. But I have used it and PGP over the years and the question has come up, so I thought to share what knowledge I have. There are many sources on the web, starting of course with info gpg and The GNU Privacy Handbook, which explains it in much more detail than I can here. I definitely recommend reading through them if you need more than basic operation. The importance of privacy cannot be overstated. The word does not just connote things hidden, though that is a part of it, but things belonging exclusively to us as well. In other words, property. This forum exists to discuss "intellectual property", and encryption and particularly validation can be used to identify the original owner of a digital work as you can see in various software archives where the signature is stored with the package. Similarly DRM technologies, for good or ill, will be using many of the same features and techniques used in GPG and other encryption packages.
The purpose of encryption is to make something readable only to a select individual or group. The simplest ways of doing this are "codes" which basically mean that parts (possibly all of it in total) are transposed with other unique items. The most common example of this is the daily cryptogram in many newspapers though of course that is too simple and easily broken for practical use. Historically more common have been codebooks where particular words and phrases would be transposed with others and then back again to read the message. The weakness here is that if a lot of traffic is intercepted by a black hat and the topic of the messages discerned, soon he will have enough information to uncover the meaning of most of the codes, just as you can easily solve the daily cryptogram by looking for the most common letters until you see a pattern which lets you discover the rest. Worse, if the black-hat gets a copy of the encoded and decoded message he has *all* the code transubstitutions used in the message. The next step up and the basis for all modern encryption is called "ciphering". The idea here is that a reversible mathematical or symbolic technique is applied to a message to generate the encrypted message. The common feature about encryption ciphers is that they rely upon a unique key. For classical cyphers the key is the same for encrypting and decrypting the message. The most important feature of a good cypher is that even if black-hats intercept an encrypted message and it's decrypted version it should still be very difficult to impossible to discern the key used to encrypt it; that way having one message compromised does not lead to the likelihood that other encrypted messages will be exposed. The weakness of this scheme is that it depends upon a single key which both the sender and all recipients must share. If any one of the circle of trust reveals the key through misattention or ill intent, all future and any past intercepted encrypted messages are broken. Despite this weakness, single key (also known as symmetric key) ciphers have been and still are very prevalent. Today's Federal Encryption Standard is called AES and is such a system. It supersedes the earlier DES and triple-DES standards which have fallen out of favor mostly because with modern computer power it is now possible to crack DES. Wikipedia from which much of the background material for this article was pulled, has a lot of historical information for those interested. In the late 1970's MIT Mathematicians Rivest, Shamir and Adleman published a paper on a new ciphering technique supporting two (or more) independent keys. The scheme came to be known as RSA. The important thing about this technique is that the possessor of either key can decipher a message encrypted this way, and there is no way to discern the encrypting key. New algorithms have since been invented which work similarly. The more commonly known are Diffie-Hellman and ElGamal. In 1991 Philip Zimmerman released a program called Pretty Good Privacy or PGP. It used RSA to encrypt and decrypt messages and became quite famous. Mr. Zimmerman, in the mid 1990's lived through interesting times, courtesy of the U. S. Government. But despite publishing the source code for PGP and allowing free use, PGP was never an "open source" program by modern definitions. There were some variously open versions released by Mr. Zimmerman's commercial successors but the end result was that in 1999 the FSF released it's own completely free version of those programs, keeping a great deal of command compatibility as GPG, Gnu Privacy Guard. The uses of that program will be our concern for the rest of this article. The Software There are too many variations of installations for me to explain how to install gpg, but it is a largely stand-alone program without a lot of dependencies and should install easily. Very likely it came with your Linux distro. If all else fails, the source tarball can be retrieved and compiled from the source for all info on gpg, http://www.gnugp.org -- which is also where you should go to find something you don't see or don't understand here. My current version of gpg is 1.2.6; I understand 1.2.7 is out, but it hasn't come out for my distro yet. For purposes of our discussion we will consider our users adam, bill, and cindy. For demo purposes I have created the users on my machine with their own home directories, and a shared directory for the examples. In real life of course you would generally have your own directory where you would do things and messages would come from ftp, email, snarfed from a message board or wherever. Getting Started Now that you have gpg installed the first step is to generate your key. This is the key you will use for your communication. It is important. You will be asked for a pass phrase, which you must remember exactly in the future to access your key. But first you need a secret place to store your key information. You should, under your home directory make the ".gnupg" directory and give it permissions only for yourself (mkdir ~/.gnupg and chmod 700 .gnupg). It is possible to use an alternate directory for gpg configuration and databases by setting the environment variable GNUPGHOME. You can also change things such as using keyrings from elsewhere (e. g. a keyfob or portable disk drive) by setting options in the ${GNUPGHOME}/gpg.conf file. Once again info gpg is your friend, though the options can be overwhelming. The command to create a key is gpg --gen-key. This gives you a dialogue where you enter your information for this key (entered information is high-lighted:
Of course you wouldn't want to use my passphrase or anything so obvious; you want something you can remember exactly but would be unlikely for anyone else to guess. It should be pointed out that this passphrase has nothing to do with encrypting messages directly, but rather the key you just generated is encrypted in your keyring with that passphrase and you will be prompted for it when you do anything which requires it. In other words it makes it impossible for someone to steal your key just by having access to your files. Think of your pass phrase as a lock on your key itself. It is *still* best to protect your keyring and the .gnupg directory with every possible measure. Managing Keys Now the whole point of gpg and encryption is communication. So you need a way to save other people's keys. Well naturally gpg has that handled. So if our friend Adam, has been sent Bill's public key, he just types gpg --import bill-pubkey.txt and sees:
gpg: key 2DCA8230: public key "bill blather (bill) <bill@localhost.com>" imported gpg: Total number processed: 1 gpg: imported: 1 bash-2.05b$ Now of course there may be other people Adam wants to talk to, so he needs to get their public keys. Lot's of places like IPW have places in their user information for users to save their public keys. Another place is on public keyservers which allow people to save their public keys so that others may find them. So our friend adam goes to http://wwwkeys.pgp.net and looks for this guy, tzellers, whom he wants to give a piece of his mind. After typing in "tzellers" in the search box he gets:
And clicking on the key ID (9A0C3602) he get's the public key on a page which he cuts and pastes into an editor, from the ----BEGIN PGP PUBLIC KEY BLOCK----- through the -----END PGP PUBLIC KEY BLOCK----- and saves as tzellers-pubkey.txt, which he then imports. Now of course he realizes he may want others to be able to use gpg to communicate with him, or to verify his messages, so he needs a way to pull his key out of his keyring. This is fairly obvious, the option is --export, but there is a catch: most of the operations in gpg produce binary files but having anticipated this maker's of these programs provided a way to armor the outputs into purely text characters so that they can be passed through programs such as email and web browsers (well, back then it was bulletin boards) which would have a problem with non-ascii characters. The solution is to use the --armor or -a flags to produce pure ascii output which is nonetheless read just as the binaries are. Similarly most output operations will go to the console output which you can capture with shell redirection, but there is also an -o option which will redirect things.... So now Adam wants to list the keys he has: bash-2.05b$ gpg --list-keys /home/adam/.gnupg/pubring.gpg ----------------------------- pub 1024D/2D118A8E 2005-01-09 Adam Atavist (This is Adam) <adam@localhost.com> sub 1024g/4B08D37B 2005-01-09 pub 1024D/2DCA8230 2005-01-10 bill blather (bill) <bill@localhost.com> sub 1024g/11AD3215 2005-01-10 pub 1024D/9A0C3602 2002-11-19 Terrence W. Zellers (updated email) <tzellers@pobox.com> uid Terrence W. Zellers (Me at verizon) <terrence.zellers@verizon.net> uid Terrence W. Zellers <terrence.w.zellers@pobox.com> sub 2048g/AC3825A4 2002-11-19 bash-2.05b$ Now to export, in text mode his own key he would type gpg --export --armor -o adam-pubkey.txt adam and his public key is written to adam-pubkey.txt. This can be verified simply by feeding the file back into gpg: bash-2.05b$ gpg < adam-pubkey.txt pub 1024D/2D118A8E 2005-01-09 Adam Atavist (This is Adam) <adam@localhost.com> sub 1024g/4B08D37B 2005-01-09 bash-2.05b$ As opposed to a file with no valid gpg data: bash-2.05b$ gpg < junk gpg: no valid OpenPGP data found. gpg: processing message failed: eof bash-2.05b$ Now of course exporting bill's or that annoying tzellers guy's key would be as simple as substituting any distinctive part of their id into the export command. gpg will either stop when it finds the first valid matching part in an id or, more often depending on the operation, pull all matching ids from the keyrings; it is not necessary to type in (as you could, in quotes) "bill blather (bill) <bill@localhost.com>" if "bill" is sufficiently distinctive. In this case if you had typed "ll", then the bill and tzellers keys would be exported. If no particular user id is found, the entire keyring, all public signatures will be exported. Once he has a good signature file with only his own public signature, he may wish to save it in his user info at his favorite web site, publish it to lists he frequents or save it to a keyserver so others can find it. Now there is one more basic thing about signatures. You can "sign" a signature in your keyring to denote the level of trust you have in it. In our example we assume Adam knows for sure that the signature came from Bill. For the rest of these examples we'll just presume that people are lazy; in most instances it won't matter, but if you are really involved in something which requires security these kinds of things will matter. So Adam signs Bill's key (the passphrase would be hidden)....
Actually using GPG Now we get to the meat of the matter, actually using gpg. So Adam writes something for Bill's eyes only. The "e" in "-ear" means encrypt and could have been --encrypt; the "a" means --armor or to make the output ascii; r means recipient or --recipient, as in this is going to bill. If you leave off the recipient flag gpg will prompt you for the recipient and you can specify multiple recipients as it will continue to prompt until you enter a blank line; in such case gpg will build a merged key and each recipient will be able to independently decipher the message. In these examples /tgpg is just the test directory that everyone can read and write; in practice the files may have been sent by email, left on a server or transmitted by other medium. Note that the ascii armoring is not required if the medium can handle binaries. (No passphrase required here because gpg saved that from prior in the session). bash-2.05b$ gpg -ear bill -o /tgpg/adam2bill.txt.gpg adam2bill.txt gpg: checking the trustdb gpg: checking at depth 0 signed=1 ot(-/q/n/m/f/u)=0/0/0/0/0/1 gpg: checking at depth 1 signed=0 ot(-/q/n/m/f/u)=1/0/0/0/0/0 bash-2.05b$ And the resulting file is totally unintelligible ... bash-2.05b$ cat /tgpg/adam2bill.txt.gpg -----BEGIN PGP MESSAGE----- Version: GnuPG v1.2.6 (GNU/Linux) hQEOAxqSnTkRrTIVEAQAoAF1qduJ5JOajqD7FbOdZJMayJBOJG7vKQ37QQs80nZ3 zSBSRsq/9wkgRcMdHpSSsnApJuv/wmVteQCDYygM7XuwKKcvZJoKfjAFAUPswvvI GgkJtwe2d3chWfwvZSlYE4prO3Mn7pum7E5T5OJYBtJwClNi50v6Q6MuY8ALQo0D /2cO3ynoV3q9D9uV4QJBUTulYWm+ei8Dv5eTfNsGm9U3z52xK4YtrJjRSwoiYTVe YDYlZkjIWDn7FRIi/XE7ns7ShM60oL6F9NCh83ay2J54IlwDfARldyTS3ZoDBd2H h/T4N/av+0ZqlhLQJq8y6D+BqmZQWUBN0TDQJdiGkKqp0okBlgSU7rs7V6kH7oC8 mKu0ZQQ+2iDVrBBmH3/TRxtxaa5mwzEQ2Q35bxLoxGsfkNBLZESy8QITmk4Edf2O dqQGsRLrWyk01rg78/d0rzhAnkk65fRjKQr3G3Nl3sS6tIkUS/Rt31P0gfyp9dw7 QiZrXLIA+NzpopjnaZWgaILdv00ehcuqY65Yvw== =RkDA -----END PGP MESSAGE----- bash-2.05b$ Now Cindy is curious, she sees that file out there so just for kicks she tries to read it and gets nowhere ...
But Bill can read the message:
And Bill replies, but not having signed Adam's key, the dialog is just a little different:
Which of course Adam has no problem reading and sadly agrees with:
Meanwhile Cindy has a message of her own to write. She leaves it on the bulletin board at the local Starbuck's and want's anyone who reads it to be sure it came from her. In other words she wants to sign the message. bash-2.05b$ gpg --clearsign -o /tgpg/cindy.txt.gpg cindy.txt You need a passphrase to unlock the secret key for user: "Cindy <cindy@localhost.com>" 1024-bit DSA key, ID ADEC7F08, created 2005-01-10 Enter passphrase: cindy's passphrase bash-2.05b$ Which of course our heroes will have no trouble verifying once they import Cindy's key: bash-2.05b$ gpg < /tgpg/cindy.txt.gpg Hey I'm lonely, frustrated and horny. They guys around here are a bunch of dorks! I tried the come-hither with a couple of local techs named Adam and Bill but they're both just interested in whether PJ misspelled incontrovertible in her last article, whatever that's about. I'm really looking for someone who can help me figure out how to get ssh and apache working on my home computer and maybe explain this object-oriented programming stuff. Then we can try some more personal orienting before bedtime. I love it when a guy mumbles about parsers in his sleep! -- Sinful Cindy gpg: Signature made Sun Jan 9 23:34:55 2005 EST using DSA key ID ADEC7F08 gpg: Good signature from "Cindy <cindy@localhost.com>" gpg: checking the trustdb gpg: checking at depth 0 signed=1 ot(-/q/n/m/f/u)=0/0/0/0/0/1 gpg: checking at depth 1 signed=0 ot(-/q/n/m/f/u)=1/0/0/0/0/0 gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 599B AAC0 B39D A9D4 4490 6490 14C7 C492 ADEC 7F08 bash-2.05b$ Of course as left on the bulletin board it was quite readable to their dismay: bash-2.05b$ cat /tgpg/cindy.txt.gpg -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey I'm lonely, frustrated and horny. They guys around here are a bunch of dorks! I tried the come-hither with a couple of local techs named Adam and Bill but they're both just interested in whether PJ misspelled incontrovertible in her last article, whatever that's about. I'm really looking for someone who can help me figure out how to get ssh and apache working on my home computer and maybe explain this object-oriented programming stuff. Then we can try some more personal orienting before bedtime. I love it when a guy mumbles about parsers in his sleep! - -- Sinful Cindy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQFB4gXvFMfEkq3sfwgRAs/UAKC7mUzjhbvXw+KMsh7PVAaEQht1awCgrL8m Xd5b3+z1nVSM98+1wkNeY34= =zyZ9 -----END PGP SIGNATURE----- bash-2.05b$ Conclusion There is, of course, a great deal more to GPG. I've barely touched upon the deeper uses. There are also some graphical front ends for both dealing with signed and encrypted files and managing the keys. Likewise many modern mailers have interfaces to gpg built in so that signed or encrypted email can be dealt with automatically. In evolution, for instance, signing outgoing email is simply clicking a checkbox in the user's security setting (and answering the passphrase question when sending mail). But hopefully this has given you enough information to pursue it further if you so desire.
----------------------------------------------
An Overview of GPG | 26 comments (18 topical, 8 editorial, 6 hidden)
An Overview of GPG | 26 comments (18 topical, 8 editorial, 6 hidden)
|
Links![]()
~ Merkey v The Internet et al Docs Recent CommentsBreaking News and External Article CommentsGeneral News by ColonelZen, January 5 60 comments
» SCO Lifeboat List from Stats_for_all
» Not a single comment on the Novell...
» Re: Not a single comment on the Novell...
Eagle Loses Appeals General News by JCausey, December 15 1 comment
» Re: Eagle Loses Appeals
The Chinese Room Revisited, Thoughts on... General News by ColonelZen, November 24 1 comment
» Re: The Chinese Room Revisited,...
How to Transition a Windows Shop to Linux General News by JCausey, November 21 3 comments
» Re: How to Transition a Windows Shop to...
» Re: How to Transition a Windows Shop to...
» Re: How to Transition a Windows Shop to...
Advocacy General News by br3n, October 29 3 comments
» Re: Advocacy
» Re: Advocacy
» Re: Advocacy
Very Bad News for Darl and Ralph SCO v The World by ColonelZen, October 13 7 comments
» Re: OT advocacy
» Re: OT advocacy
» Re: OT advocacy
Some SCOX Financial Analysis SCO v The World by JCausey, September 21 13 comments
» Re: Some SCOX Financial Analysis
» Re: Some SCOX Financial Analysis
» Re: Some SCOX Financial Analysis
Open Source in Education - Opening Doors General News by JCausey, September 28 1 comment
» Re: Open Source in Education - Opening...
An IPOWER ful experience General News by ColonelZen, September 25 6 comments
» IPOWER SysAdmin Doesn't Do Weekends!!
» Re: An IPOWER ful experience
» Re: An IPOWER ful experience
Learning C# Microsoft by ColonelZen, September 23 1 comment
» Re: Learning C#
Comment search... Recent DiariesSCO has a Potential and Credible BILLION Dollar Liabilityby ColonelZen - March 15 The Chinese Room Revisited, Thoughts on Consciousness by ColonelZen - November 24 1 comment Advocacy by br3n - October 29 3 comments An IPOWER ful experience by ColonelZen - September 25 6 comments Learning C# by ColonelZen - September 23 1 comment Getting ruby DBI for Mysql and Postgresql working on FC 6 by ColonelZen - March 7 Declaration of Linus Torvalds by nedu - February 13 1 comment Declaration of M. Douglas McIlroy by nedu - February 12 6 comments Declaration of Ulrich Drepper by nedu - February 11 1 comment Declaration of K. Y. Srinivasan by nedu - February 11 More Diaries... Older Stories
Monday May 28th
Thursday April 5th
Monday March 12th
Tuesday March 6th
Monday January 15th
|