Home | Mirror | Search

Chapter 11. OpenPGP/OpenGPG(GnuPG)

Table of Contents

1. GnuPG
1.1. Creating a key (創建key)
1.2. Exporting keys (導出key)
1.2.1. --export export keys
1.2.2. -o, --output use as output file
1.3. Importing keys (導入key)
1.4. Revoke a key (吊銷key)
2. GnuPG For Windows
2.1. 生成密鑰對
2.2. 列出密鑰
2.3. 驗證簽字
3. EMail-Security
4. Smart Card

下載PGP: http://www.pgp.com/

下載OpenPGP: http://www.pgpi.org/

1. GnuPG

GnuPG

~/.gnupg/gpg.conf 	 – 配置檔案
~/.gnupg/trustdb.gpg – 信任庫
~/.gnupg/pubring.gpg – 公鑰庫
~/.gnupg/secring.gpg – 私鑰庫
		

1.1. Creating a key (創建key)

--gen-key generate a new key pair

			
neo@neo-laptop:~$ gpg --gen-key
gpg (GnuPG) 1.4.11; Copyright (C) 2010 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
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) 1y
Key expires at Tuesday, October 22, 2013 PM03:25:35 HKT
Is this correct? (y/N) y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"

Real name: Neo Chan
Email address: 324@example.com
Comment: Office Email
You selected this USER-ID:
    "Neo Chan (Office Email) <324@example.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 282 more bytes)
.......+++++
.......+++++
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
..+++++
..+++++
gpg: key CEF09301 marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2013-10-22
pub   2048R/CEF09301 2012-10-22 [expires: 2013-10-22]
      Key fingerprint = C5B7 50EF 762F 3F7F 1AE5  8AEC AF10 D50D CEF0 9301
uid                  Neo Chan (Office Email) <324@example.com>
sub   2048R/0BF4D523 2012-10-22 [expires: 2013-10-22]
			
			

1.2. Exporting keys (導出key)

1.2.1. --export export keys

				
gpg --export -a
				
				

1.2.2. -o, --output use as output file

				
$ gpg --export -a -o test.asc
$ gpg --output yourname.asc --export -a
				
				

1.3. Importing keys (導入key)

--import import/merge keys

			
neo@neo-laptop:~$ gpg --import 409.asc
gpg: key 4D3A0803: public key "Phoenix.L <409@example.com>" imported
gpg: key CEF09301: "Neo Chan (Office Email) <324@example.com>" not changed
gpg: Total number processed: 2
gpg:               imported: 1  (RSA: 1)
gpg:              unchanged: 1

			
			

1.4. Revoke a key (吊銷key)

			
gpg --gen-revoke
			
			
comments powered by Disqus