public and secret key created and signed.
Now I will explain about the various inputs asked during the generation of the keypairs.
- Please select what kind of key you want:
(1) DSA and ElGamal (default) (2) DSA (sign only) (4) ElGamal (sign and encrypt)
GnuPG is capable of creating different kind of keypairs. There are three options. 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
4 creates a single ElGamal keypair usable for both making signatures and performing encryption. 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.
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)
There are advantages and disadvantages of choosing a longer key. The advantages are: 1) The longer the key the more secure it is against brute-force attacks
The disadvantages are: 1) encryption and decryption will be slower as the key size is increased 2) a larger keysize may affect signature length
The default keysize is adequate for almost all purpose and the keysize can never be changed after selection.
- 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
= key expires in n days w = key expires in n weeks m = key expires in n months 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:
« Kapil Sharma (Linux consultant) «
Real name: Enter you name here
Email address: Enter you email address
Comment: Enter any comment here
- 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 secret key.
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.
2: 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.
[root@dragon /]# gpg –output revoke.asc –gen-revoke mykey
Here 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. 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.
3: Listing Keys
To list the keys on your public keyring use the command-line option –list-keys.
[root@dragon /]# gpg –list-keys /root/.gnupg/pubring.gpg ———————— pub 1024D/020C9884 2000-11-09 Kapil Sharma (Unix/Linux consultant)
sub 2048g/555286CA 2000-11-09
4: Exporting a public key
You can export your public key to use it on your homepage or on a available key server on the Internet or any other method. 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.
- To export your public key in binary format, use the following command:
- To export your public key in ASCII armored output, use the following command:
- To export your public key in ASCII armored output and to view it , use the following command:
[root@dragon /]# gpg –output kapil.gpg –export firstname.lastname@example.org
[root@dragon /]# gpg –export-armor> kapil-key.asc
Here « –export » is for extracting your Public-key from your pubring encrypted file , « -armor » is to create ASCII armored output that you can mail, publish it on a web page and « > kapil-key.asc » is to put the result in a file.
[root@dragon /]# gpg –export-armor —–BEGIN PGP PUBLIC KEY BLOCK—– Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org
[…] —–END PGP PUBLIC KEY BLOCK—–
5: Importing a public key
Once your own keypair is created, you can put it into your public keyring database of all keys from trusted third party in order to be able to use the keys for future encryption and authentication communication. A public key may be added to your public keyring with the –import option.
[root@dragon /]# gpg –import Here « filename » is the name of the exported public key. For example: [root@dragon /]# gpg –import mandrake.asc gpg: key :9B4A4024: public key imported gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: Total number processed: 1
gpg: imported: 1
In the above example we imported the Public key file « mandrake.asc » from the company Mandrake Linux, downloadable from Mandrake Internet site, into our keyring.
6: Validating the key Once a key is imported it should be validated. 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. [root@dragon /]# gpg –fingerprint As a example: [root@dragon /]# gpg –fingerprint mandrake pub 1024D/9B4A4024 2000-01-06 MandrakeSoft (MandrakeSoft official keys) Key fingerprint = 63A2 8CBD A7A8 387E 1A53 2C1E 59E7 0DEE 9B4A 4024
sub 1024g/686FF394 2000-01-06
In the above example we verified the fingerprint of mandrake. 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.
7: Key Signing After importing and verifying the keys that you have imported into your public database, you can start signing them. Signing a key certifies that you know the owner of the keys. You should only sign the keys when you are 100% sure of the authentication of the key.
- To sign a key for the company Mandrake that we have added on our keyring above, use the following command:
[root@dragon /]# gpg –sign-key As an example: [root@dragon /]# gpg –sign-key pub 1024D/9B4A4024 created: 2000-01-06 expires: never trust: -/q sub 1024g/686FF394 created: 2000-01-06 expires: never (1) MandrakeSoft (MandrakeSoft official keys)
pub 1024D/9B4A4024 created: 2000-01-06 expires: never trust: -/q
Fingerprint: 63A2 8CBD A7A8 387E 1A53 2C1E 59E7 0DEE 9B4A 4024
MandrakeSoft (MandrakeSoft official keys)
Are you really sure that you want to sign this key
with your key: « Kapil Sharma (Unix/Linux consultant) «
Really sign? y
You need a passphrase to unlock the secret key for user: « Kapil Sharma (Unix/Linux consultant) «
1024-bit DSA key, ID 020C9884, created 2000-11-09
8: Checking Signatures 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. We can check the signatures of the keys by the gpg option « –check-sigs: As an example: [root@dragon /]# gpg –check-sigs mandrake pub 1024D/9B4A4024 2000-01-06 MandrakeSoft (MandrakeSoft official keys) sig! 9B4A4024 2000-01-06 MandrakeSoft (MandrakeSoft official keys) sig! 020C9884 2000-11-09 Kapil Sharma (Unix/Linux consultant) sub 1024g/686FF394 2000-01-06
sig! 9B4A4024 2000-01-06 MandrakeSoft (MandrakeSoft official keys)
9: Encrypting and decrypting The procedure for encrypting and decrypting documents is very simple. If you want to encrypt a message to mandrake, you encrypt it using mandrake public key, and then only mandrake can
decrypt that file with his private key. If Mandrake wants to send you a message, it encrypts it using your public key, and you decrypt it with your private key.
To encrypt and sign data for the user Mandrake that we have added on our keyring use the following command (You must have a public key of the recipient):
[root@dragon /]# gpg -sear
As an example: [root@dragon /]# gpg -sear Mandrake document.txt You need a passphrase to unlock the secret key for user: « Kapil Sharma (Unix/Linux consultant) «
1024-bit DSA key, ID 020C9884, created 2000-11-09
Here « s » is for signing , « e » for encrypting, « a » to create ASCII armored output (« .asc » is ready for sending by mail), « r » to encrypt the user id name and is the data you want to encrypt
[root@dragon /]# gpg -d
As an example: [root@dragon /]# gpg -d documentforkapil.asc You need a passphrase to unlock the secret key for user: « Kapil Sharma (Unix/Linux consultant) » 1024-bit DSA key, ID 020C9884, created 2000-11-09
Here the parameter « d » is for decrypting the data and is a data you want to decrypt.
[Note: you must have the public key of the sender of the message/data that you want to decrypt in your public keyring database.]
10: Checking the signature
Once you have extracted your public key and exported it then by using the –verify option of GnuPG anybody can check whether encrypted data from you is also signed by you.
- To check the signature of encrypted data, use the following command:
[root@dragon /]# gpg –verify
Here « –verify » option is to check the signature and » » is the encrypted data/file you want to verify.
Some uses of GnuPG software
1: Send encrypted mail messages. 2: Encrypt files and documents 3: Transmit encrypted files and important documents through network
Here is a list of some of the Frontend and software for GnuPG
GPA aims to be the standard GnuPG graphical frontend. This has a very nice GUI interface.
GnomePGP is a GNOME desktop tool to control GnuPG.
Geheimniss is a KDE frontend for GnuPG.
pgp4pine is a Pine filter to handle PGP messages.
MagicPGP is yet another set of scripts to use GnuPG with Pine.
PinePGP is also a Pine filter for GnuPG.
Anybody who is cautious about security must use GnuPG. It is one of the best open-source programs which has all the functions for encryption and decryption for all your secure data and can be used without any restrictions since it is under GNU General Public License. It can be used to send encrypted mail messages, files and documents for security. It can also be used to transmit files and important documents through network securely.