gpg crypto from gnu manual

gpg crypto from gnu manual - The GNU Privacy Handbook The...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The GNU Privacy Handbook The GNU Privacy Handbook Copyright © 1999 by The Free Software Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no FrontCover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please direct questions, bug reports, or suggestions concerning this manual to the maintainer, Mike Ashley (<[email protected]>). When referring to the manual please specify which version of the manual you have by using this version string: $Name: v1_1 $. Contributors to this manual include Matthew Copeland, Joergen Grahn, and David A. Wheeler. J Horacio MG has translated the manual to Spanish. Table of Contents 1. Getting Started ................................................................................................................................................ 6 Generating a new keypair ............................................................................................................................ 6 Generating a revocation certificate .................................................................................................... 8 Exchanging keys ......................................................................................................................................... 8 Exporting a public key ....................................................................................................................... 8 Importing a public key ....................................................................................................................... 9 Encrypting and decrypting documents ...................................................................................................... 10 Making and verifying signatures ............................................................................................................... 11 Clearsigned documents .................................................................................................................... 12 Detached signatures ......................................................................................................................... 12 2. Concepts......................................................................................................................................................... 14 Symmetric ciphers..................................................................................................................................... 14 Public-key ciphers ..................................................................................................................................... 14 Hybrid ciphers ........................................................................................................................................... 15 Digital signatures ...................................................................................................................................... 16 3. Key Management .......................................................................................................................................... 18 Managing your own keypair ..................................................................................................................... 18 Key integrity .................................................................................................................................... 19 Adding and deleting key components ............................................................................................. 20 Revoking key components ............................................................................................................... 20 Updating a key’s expiration time ..................................................................................................... 22 Validating other keys on your public keyring ........................................................................................... 22 Trust in a key’s owner ...................................................................................................................... 23 Using trust to validate keys.............................................................................................................. 24 Distributing keys ....................................................................................................................................... 26 4. Daily use of GnuPG ...................................................................................................................................... 28 Defining your security needs..................................................................................................................... 28 Choosing a key size ......................................................................................................................... 28 Protecting your private key .............................................................................................................. 29 Selecting expiration dates and using subkeys.................................................................................. 30 Managing your web of trust ............................................................................................................ 30 Building your web of trust ........................................................................................................................ 31 Using GnuPG legally ................................................................................................................................ 32 5. Topics ............................................................................................................................................................. 33 Writing user interfaces .............................................................................................................................. 33 A. GNU Free Documentation License ............................................................................................................. 35 0. PREAMBLE ......................................................................................................................................... 35 1. APPLICABILITY AND DEFINITIONS ............................................................................................. 35 3 2. VERBATIM COPYING ........................................................................................................................ 36 3. COPYING IN QUANTITY .................................................................................................................. 36 4. MODIFICATIONS................................................................................................................................ 37 5. COMBINING DOCUMENTS .............................................................................................................. 38 6. COLLECTIONS OF DOCUMENTS ................................................................................................... 38 7. AGGREGATION WITH INDEPENDENT WORKS........................................................................... 38 8. TRANSLATION ................................................................................................................................... 39 9. TERMINATION.................................................................................................................................... 39 10. FUTURE REVISIONS OF THIS LICENSE ...................................................................................... 39 How to use this License for your documents ............................................................................................ 39 4 List of Figures 3-1. A hypothetical web of trust ......................................................................................................................... 25 5 Chapter 1. Getting Started GnuPG is a tool for secure communication. This chapter is a quick-start guide that covers the core functionality of GnuPG. This includes keypair creation, exchanging and verifying keys, encrypting and decrypting documents, and authenticating documents with digital signatures. It does not explain in detail the concepts behind public-key cryptography, encryption, and digital signatures. This is covered in Chapter 2. It also does not explain how to use GnuPG wisely. This is covered in Chapters 3 and 4. GnuPG uses public-key cryptography so that users may communicate securely. In a public-key system, each user has a pair of keys consisting of a private key and a public key. A user’s private key is kept secret; it need never be revealed. The public key may be given to anyone with whom the user wants to communicate. GnuPG uses a somewhat more sophisticated scheme in which a user has a primary keypair and then zero or more additional subordinate keypairs. The primary and subordinate keypairs are bundled to facilitate key management and the bundle can often be considered simply as one keypair. Generating a new keypair The command-line option -gen-key is used to create a new primary keypair. alice% gpg EgenEkey gpg (GnuPG) 0.9.4; Copyright (C) 1999 Free Software Foundation, Inc. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the file COPYING for details. Please select what kind of key you want: (1) DSA and ElGamal (default) (2) DSA (sign only) (4) ElGamal (sign and encrypt) Your selection? GnuPG is able to create several different types of keypairs, but a primary key must be capable of making signatures. There are therefore only three options. Option 1 actually creates two keypairs. A DSA keypair is the primary keypair usable only for making signatures. An ElGamal subordinate keypair is also created for encryption. Option 2 is similar but creates only a DSA keypair. Option 41 creates a single ElGamal keypair usable for both making signatures and performing encryption. In all cases it is possible to later add additional subkeys for encryption and signing. For most users the default option is fine. You must also choose a key size. The size of a DSA key must be between 512 and 1024 bits, and an ElGamal key may be of any size. GnuPG, however, requires that keys be no smaller than 768 bits. Therefore, if Option 1 was chosen and you choose a keysize larger than 1024 bits, the ElGamal key will have the requested size, but the DSA key will be 1024 bits. 1. Option 3 is to generate an ElGamal keypair that is not usable for making signatures. 6 Chapter 1. Getting Started About to generate a new ELG-E keypair. minimum keysize is 768 bits default keysize is 1024 bits highest suggested keysize is 2048 bits What keysize do you want? (1024) The longer the key the more secure it is against brute-force attacks, but for almost all purposes the default keysize is adequate since it would be cheaper to circumvent the encryption than try to break it. Also, encryption and decryption will be slower as the key size is increased, and a larger keysize may affect signature length. Once selected, the keysize can never be changed. Finally, you must choose an expiration date. If Option 1 was chosen, the expiration date will be used for both the ElGamal and DSA keypairs. Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) For most users a key that does not expire is adequate. The expiration time should be chosen with care, however, since although it is possible to change the expiration date after the key is created, it may be difficult to communicate a change to users who have your public key. You must provide a user ID in addition to the key parameters. The user ID is used to associate the key being created with a real person. You need a User-ID to identify your key; the software constructs the user id from Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <[email protected]>" Real name: Only one user ID is created when a key is created, but it is possible to create additional user IDs if you want to use the key in two or more contexts, e.g., as an employee at work and a political activist on the side. A user ID should be created carefully since it cannot be edited after it is created. GnuPG needs a passphrase to protect the primary and subordinate private keys that you keep in your possession. You need a Passphrase to protect your private key. Enter passphrase: There is no limit on the length of a passphrase, and it should be carefully chosen. From the perspective of security, the passphrase to unlock the private key is one of the weakest points in GnuPG (and other public-key encryption systems as well) since it is the only protection you have if another individual gets your private key. Ideally, the passphrase should not use words from a dictionary and should mix the case of alphabetic characters as well as use non-alphabetic characters. A good passphrase is crucial to the secure use of GnuPG. 7 Chapter 1. Getting Started Generating a revocation certificate After your keypair is created you should immediately generate a revocation certificate for the primary public key using the option -gen-revoke. If you forget your passphrase or if your private key is compromised or lost, this revocation certificate may be published to notify others that the public key should no longer be used. A revoked public key can still be used to verify signatures made by you in the past, but it cannot be used to encrypt future messages to you. It also does not affect your ability to decrypt messages sent to you in the past if you still do have access to the private key. alice% gpg Eoutput revokeF—s™ EgenErevoke mykey [...] The argument mykey must be a key specifier, either the key ID of your primary keypair or any part of a user ID that identifies your keypair. The generated certificate will be left in the file revoke.asc. If the -output option is omitted, the result will be placed on standard output. Since the certificate is short, you may wish to print a hardcopy of the certificate to store somewhere safe such as your safe deposit box. The certificate should not be stored where others can access it since anybody can publish the revocation certificate and render the corresponding public key useless. Exchanging keys To communicate with others you must exchange public keys. To list the keys on your public keyring use the command-line option -list-keys. alice% gpg ElistEkeys /users/alice/.gnupg/pubring.gpg -------------------------pub 1024D/BB7576AC 1999-06-04 Alice (Judge) <[email protected]> sub 1024g/78E9A8FA 1999-06-04 Exporting a public key To send your public key to a correspondent you must first export it. The command-line option -export is used to do this. It takes an additional argument identifying the public key to export. As with the -gen-revoke option, either the key ID or any part of the user ID may be used to identify the key to export. alice% gpg Eoutput —li™eFgpg Eexport —li™ed™y˜Forg The key is exported in a binary format, but this can be inconvenient when the key is to be sent though email or published on a web page. GnuPG therefore supports a command-line option -armor2 that causes output to be 2. Many command-line options that are frequently used can also be set in a configuration file. 8 Chapter 1. Getting Started generated in an ASCII-armored format similar to uuencoded documents. In general, any output from GnuPG, e.g., keys, encrypted documents, and signatures, can be ASCII-armored by adding the -armor option. alice% gpg E—rmor Eexport —li™ed™y˜Forg ---BEGIN PGP PUBLIC KEY BLOCK--Version: GnuPG v0.9.7 (GNU/Linux) Comment: For info see http://www.gnupg.org [...] ---END PGP PUBLIC KEY BLOCK--- Importing a public key A public key may be added to your public keyring with the -import option. alice% gpg Eimport ˜l—keFgpg gpg: key 9E98BC16: public key imported gpg: Total number processed: 1 gpg: imported: 1 alice% gpg ElistEkeys /users/alice/.gnupg/pubring.gpg -------------------------pub 1024D/BB7576AC 1999-06-04 Alice (Judge) <[email protected]> sub 1024g/78E9A8FA 1999-06-04 pub sub 1024D/9E98BC16 1999-06-04 Blake (Executioner) <[email protected]> 1024g/5C8CBD41 1999-06-04 Once a key is imported it should be validated. GnuPG uses a powerful and flexible trust model that does not require you to personally validate each key you import. Some keys may need to be personally validated, however. A key is validated by verifying the key’s fingerprint and then signing the key to certify it as a valid key. A key’s fingerprint can be quickly viewed with the -fingerprint command-line option, but in order to certify the key you must edit it. alice% gpg EeditEkey ˜l—ked™y˜Forg trust: -/q pub sub (1) 1024D/9E98BC16 created: 1999-06-04 expires: never 1024g/5C8CBD41 created: 1999-06-04 expires: never Blake (Executioner) <[email protected]> Command> fpr pub 1024D/9E98BC16 1999-06-04 Blake (Executioner) <[email protected]> Fingerprint: 268F 448F CCD7 AF34 183E 52D8 9BDE 1A08 9E98 BC16 A key’s fingerprint is verified with the key’s owner. This may be done in person or over the phone or through any other means as long as you can guarantee that you are communicating with the key’s true owner. If the fingerprint you get is the same as the fingerprint the key’s owner gets, then you can be sure that you have a correct copy of the key. 9 Chapter 1. Getting Started After checking the fingerprint, you may sign the key to validate it. Since key verification is a weak point in public-key cryptography, you should be extremely careful and always check a key’s fingerprint with the owner before signing the key. Command> sign pub 1024D/9E98BC16 created: 1999-06-04 expires: never trust: -/q Fingerprint: 268F 448F CCD7 AF34 183E 52D8 9BDE 1A08 9E98 BC16 Blake (Executioner) <[email protected]> Are you really sure that you want to sign this key with your key: "Alice (Judge) <[email protected]>" Really sign? Once signed you can check the key to list the signatures on it and see the signature that you have added. Every user ID on the key will have one or more self-signatures as well as a signature for each user that has validated the key. Command> ™he™k uid Blake (Executioner) <[email protected]> sig! 9E98BC16 1999-06-04 [self-signature] sig! BB7576AC 1999-06-04 Alice (Judge) <[email protected]> Encrypting and decrypting documents A public and private key each have a specific role when encrypting and decrypting documents. A public key may be thought of as an open safe. When a correspondent encrypts a document using a public key, that document is put in the safe, the safe shut, and the combination lock spun several times. The corresponding private key is the combination that can reopen the safe and retrieve the document. In other words, only the person who holds the private key can recover a document encrypted using the associated public key. The procedure for encrypting and decrypting documents is straightforward with this mental model. If you want to encrypt a message to Alice, you encrypt it using Alice’s public key, and she decrypts it with her private key. If Alice wants to send you a message, she encrypts it using your public key, and you decrypt it with your private key. To encrypt a document the option -encrypt is used. You must have the public keys of the intended recipients. The software expects the name of the document to encrypt as input; if omitted, it reads standard input. The encrypted result is placed on standard output or as specified using the option -output. The document is com...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern