2 Format of colon listings
3 ========================
6 $ gpg --fixed-list-mode --with-colons --list-keys \
7 --with-fingerprint --with-fingerprint wk@gnupg.org
9 pub:f:1024:17:6C7EE1B8621CC013:899817715:1055898235::m:::scESC:
10 fpr:::::::::ECAF7590EB3443B5C7CF3ACB6C7EE1B8621CC013:
11 uid:f::::::::Werner Koch <wk@g10code.com>:
12 uid:f::::::::Werner Koch <wk@gnupg.org>:
13 sub:f:1536:16:06AD222CADF6A6E1:919537416:1036177416:::::e:
14 fpr:::::::::CF8BCC4B18DE08FCD8A1615906AD222CADF6A6E1:
15 sub:r:1536:20:5CE086B5B5A18FF4:899817788:1025961788:::::esc:
16 fpr:::::::::AB059359A3B81F410FCFF97F5CE086B5B5A18FF4:
18 The double --with-fingerprint prints the fingerprint for the subkeys
19 too, --fixed-list-mode is themodern listing way printing dates in
20 seconds since Epoch and does not merge the first userID with the pub
24 1. Field: Type of record
26 crt = X.509 certificate
27 crs = X.509 certificate and private key available
28 sub = subkey (secondary key)
30 ssb = secret subkey (secondary key)
31 uid = user id (only field 10 is used).
32 uat = user attribute (same as user id except for field 10).
34 rev = revocation signature
35 fpr = fingerprint: (fingerprint is in field 10)
36 pkd = public key data (special field format, see below)
37 grp = reserved for gpgsm
39 tru = trust database information
40 spk = signature subpacket
42 2. Field: A letter describing the calculated trust. This is a single
43 letter, but be prepared that additional information may follow
44 in some future versions. (not used for secret keys)
45 o = Unknown (this key is new to the system)
46 i = The key is invalid (e.g. due to a missing self-signature)
47 d = The key has been disabled
48 (deprecated - use the 'D' in field 12 instead)
49 r = The key has been revoked
50 e = The key has expired
51 - = Unknown trust (i.e. no value assigned)
53 '-' and 'q' may safely be treated as the same
54 value for most purposes
55 n = Don't trust this key at all
56 m = There is marginal trust in this key
57 f = The key is fully trusted
58 u = The key is ultimately trusted. This often means
59 that the secret key is available, but any key may
60 be marked as ultimately trusted.
61 3. Field: length of key in bits.
62 4. Field: Algorithm: 1 = RSA
63 16 = Elgamal (encrypt only)
64 17 = DSA (sometimes called DH, sign only)
65 20 = Elgamal (sign and encrypt - don't use them!)
66 (for other id's see include/cipher.h)
68 6. Field: Creation Date (in UTC). For UID and UAT records, this is the
69 self-signature date. Note that the dae is usally printed
70 in seconds since epoch, however, we are migrating to an ISO
71 8601 format (e.g. "19660205T091500"). This is currently
72 only relevant for X.509, A simple way to detect the format
73 is be scannning for the 'T'.
74 7. Field: Key or user ID/user attribute expiration date or empty if none.
75 8. Field: Used for serial number in crt records (used to be the Local-ID).
76 For UID and UAT records, this is a hash of the user ID contents
77 used to represent that exact user ID. For trust signatures,
78 this is the trust depth seperated by the trust value by a
80 9. Field: Ownertrust (primary public keys only)
81 This is a single letter, but be prepared that additional
82 information may follow in some future versions. For trust
83 signatures with a regular expression, this is the regular
84 expression value, quoted as in field 10.
85 10. Field: User-ID. The value is quoted like a C string to avoid
86 control characters (the colon is quoted "\x3a").
87 This is not used with --fixed-list-mode in gpg.
88 A UAT record puts the attribute subpacket count here, a
89 space, and then the total attribute subpacket size.
90 In gpgsm the issuer name comes here
91 An FPR record stores the fingerprint here.
92 The fingerprint of an revocation key is stored here.
93 11. Field: Signature class. This is a 2 digit hexnumber followed by
94 either the letter 'x' for an exportable signature or the
95 letter 'l' for a local-only signature.
96 The class byte of an revocation key is also given here,
97 'x' and 'l' ist used the same way.
98 12. Field: Key capabilities:
103 A key may have any combination of them in any order. In
104 addition to these letters, the primary key has uppercase
105 versions of the letters to denote the _usable_
106 capabilities of the entire key, and a potential letter 'D'
107 to indicate a disabled key.
108 13. Field: Used in FPR records for S/MIME keys to store the fingerprint of
109 the issuer certificate. This is useful to build the
110 certificate path based on certificates stored in the local
111 keyDB; it is only filled if the issue certificate is
112 available. The advantage of using this value is that it is
113 guaranteed to have been been build by the same lookup
114 algorithm as gpgsm uses.
115 For "uid" recods this lists the preferences n the sameway the
117 For "sig" records, this is the fingerprint of the key that
118 issued the signature. Note that this is only filled in if
119 the signature verified correctly. Note also that for
120 various technical reasons, this fingerprint is only
121 available if --no-sig-cache is used.
123 14. Field Flag field used in the --edit menu output:
125 15. Field Used in sec/sbb to print the serial number of a token
126 (internal protect mode 1002) or a '#' if that key is a
127 simple stub (internal protect mode 1001)
129 All dates are displayed in the format yyyy-mm-dd unless you use the
130 option --fixed-list-mode in which case they are displayed as seconds
131 since Epoch. More fields may be added later, so parsers should be
132 prepared for this. When parsing a number the parser should stop at the
133 first non-number character so that additional information can later be
136 If field 1 has the tag "pkd", a listing looks like this:
137 pkd:0:1024:B665B1435F4C2 .... FF26ABB:
139 ! !------ for information number of bits in the value
140 !--------- index (eg. DSA goes from 0 to 3: p,q,g,y)
143 The "tru" trust database records have the fields:
145 2: Reason for staleness of trust. If this field is empty, then the
146 trustdb is not stale. This field may have multiple flags in it:
149 t: Trustdb was built with a different trust model than the one we
153 0: Classic trust model, as used in PGP 2.x.
154 1: PGP trust model, as used in PGP 6 and later. This is the same
155 as the classic trust model, except for the addition of trust
158 GnuPG before version 1.4 used the classic trust model by default.
159 GnuPG 1.4 and later uses the PGP trust model by default.
161 4: Date trustdb was created in seconds since 1/1/1970.
162 5: Date trustdb will expire in seconds since 1/1/1970.
164 The "spk" signature subpacket records have the fields:
166 2: Subpacket number as per RFC-2440 and later.
167 3: Flags in hex. Currently the only two bits assigned are 1, to
168 indicate that the subpacket came from the hashed part of the
169 signature, and 2, to indicate the subpacket was marked critical.
170 4: Length of the subpacket. Note that this is the length of the
171 subpacket, and not the length of field 5 below. Due to the need
172 for %-encoding, the length of field 5 may be up to 3x this value.
173 5: The subpacket data. Printable ASCII is shown as ASCII, but other
174 values are rendered as %XX where XX is the hex value for the byte.
177 Format of the "--status-fd" output
178 ==================================
179 Every line is prefixed with "[GNUPG:] ", followed by a keyword with
180 the type of the status line and a some arguments depending on the
181 type (maybe none); an application should always be prepared to see
182 more arguments in future versions.
186 May be issued right before a signature verification starts. This
187 is useful to define a context for parsing ERROR status
188 messages. No arguments are currently defined.
190 GOODSIG <long keyid> <username>
191 The signature with the keyid is good. For each signature only
192 one of the three codes GOODSIG, BADSIG or ERRSIG will be
193 emitted and they may be used as a marker for a new signature.
194 The username is the primary one encoded in UTF-8 and %XX
197 EXPSIG <long keyid> <username>
198 The signature with the keyid is good, but the signature is
199 expired. The username is the primary one encoded in UTF-8 and
202 EXPKEYSIG <long keyid> <username>
203 The signature with the keyid is good, but the signature was
204 made by an expired key. The username is the primary one
205 encoded in UTF-8 and %XX escaped.
207 REVKEYSIG <long keyid> <username>
208 The signature with the keyid is good, but the signature was
209 made by a revoked key. The username is the primary one
210 encoded in UTF-8 and %XX escaped.
212 BADSIG <long keyid> <username>
213 The signature with the keyid has not been verified okay.
214 The username is the primary one encoded in UTF-8 and %XX
217 ERRSIG <long keyid> <pubkey_algo> <hash_algo> \
218 <sig_class> <timestamp> <rc>
219 It was not possible to check the signature. This may be
220 caused by a missing public key or an unsupported algorithm.
221 A RC of 4 indicates unknown algorithm, a 9 indicates a missing
222 public key. The other fields give more information about
223 this signature. sig_class is a 2 byte hex-value.
225 Note, that TIMESTAMP may either be a number with seconds since
226 epoch or an ISO 8601 string which can be detected by the
227 presence of the letter 'T' inside.
229 VALIDSIG <fingerprint in hex> <sig_creation_date> <sig-timestamp>
230 <expire-timestamp> <sig-version> <reserved> <pubkey-algo>
231 <hash-algo> <sig-class> <primary-key-fpr>
233 The signature with the keyid is good. This is the same as
234 GOODSIG but has the fingerprint as the argument. Both status
235 lines are emitted for a good signature. All arguments here
236 are on one long line. sig-timestamp is the signature creation
237 time in seconds after the epoch. expire-timestamp is the
238 signature expiration time in seconds after the epoch (zero
239 means "does not expire"). sig-version, pubkey-algo, hash-algo,
240 and sig-class (a 2-byte hex value) are all straight from the
241 signature packet. PRIMARY-KEY-FPR is the fingerprint of the
242 primary key or identical to the first argument. This is
243 useful to get back to the primary key without running gpg
244 again for this purpose.
246 Note, that *-TIMESTAMP may either be a number with seconds
247 since epoch or an ISO 8601 string which can be detected by the
248 presence of the letter 'T' inside.
250 SIG_ID <radix64_string> <sig_creation_date> <sig-timestamp>
251 This is emitted only for signatures of class 0 or 1 which
252 have been verified okay. The string is a signature id
253 and may be used in applications to detect replay attacks
254 of signed messages. Note that only DLP algorithms give
255 unique ids - others may yield duplicated ones when they
256 have been created in the same second.
258 Note, that SIG-TIMESTAMP may either be a number with seconds
259 since epoch or an ISO 8601 string which can be detected by the
260 presence of the letter 'T' inside.
263 ENC_TO <long keyid> <keytype> <keylength>
264 The message is encrypted to this keyid.
265 keytype is the numerical value of the public key algorithm,
266 keylength is the length of the key or 0 if it is not known
267 (which is currently always the case).
270 No data has been found. Codes for what are:
272 2 - Expected a packet but did not found one.
273 3 - Invalid packet found, this may indicate a non OpenPGP
275 4 - signature expected but not found
276 You may see more than one of these status lines.
279 Unexpected data has been encountered
280 0 - not further specified 1
283 TRUST_UNDEFINED <error token>
284 TRUST_NEVER <error token>
288 For good signatures one of these status lines are emitted
289 to indicate how trustworthy the signature is. The error token
290 values are currently only emiited by gpgsm.
292 PKA_TRUST_GOOD <mailbox>
293 PKA_TRUST_BAD <mailbox>
294 Depending on the outcome of the PKA check one of the above
295 status codes is emitted in addition to a TRUST_* status.
296 Without PKA info available or
299 This is deprecated in favor of KEYEXPIRED.
301 KEYEXPIRED <expire-timestamp>
302 The key has expired. expire-timestamp is the expiration time
303 in seconds after the epoch.
305 Note, that TIMESTAMP may either be a number with seconds since
306 epoch or an ISO 8601 string which can be detected by the
307 presence of the letter 'T' inside.
310 The used key has been revoked by its owner. No arguments yet.
313 The ASCII armor is corrupted. No arguments yet.
316 The IDEA algorithms has been used in the data. A
317 program might want to fallback to another program to handle
318 the data if GnuPG failed. This status message used to be emitted
319 also for RSA but this has been dropped after the RSA patent expired.
320 However we can't change the name of the message.
332 NEED_PASSPHRASE <long main keyid> <long keyid> <keytype> <keylength>
333 Issued whenever a passphrase is needed.
334 keytype is the numerical value of the public key algorithm
335 or 0 if this is not applicable, keylength is the length
336 of the key or 0 if it is not known (this is currently always the case).
338 NEED_PASSPHRASE_SYM <cipher_algo> <s2k_mode> <s2k_hash>
339 Issued whenever a passphrase for symmetric encryption is needed.
341 NEED_PASSPHRASE_PIN <card_type> <chvno> [<serialno>]
342 Issued whenever a PIN is requested to unlock a card.
345 No passphrase was supplied. An application which encounters this
346 message may want to stop parsing immediately because the next message
347 will probably be a BAD_PASSPHRASE. However, if the application
348 is a wrapper around the key edit menu functionality it might not
349 make sense to stop parsing but simply ignoring the following
352 BAD_PASSPHRASE <long keyid>
353 The supplied passphrase was wrong or not given. In the latter case
354 you may have seen a MISSING_PASSPHRASE.
357 The supplied passphrase was good and the secret key material
361 The symmetric decryption failed - one reason could be a wrong
362 passphrase for a symmetrical encrypted message.
365 The decryption process succeeded. This means, that either the
366 correct secret key has been used or the correct passphrase
367 for a conventional encrypted message was given. The program
368 itself may return an errorcode because it may not be possible to
369 verify a signature for some reasons.
371 NO_PUBKEY <long keyid>
372 NO_SECKEY <long keyid>
373 The key is not available
375 IMPORT_CHECK <long keyid> <fingerprint> <user ID>
376 This status is emitted in interactive mode right before
377 the "import.okay" prompt.
379 IMPORTED <long keyid> <username>
380 The keyid and name of the signature just imported
382 IMPORT_OK <reason> [<fingerprint>]
383 The key with the primary key's FINGERPRINT has been imported.
385 0 := Not actually changed
386 1 := Entirely new key.
390 16 := Contains private key.
391 The flags may be ORed.
393 IMPORT_PROBLEM <reason> [<fingerprint>]
394 Issued for each import failure. Reason codes are:
395 0 := "No specific reason given".
396 1 := "Invalid Certificate".
397 2 := "Issuer Certificate missing".
398 3 := "Certificate Chain too long".
399 4 := "Error storing certificate".
401 IMPORT_RES <count> <no_user_id> <imported> <imported_rsa> <unchanged>
402 <n_uids> <n_subk> <n_sigs> <n_revoc> <sec_read> <sec_imported> <sec_dups> <not_imported>
403 Final statistics on import process (this is one long line)
405 FILE_START <what> <filename>
406 Start processing a file <filename>. <what> indicates the performed
413 Marks the end of a file processing which has been started
418 Mark the start and end of the actual decryption process. These
419 are also emitted when in --list-only mode.
421 BEGIN_ENCRYPTION <mdc_method> <sym_algo>
423 Mark the start and end of the actual encryption process.
426 Mark the start of the actual signing process. This may be used
427 as an indication that all requested secret keys are ready for
430 DELETE_PROBLEM reason_code
431 Deleting a key failed. Reason codes are:
433 2 - Must delete secret key first
434 3 - Ambigious specification
436 PROGRESS what char cur total
437 Used by the primegen and Public key functions to indicate progress.
438 "char" is the character displayed with no --status-fd enabled, with
439 the linefeed replaced by an 'X'. "cur" is the current amount
440 done and "total" is amount to be done; a "total" of 0 indicates that
441 the total amount is not known. 100/100 may be used to detect the
443 Well known values for WHAT:
444 "pk_dsa" - DSA key generation
445 "pk_elg" - Elgamal key generation
446 "primegen" - Prime generation
447 "need_entropy" - Waiting for new entropy in the RNG
448 "file:XXX" - processing file XXX
449 (note that current gpg versions leave out the
451 "tick" - generic tick without any special meaning - useful
452 for letting clients know that the server is
454 "starting_agent" - A gpg-agent was started because it is not
458 SIG_CREATED <type> <pubkey algo> <hash algo> <class> <timestamp> <key fpr>
459 A signature has been created using these parameters.
463 (only the first character should be checked)
464 class: 2 hex digits with the signature class
466 Note, that TIMESTAMP may either be a number with seconds since
467 epoch or an ISO 8601 string which can be detected by the
468 presence of the letter 'T' inside.
470 KEY_CREATED <type> <fingerprint> [<handle>]
471 A key has been created
472 type: 'B' = primary and subkey
475 The fingerprint is one of the primary key for type B and P and
476 the one of the subkey for S. Handle is an arbitrary
477 non-whitespace string used to match key parameters from batch
480 KEY_NOT_CREATED [<handle>]
481 The key from batch run has not been created due to errors.
484 SESSION_KEY <algo>:<hexdigits>
485 The session key used to decrypt the message. This message will
486 only be emitted when the special option --show-session-key
487 is used. The format is suitable to be passed to the option
488 --override-session-key
491 NOTATION_DATA <string>
492 name and string are %XX escaped; the data may be splitted
493 among several notation_data lines.
495 USERID_HINT <long main keyid> <string>
496 Give a hint about the user ID for a certain keyID.
499 string is %XX escaped
505 INV_RECP <reason> <requested_recipient>
506 Issued for each unusable recipient. The reasons codes
507 currently in use are:
508 0 := "No specific reason given".
510 2 := "Ambigious specification"
511 3 := "Wrong key usage"
516 8 := "Policy mismatch"
517 9 := "Not a secret key"
518 10 := "Key not trusted"
520 Note that this status is also used for gpgsm's SIGNER command
521 where it relates to signer's of course.
524 Issued when no recipients are usable.
526 ALREADY_SIGNED <long-keyid>
527 Warning: This is experimental and might be removed at any time.
530 The output was truncated to MAXNO items. This status code is issued
531 for certain external requests
533 ERROR <error location> <error code>
535 This is a generic error status message, it might be followed
536 by error location specific data. <error token> and
537 <error_location> should not contain a space. The error code
538 is a either a string commencing with a letter or such string
539 prefix with a numerical error code and an underscore; e.g.:
542 ATTRIBUTE <fpr> <octets> <type> <index> <count>
543 <timestamp> <expiredate> <flags>
544 This is one long line issued for each attribute subpacket when
545 an attribute packet is seen during key listing. <fpr> is the
546 fingerprint of the key. <octets> is the length of the
547 attribute subpacket. <type> is the attribute type
548 (1==image). <index>/<count> indicates that this is the Nth
549 indexed subpacket of count total subpackets in this attribute
550 packet. <timestamp> and <expiredate> are from the
551 self-signature on the attribute packet. If the attribute
552 packet does not have a valid self-signature, then the
553 timestamp is 0. <flags> are a bitwise OR of:
554 0x01 = this attribute packet is a primary uid
555 0x02 = this attribute packet is revoked
556 0x04 = this attribute packet is expired
558 CARDCTRL <what> [<serialno>]
559 This is used to control smartcard operations.
560 Defined values for WHAT are:
561 1 = Request insertion of a card. Serialnumber may be given
562 to request a specific card.
563 2 = Request removal of a card.
564 3 = Card with serialnumber detected
565 4 = No card available.
566 5 = No card reader available
569 PLAINTEXT <format> <timestamp> <filename>
570 This indicates the format of the plaintext that is about to be
571 written. The format is a 1 byte hex code that shows the
572 format of the plaintext: 62 ('b') is binary data, 74 ('t') is
573 text data with no character set specified, and 75 ('u') is
574 text data encoded in the UTF-8 character set. The timestamp
575 is in seconds since the epoch. If a filename is available it
576 gets printed as the third argument, percent-escaped as usual.
578 PLAINTEXT_LENGTH <length>
579 This indicates the length of the plaintext that is about to be
580 written. Note that if the plaintext packet has partial length
581 encoding it is not possible to know the length ahead of time.
582 In that case, this status tag does not appear.
584 SIG_SUBPACKET <type> <flags> <len> <data>
585 This indicates that a signature subpacket was seen. The
586 format is the same as the "spk" record above.
588 SC_OP_FAILURE [<code>]
589 An operation on a smartcard definitely failed. Currently
590 there is no indication of the actual error code, but
591 application should be prepared to later accept more arguments.
592 Defined values for CODE are:
593 0 - unspecified error (identically to a missing CODE)
598 A smart card operaion succeeded. This status is only printed
599 for certain operation and is mostly useful to check whether a
600 PIN change really worked.
602 BACKUP_KEY_CREATED fingerprint fname
603 A backup key named FNAME has been created for the key with
607 Format of the "--attribute-fd" output
608 =====================================
610 When --attribute-fd is set, during key listings (--list-keys,
611 --list-secret-keys) GnuPG dumps each attribute packet to the file
612 descriptor specified. --attribute-fd is intended for use with
613 --status-fd as part of the required information is carried on the
614 ATTRIBUTE status tag (see above).
616 The contents of the attribute data is specified by 2440bis, but for
617 convenience, here is the Photo ID format, as it is currently the only
620 Byte 0-1: The length of the image header. Due to a historical
621 accident (i.e. oops!) back in the NAI PGP days, this is
622 a little-endian number. Currently 16 (0x10 0x00).
624 Byte 2: The image header version. Currently 0x01.
626 Byte 3: Encoding format. 0x01 == JPEG.
628 Byte 4-15: Reserved, and currently unused.
630 All other data after this header is raw image (JPEG) data.
633 Format of the "--list-config" output
634 ====================================
636 --list-config outputs information about the GnuPG configuration for
637 the benefit of frontends or other programs that call GnuPG. There are
638 several list-config items, all colon delimited like the rest of the
639 --with-colons output. The first field is always "cfg" to indicate
640 configuration information. The second field is one of (with
643 version: the third field contains the version of GnuPG.
647 pubkey: the third field contains the public key algorithmdcaiphers
648 this version of GnuPG supports, separated by semicolons. The
649 algorithm numbers are as specified in RFC-2440.
651 cfg:pubkey:1;2;3;16;17
653 cipher: the third field contains the symmetric ciphers this version of
654 GnuPG supports, separated by semicolons. The cipher numbers
655 are as specified in RFC-2440.
657 cfg:cipher:2;3;4;7;8;9;10
659 digest: the third field contains the digest (hash) algorithms this
660 version of GnuPG supports, separated by semicolons. The
661 digest numbers are as specified in RFC-2440.
663 cfg:digest:1;2;3;8;9;10
665 compress: the third field contains the compression algorithms this
666 version of GnuPG supports, separated by semicolons. The
667 algorithm numbers are as specified in RFC-2440.
671 group: the third field contains the name of the group, and the fourth
672 field contains the values that the group expands to, separated
675 For example, a group of:
676 group mynames = paige 0x12345678 joe patti
679 cfg:group:mynames:patti;joe;0x12345678;paige
684 Key generation shows progress by printing different characters to
686 "." Last 10 Miller-Rabin tests failed
687 "+" Miller-Rabin test succeeded
688 "!" Reloading the pool with fresh prime numbers
689 "^" Checking a new value for the generator
690 "<" Size of one factor decreased
691 ">" Size of one factor increased
693 The prime number for Elgamal is generated this way:
695 1) Make a prime number q of 160, 200, 240 bits (depending on the keysize)
696 2) Select the length of the other prime factors to be at least the size
697 of q and calculate the number of prime factors needed
698 3) Make a pool of prime numbers, each of the length determined in step 2
699 4) Get a new permutation out of the pool or continue with step 3
700 if we have tested all permutations.
701 5) Calculate a candidate prime p = 2 * q * p[1] * ... * p[n] + 1
702 6) Check that this prime has the correct length (this may change q if
703 it seems not to be possible to make a prime of the desired length)
704 7) Check whether this is a prime using trial divisions and the
706 8) Continue with step 4 if we did not find a prime in step 7.
707 9) Find a generator for that prime.
709 This algorithm is based on Lim and Lee's suggestion from the
710 Crypto '97 proceedings p. 260.
713 Unattended key generation
714 =========================
715 This feature allows unattended generation of keys controlled by a
716 parameter file. To use this feature, you use --gen-key together with
717 --batch and feed the parameters either from stdin or from a file given
720 The format of this file is as follows:
721 o Text only, line length is limited to about 1000 chars.
722 o You must use UTF-8 encoding to specify non-ascii characters.
723 o Empty lines are ignored.
724 o Leading and trailing spaces are ignored.
725 o A hash sign as the first non white space character indicates a comment line.
726 o Control statements are indicated by a leading percent sign, the
727 arguments are separated by white space from the keyword.
728 o Parameters are specified by a keyword, followed by a colon. Arguments
729 are separated by white space.
730 o The first parameter must be "Key-Type", control statements
731 may be placed anywhere.
732 o Key generation takes place when either the end of the parameter file
733 is reached, the next "Key-Type" parameter is encountered or at the
734 control statement "%commit"
735 o Control statements:
739 Suppress actual key generation (useful for syntax checking).
741 Perform the key generation. An implicit commit is done
742 at the next "Key-Type" parameter.
745 Do not write the key to the default or commandline given
746 keyring but to <filename>. This must be given before the first
747 commit to take place, duplicate specification of the same filename
748 is ignored, the last filename before a commit is used.
749 The filename is used until a new filename is used (at commit points)
750 and all keys are written to that file. If a new filename is given,
751 this file is created (and overwrites an existing one).
752 Both control statements must be given.
753 o The order of the parameters does not matter except for "Key-Type"
754 which must be the first parameter. The parameters are only for the
755 generated keyblock and parameters from previous key generations are not
756 used. Some syntactically checks may be performed.
757 The currently defined parameters are:
758 Key-Type: <algo-number>|<algo-string>
759 Starts a new parameter block by giving the type of the
760 primary key. The algorithm must be capable of signing.
761 This is a required parameter.
762 Key-Length: <length-in-bits>
763 Length of the key in bits. Default is 1024.
764 Key-Usage: <usage-list>
765 Space or comma delimited list of key usage, allowed values are
766 "encrypt", "sign", and "auth". This is used to generate the
767 key flags. Please make sure that the algorithm is capable of
768 this usage. Note that OpenPGP requires that all primary keys
769 are capable of certification, so no matter what usage is given
770 here, the "cert" flag will be on. If no Key-Usage is
771 specified, all the allowed usages for that particular
773 Subkey-Type: <algo-number>|<algo-string>
774 This generates a secondary key. Currently only one subkey
776 Subkey-Length: <length-in-bits>
777 Length of the subkey in bits. Default is 1024.
778 Subkey-Usage: <usage-list>
779 Similar to Key-Usage.
781 If you want to specify a passphrase for the secret key,
782 enter it here. Default is not to use any passphrase.
784 Name-Comment: <string>
786 The 3 parts of a key. Remember to use UTF-8 here.
787 If you don't give any of them, no user ID is created.
788 Expire-Date: <iso-date>|(<number>[d|w|m|y])
789 Set the expiration date for the key (and the subkey). It
790 may either be entered in ISO date format (2000-08-15) or as
791 number of days, weeks, month or years. Without a letter days
793 Preferences: <string>
794 Set the cipher, hash, and compression preference values for
795 this key. This expects the same type of string as "setpref"
797 Revoker: <algo>:<fpr> [sensitive]
798 Add a designated revoker to the generated key. Algo is the
799 public key algorithm of the designated revoker (i.e. RSA=1,
800 DSA=17, etc.) Fpr is the fingerprint of the designated
801 revoker. The optional "sensitive" flag marks the designated
802 revoker as sensitive information. Only v4 keys may be
805 This is an optional parameter only used with the status lines
806 KEY_CREATED and KEY_NOT_CREATED. STRING may be up to 100
807 characters and should not contain spaces. It is useful for
808 batch key generation to associate a key parameter block with a
814 %echo Generating a standard key
819 Name-Real: Joe Tester
820 Name-Comment: with stupid passphrase
821 Name-Email: joe@foo.bar
826 # Do a commit here, so that we can later print "done" :-)
830 $ gpg --batch --gen-key foo
832 $ gpg --no-default-keyring --secret-keyring ./foo.sec \
833 --keyring ./foo.pub --list-secret-keys
834 /home/wk/work/gnupg-stable/scratch/foo.sec
835 ------------------------------------------
836 sec 1024D/915A878D 2000-03-09 Joe Tester (with stupid passphrase) <joe@foo.bar>
837 ssb 1024g/8F70E2C0 2000-03-09
841 Layout of the TrustDB
842 =====================
843 The TrustDB is built from fixed length records, where the first byte
844 describes the record type. All numeric values are stored in network
845 byte order. The length of each record is 40 bytes. The first record of
846 the DB is always of type 1 and this is the only record of this type.
848 FIXME: The layout changed, document it here.
852 Unused record, can be reused for any purpose.
856 Version information for this TrustDB. This is always the first
857 record of the DB and the only one with type 1.
859 3 bytes 'gpg' magic value
860 1 byte Version of the TrustDB (2)
861 1 byte marginals needed
862 1 byte completes needed
863 1 byte max_cert_depth
864 The three items are used to check whether the cached
865 validity value from the dir record can be used.
866 1 u32 locked flags [not used]
867 1 u32 timestamp of trustdb creation
868 1 u32 timestamp of last modification which may affect the validity
869 of keys in the trustdb. This value is checked against the
870 validity timestamp in the dir records.
871 1 u32 timestamp of last validation [currently not used]
872 (Used to keep track of the time, when this TrustDB was checked
874 1 u32 record number of keyhashtable [currently not used]
875 1 u32 first free record
876 1 u32 record number of shadow directory hash table [currently not used]
877 It does not make sense to combine this table with the key table
878 because the keyid is not in every case a part of the fingerprint.
879 1 u32 record number of the trusthashtbale
882 Record type 2: (directory record)
884 Informations about a public key certificate.
885 These are static values which are never changed without user interaction.
889 1 u32 LID . (This is simply the record number of this record.)
890 1 u32 List of key-records (the first one is the primary key)
891 1 u32 List of uid-records
895 1 byte maximum validity of all the user ids
896 1 u32 time of last validity check.
897 1 u32 Must check when this time has been reached.
898 (0 = no check required)
901 Record type 3: (key record)
903 Informations about a primary public key.
904 (This is mainly used to lookup a trust record)
909 1 u32 next - next key record
912 1 byte pubkey algorithm
913 1 byte length of the fingerprint (in bytes)
914 20 bytes fingerprint of the public key
915 (This is the value we use to identify a key)
917 Record type 4: (uid record)
919 Informations about a userid
920 We do not store the userid but the hash value of the userid because that
925 1 u32 LID points to the directory record.
926 1 u32 next next userid
927 1 u32 pointer to preference record
928 1 u32 siglist list of valid signatures
930 1 byte validity of the key calculated over this user id
931 20 bytes ripemd160 hash of the username.
934 Record type 5: (pref record)
936 This record type is not anymore used.
940 1 u32 LID; points to the directory record (and not to the uid record!).
941 (or 0 for standard preference record)
943 30 byte preference data
945 Record type 6 (sigrec)
947 Used to keep track of key signatures. Self-signatures are not
948 stored. If a public key is not in the DB, the signature points to
949 a shadow dir record, which in turn has a list of records which
950 might be interested in this key (and the signature record here
955 1 u32 LID points back to the dir record
956 1 u32 next next sigrec of this uid or 0 to indicate the
959 1 u32 Local_id of signatures dir or shadow dir record
960 1 byte Flag: Bit 0 = checked: Bit 1 is valid (we have a real
961 directory record for this)
962 1 = valid is set (but may be revoked)
966 Record type 8: (shadow directory record)
968 This record is used to reserve a LID for a public key. We
969 need this to create the sig records of other keys, even if we
970 do not yet have the public key of the signature.
971 This record (the record number to be more precise) will be reused
972 as the dir record when we import the real public key.
976 1 u32 LID (This is simply the record number of this record.)
978 1 byte pubkey algorithm
980 1 u32 hintlist A list of records which have references to
981 this key. This is used for fast access to
982 signature records which are not yet checked.
983 Note, that this is only a hint and the actual records
984 may not anymore hold signature records for that key
985 but that the code cares about this.
990 Record Type 10 (hash table)
992 Due to the fact that we use fingerprints to lookup keys, we can
993 implement quick access by some simple hash methods, and avoid
994 the overhead of gdbm. A property of fingerprints is that they can be
995 used directly as hash values. (They can be considered as strong
997 What we use is a dynamic multilevel architecture, which combines
998 hashtables, record lists, and linked lists.
1000 This record is a hashtable of 256 entries; a special property
1001 is that all these records are stored consecutively to make one
1002 big table. The hash value is simple the 1st, 2nd, ... byte of
1003 the fingerprint (depending on the indirection level).
1005 When used to hash shadow directory records, a different table is used
1006 and indexed by the keyid.
1010 n u32 recnum; n depends on the record length:
1011 n = (reclen-2)/4 which yields 9 for the current record length
1014 the total number of such record which makes up the table is:
1016 which is 29 for a record length of 40.
1018 To look up a key we use the first byte of the fingerprint to get
1019 the recnum from this hashtable and look up the addressed record:
1020 - If this record is another hashtable, we use 2nd byte
1021 to index this hash table and so on.
1022 - if this record is a hashlist, we walk all entries
1023 until we found one a matching one.
1024 - if this record is a key record, we compare the
1025 fingerprint and to decide whether it is the requested key;
1028 Record type 11 (hash list)
1030 see hash table for an explanation.
1031 This is also used for other purposes.
1035 1 u32 next next hash list record
1036 n times n = (reclen-5)/5
1039 For the current record length of 40, n is 7
1043 Record type 254 (free record)
1045 All these records form a linked list of unused records.
1055 GNUPG uses PGP 2 packet headers and also understands OpenPGP packet header.
1056 There is one enhancement used with the old style packet headers:
1058 CTB bits 10, the "packet-length length bits", have values listed in
1059 the following table:
1061 00 - 1-byte packet-length field
1062 01 - 2-byte packet-length field
1063 10 - 4-byte packet-length field
1064 11 - no packet length supplied, unknown packet length
1066 As indicated in this table, depending on the packet-length length
1067 bits, the remaining 1, 2, 4, or 0 bytes of the packet structure field
1068 are a "packet-length field". The packet-length field is a whole
1069 number field. The value of the packet-length field is defined to be
1070 the value of the whole number field.
1072 A value of 11 is currently used in one place: on compressed data.
1073 That is, a compressed data block currently looks like <A3 01 . . .>,
1074 where <A3>, binary 10 1000 11, is an indefinite-length packet. The
1075 proper interpretation is "until the end of the enclosing structure",
1076 although it should never appear outermost (where the enclosing
1077 structure is a file).
1079 + This will be changed with another version, where the new meaning of
1080 + the value 11 (see below) will also take place.
1082 + A value of 11 for other packets enables a special length encoding,
1083 + which is used in case, where the length of the following packet can
1084 + not be determined prior to writing the packet; especially this will
1085 + be used if large amounts of data are processed in filter mode.
1087 + It works like this: After the CTB (with a length field of 11) a
1088 + marker field is used, which gives the length of the following datablock.
1089 + This is a simple 2 byte field (MSB first) containing the amount of data
1090 + following this field, not including this length field. After this datablock
1091 + another length field follows, which gives the size of the next datablock.
1092 + A value of 0 indicates the end of the packet. The maximum size of a
1093 + data block is limited to 65534, thereby reserving a value of 0xffff for
1094 + future extensions. These length markers must be inserted into the data
1095 + stream just before writing the data out.
1097 + This 2 byte field is large enough, because the application must buffer
1098 + this amount of data to prepend the length marker before writing it out.
1099 + Data block sizes larger than about 32k doesn't make any sense. Note
1100 + that this may also be used for compressed data streams, but we must use
1101 + another packet version to tell the application that it can not assume,
1102 + that this is the last packet.
1105 GNU extensions to the S2K algorithm
1106 ===================================
1107 S2K mode 101 is used to identify these extensions.
1108 After the hash algorithm the 3 bytes "GNU" are used to make
1109 clear that these are extensions for GNU, the next bytes gives the
1110 GNU protection mode - 1000. Defined modes are:
1111 1001 - do not store the secret part at all
1112 1002 - a stub to access smartcards (not used in 1.2.x)
1117 NOTE: This is deprecated and will be removed in future versions.
1119 This mode can be used to perform multiple operations with one call to
1120 gpg. It comes handy in cases where you have to verify a lot of
1121 signatures. Currently we support only detached signatures. This mode
1122 is a kludge to avoid running gpg n daemon mode and using Unix Domain
1123 Sockets to pass the data to it. There is no easy portable way to do
1124 this under Windows, so we use plain old pipes which do work well under
1125 Windows. Because there is no way to signal multiple EOFs in a pipe we
1126 have to embed control commands in the data stream: We distinguish
1127 between a data state and a control state. Initially the system is in
1128 data state but it won't accept any data. Instead it waits for
1129 transition to control state which is done by sending a single '@'
1130 character. While in control state the control command os expected and
1131 this command is just a single byte after which the system falls back
1132 to data state (but does not necesary accept data now). The simplest
1133 control command is a '@' which just inserts this character into the
1136 Here is the format we use for detached signatures:
1137 "@<" - Begin of new stream
1138 "@B" - Detached signature follows.
1139 This emits a control packet (1,'B')
1140 <detached_signature>
1141 "@t" - Signed text follows.
1142 This emits the control packet (2, 'B')
1144 "@." - End of operation. The final control packet forces signature
1146 "@>" - End of stream
1155 * For packet version 3 we calculate the keyids this way:
1156 RSA := low 64 bits of n
1157 ELGAMAL := build a v3 pubkey packet (with CTB 0x99) and calculate
1158 a rmd160 hash value from it. This is used as the
1159 fingerprint and the low 64 bits are the keyid.
1161 * Revocation certificates consist only of the signature packet;
1162 "import" knows how to handle this. The rationale behind it is
1171 Keyserver Message Format
1172 =========================
1174 The keyserver may be contacted by a Unix Domain socket or via TCP.
1176 The format of a request is:
1180 "Content-length:" digits
1184 Where command-tag is
1192 The format of a response is:
1195 "GNUPG/1.0" status-code status-text
1196 "Content-length:" digits
1199 followed by <digits> bytes of data
1204 o 1xx: Informational - Request received, continuing process
1206 o 2xx: Success - The action was successfully received, understood,
1209 o 4xx: Client Error - The request contains bad syntax or cannot be
1212 o 5xx: Server Error - The server failed to fulfill an apparently
1217 Documentation on HKP (the http keyserver protocol):
1219 A minimalistic HTTP server on port 11371 recognizes a GET for /pks/lookup.
1220 The standard http URL encoded query parameters are this (always key=value):
1222 - op=index (like pgp -kv), op=vindex (like pgp -kvv) and op=get (like
1225 - search=<stringlist>. This is a list of words that must occur in the key.
1226 The words are delimited with space, points, @ and so on. The delimiters
1227 are not searched for and the order of the words doesn't matter (but see
1230 - exact=on. This switch tells the hkp server to only report exact matching
1231 keys back. In this case the order and the "delimiters" are important.
1233 - fingerprint=on. Also reports the fingerprints when used with 'index' or
1236 The keyserver also recognizes http-POSTs to /pks/add. Use this to upload
1240 A better way to do this would be a request like:
1242 /pks/lookup/<gnupg_formatierte_user_id>?op=<operation>
1244 This can be implemented using Hurd's translator mechanism.
1245 However, I think the whole key server stuff has to be re-thought;
1246 I have some ideas and probably create a white paper.