chiark / gitweb /
gpg-agent connection count: Introduce locking
[gnupg2.git] / doc / DETAILS
1 # doc/DETAILS                                                -*- org -*-
2 #+TITLE: GnuPG Details
3 # Globally disable superscripts and subscripts:
4 #+OPTIONS: ^:{}
5 #
6
7 # Note: This file uses org-mode; it should be easy to read as plain
8 # text but be aware of some markup peculiarities: Verbatim code is
9 # enclosed in #+begin-example, #+end-example blocks or marked by a
10 # colon as the first non-white-space character, words bracketed with
11 # equal signs indicate a monospace font, and the usual /italics/,
12 # *bold*, and _underline_ conventions are recognized.
13
14 This is the DETAILS file for GnuPG which specifies some internals and
15 parts of the external API for GPG and GPGSM.
16
17 * Format of the colon listings
18
19   The format is a based on colon separated record, each recods starts
20   with a tag string and extends to the end of the line.  Here is an
21   example:
22 #+begin_example
23 $ gpg --with-colons --list-keys \
24       --with-fingerprint --with-fingerprint wk@gnupg.org
25 pub:f:1024:17:6C7EE1B8621CC013:899817715:1055898235::m:::scESC:
26 fpr:::::::::ECAF7590EB3443B5C7CF3ACB6C7EE1B8621CC013:
27 uid:f::::::::Werner Koch <wk@g10code.com>:
28 uid:f::::::::Werner Koch <wk@gnupg.org>:
29 sub:f:1536:16:06AD222CADF6A6E1:919537416:1036177416:::::e:
30 fpr:::::::::CF8BCC4B18DE08FCD8A1615906AD222CADF6A6E1:
31 sub:r:1536:20:5CE086B5B5A18FF4:899817788:1025961788:::::esc:
32 fpr:::::::::AB059359A3B81F410FCFF97F5CE086B5B5A18FF4:
33 #+end_example
34
35 Note that new version of GnuPG or the use of certain options may add
36 new fields to the output.  Parsers should not assume a limit on the
37 number of fields per line.  Some fields are not yet used or only used
38 with certain record types; parsers should ignore fields they are not
39 aware of.  New versions of GnuPG or the use of certain options may add
40 new types of records as well.  Parsers should ignore any record whose
41 type they do not recognize for forward-compatibility.
42
43 The double =--with-fingerprint= prints the fingerprint for the subkeys
44 too.  Old versions of gpg used a slightly different format and required
45 the use of the option =--fixed-list-mode= to conform to the format
46 described here.
47
48
49 ** Description of the fields
50 *** Field 1 - Type of record
51
52     - pub :: Public key
53     - crt :: X.509 certificate
54     - crs :: X.509 certificate and private key available
55     - sub :: Subkey (secondary key)
56     - sec :: Secret key
57     - ssb :: Secret subkey (secondary key)
58     - uid :: User id
59     - uat :: User attribute (same as user id except for field 10).
60     - sig :: Signature
61     - rev :: Revocation signature
62     - fpr :: Fingerprint (fingerprint is in field 10)
63     - pkd :: Public key data [*]
64     - grp :: Keygrip
65     - rvk :: Revocation key
66     - tfs :: TOFU statistics [*]
67     - tru :: Trust database information [*]
68     - spk :: Signature subpacket [*]
69     - cfg :: Configuration data [*]
70
71     Records marked with an asterisk are described at [[*Special%20field%20formats][*Special fields]].
72
73 *** Field 2 - Validity
74
75     This is a letter describing the computed validity of a key.
76     Currently this is a single letter, but be prepared that additional
77     information may follow in some future versions. Note that GnuPG <
78     2.1 does not set this field for secret key listings.
79
80     - o :: Unknown (this key is new to the system)
81     - i :: The key is invalid (e.g. due to a missing self-signature)
82     - d :: The key has been disabled
83            (deprecated - use the 'D' in field 12 instead)
84     - r :: The key has been revoked
85     - e :: The key has expired
86     - - :: Unknown validity (i.e. no value assigned)
87     - q :: Undefined validity.  '-' and 'q' may safely be treated as
88            the same value for most purposes
89     - n :: The key is not valid
90     - m :: The key is marginal valid.
91     - f :: The key is fully valid
92     - u :: The key is ultimately valid.  This often means that the
93            secret key is available, but any key may be marked as
94            ultimately valid.
95     - w :: The key has a well known private part.
96     - s :: The key has special validity.  This means that it might be
97            self-signed and expected to be used in the STEED system.
98
99     If the validity information is given for a UID or UAT record, it
100     describes the validity calculated based on this user ID.  If given
101     for a key record it describes the validity taken from the best
102     rated user ID.
103
104     For X.509 certificates a 'u' is used for a trusted root
105     certificate (i.e. for the trust anchor) and an 'f' for all other
106     valid certificates.
107
108 *** Field 3 - Key length
109
110     The length of key in bits.
111
112 *** Field 4 - Public key algorithm
113
114     The values here are those from the OpenPGP specs or if they are
115     greather than 255 the algorithm ids as used by Libgcrypt.
116
117 *** Field 5 - KeyID
118
119     This is the 64 bit keyid as specified by OpenPGP and the last 64
120     bit of the SHA-1 fingerprint of an X.509 certifciate.
121
122 *** Field 6 - Creation date
123
124     The creation date of the key is given in UTC.  For UID and UAT
125     records, this is used for the self-signature date.  Note that the
126     date is usually printed in seconds since epoch, however, we are
127     migrating to an ISO 8601 format (e.g. "19660205T091500").  This is
128     currently only relevant for X.509.  A simple way to detect the new
129     format is to scan for the 'T'.  Note that old versions of gpg
130     without using the =--fixed-list-mode= option used a "yyyy-mm-tt"
131     format.
132
133 *** Field 7 - Expiration date
134
135     Key or UID/UAT expiration date or empty if it does not expire.
136
137 *** Field 8 - Certificate S/N, UID hash, trust signature info
138
139     Used for serial number in crt records.  For UID and UAT records,
140     this is a hash of the user ID contents used to represent that
141     exact user ID.  For trust signatures, this is the trust depth
142     separated by the trust value by a space.
143
144 *** Field 9 -  Ownertrust
145
146     This is only used on primary keys.  This is a single letter, but
147     be prepared that additional information may follow in future
148     versions.  For trust signatures with a regular expression, this is
149     the regular expression value, quoted as in field 10.
150
151 *** Field 10 - User-ID
152     The value is quoted like a C string to avoid control characters
153     (the colon is quoted =\x3a=).  For a "pub" record this field is
154     not used on --fixed-list-mode.  A UAT record puts the attribute
155     subpacket count here, a space, and then the total attribute
156     subpacket size.  In gpgsm the issuer name comes here.  A FPR
157     record stores the fingerprint here.  The fingerprint of a
158     revocation key is stored here.
159 *** Field 11 - Signature class
160
161     Signature class as per RFC-4880.  This is a 2 digit hexnumber
162     followed by either the letter 'x' for an exportable signature or
163     the letter 'l' for a local-only signature.  The class byte of an
164     revocation key is also given here, 'x' and 'l' is used the same
165     way.  This field if not used for X.509.
166
167 *** Field 12 - Key capabilities
168
169     The defined capabilities are:
170
171     - e :: Encrypt
172     - s :: Sign
173     - c :: Certify
174     - a :: Authentication
175     - ? :: Unknown capability
176
177     A key may have any combination of them in any order.  In addition
178     to these letters, the primary key has uppercase versions of the
179     letters to denote the _usable_ capabilities of the entire key, and
180     a potential letter 'D' to indicate a disabled key.
181
182 *** Field 13 - Issuer certificate fingerprint or other info
183
184     Used in FPR records for S/MIME keys to store the fingerprint of
185     the issuer certificate.  This is useful to build the certificate
186     path based on certificates stored in the local key database it is
187     only filled if the issuer certificate is available. The root has
188     been reached if this is the same string as the fingerprint. The
189     advantage of using this value is that it is guaranteed to have
190     been been build by the same lookup algorithm as gpgsm uses.
191
192     For "uid" records this field lists the preferences in the same way
193     gpg's --edit-key menu does.
194
195     For "sig" records, this is the fingerprint of the key that issued
196     the signature.  Note that this is only filled in if the signature
197     verified correctly.  Note also that for various technical reasons,
198     this fingerprint is only available if --no-sig-cache is used.
199
200 *** Field 14 - Flag field
201
202     Flag field used in the --edit menu output
203
204 *** Field 15 - S/N of a token
205
206     Used in sec/ssb to print the serial number of a token (internal
207     protect mode 1002) or a '#' if that key is a simple stub (internal
208     protect mode 1001).  If the option --with-secret is used and a
209     secret key is available for the public key, a '+' indicates this.
210
211 *** Field 16 - Hash algorithm
212
213     For sig records, this is the used hash algorithm.  For example:
214     2 = SHA-1, 8 = SHA-256.
215
216 *** Field 17 - Curve name
217
218     For pub, sub, sec, and ssb records this field is used for the ECC
219     curve name.
220
221 ** Special fields
222
223 *** PKD - Public key data
224
225     If field 1 has the tag "pkd", a listing looks like this:
226 #+begin_example
227 pkd:0:1024:B665B1435F4C2 .... FF26ABB:
228     !  !   !-- the value
229     !  !------ for information number of bits in the value
230     !--------- index (eg. DSA goes from 0 to 3: p,q,g,y)
231 #+end_example
232
233 *** TFS - TOFU statistics
234
235     This field may follows a UID record to convey information about
236     the TOFU database.  The information is similar to a TOFU_STATS
237     status line.
238
239     - Field 2 :: tfs record version (must be 1)
240     - Field 3 :: validity -  A number with validity code.
241     - Field 4 :: signcount - The number of signatures seen.
242     - Field 5 :: encrcount - The number of encryptions done.
243     - Field 6 :: policy - A string with the policy
244     - Field 7 :: signture-first-seen - a timestamp or 0 if not known.
245     - Field 8 :: signature-most-recent-seen - a timestamp or 0 if not known.
246     - Field 9 :: encryption-first-done - a timestamp or 0 if not known.
247     - Field 10 :: encryption-most-recent-done - a timestamp or 0 if not known.
248
249 *** TRU - Trust database information
250     Example for a "tru" trust base record:
251 #+begin_example
252     tru:o:0:1166697654:1:3:1:5
253 #+end_example
254
255     - Field 2 :: Reason for staleness of trust.  If this field is
256                  empty, then the trustdb is not stale.  This field may
257                  have multiple flags in it:
258
259                  - o :: Trustdb is old
260                  - t :: Trustdb was built with a different trust model
261                         than the one we are using now.
262
263     - Field 3 :: Trust model
264
265                  - 0 :: Classic trust model, as used in PGP 2.x.
266                  - 1 :: PGP trust model, as used in PGP 6 and later.
267                         This is the same as the classic trust model,
268                         except for the addition of trust signatures.
269
270                  GnuPG before version 1.4 used the classic trust model
271                  by default. GnuPG 1.4 and later uses the PGP trust
272                  model by default.
273
274     - Field 4 :: Date trustdb was created in seconds since Epoch.
275     - Field 5 :: Date trustdb will expire in seconds since Epoch.
276     - Field 6 :: Number of marginally trusted users to introduce a new
277                  key signer (gpg's option --marginals-needed).
278     - Field 7 :: Number of completely trusted users to introduce a new
279                  key signer.  (gpg's option --completes-needed)
280
281     - Field 8 :: Maximum depth of a certification chain. (gpg's option
282                  --max-cert-depth)
283
284 *** SPK - Signature subpacket records
285
286     - Field 2 :: Subpacket number as per RFC-4880 and later.
287     - Field 3 :: Flags in hex.  Currently the only two bits assigned
288                  are 1, to indicate that the subpacket came from the
289                  hashed part of the signature, and 2, to indicate the
290                  subpacket was marked critical.
291     - Field 4 :: Length of the subpacket.  Note that this is the
292                  length of the subpacket, and not the length of field
293                  5 below.  Due to the need for %-encoding, the length
294                  of field 5 may be up to 3x this value.
295     - Field 5 :: The subpacket data.  Printable ASCII is shown as
296                  ASCII, but other values are rendered as %XX where XX
297                  is the hex value for the byte.
298
299 *** CFG - Configuration data
300
301     --list-config outputs information about the GnuPG configuration
302     for the benefit of frontends or other programs that call GnuPG.
303     There are several list-config items, all colon delimited like the
304     rest of the --with-colons output.  The first field is always "cfg"
305     to indicate configuration information.  The second field is one of
306     (with examples):
307
308     - version :: The third field contains the version of GnuPG.
309
310                  : cfg:version:1.3.5
311
312     - pubkey :: The third field contains the public key algorithms
313                 this version of GnuPG supports, separated by
314                 semicolons.  The algorithm numbers are as specified in
315                 RFC-4880.  Note that in contrast to the --status-fd
316                 interface these are _not_ the Libgcrypt identifiers.
317                 Using =pubkeyname= prints names instead of numbers.
318
319                  : cfg:pubkey:1;2;3;16;17
320
321     - cipher :: The third field contains the symmetric ciphers this
322                 version of GnuPG supports, separated by semicolons.
323                 The cipher numbers are as specified in RFC-4880.
324                 Using =ciphername= prints names instead of numbers.
325
326                  : cfg:cipher:2;3;4;7;8;9;10
327
328     - digest :: The third field contains the digest (hash) algorithms
329                 this version of GnuPG supports, separated by
330                 semicolons.  The digest numbers are as specified in
331                 RFC-4880.  Using =digestname= prints names instead of
332                 numbers.
333
334                  : cfg:digest:1;2;3;8;9;10
335
336     - compress :: The third field contains the compression algorithms
337                   this version of GnuPG supports, separated by
338                   semicolons.  The algorithm numbers are as specified
339                   in RFC-4880.
340
341                  : cfg:compress:0;1;2;3
342
343     - group :: The third field contains the name of the group, and the
344                fourth field contains the values that the group expands
345                to, separated by semicolons.
346
347                For example, a group of:
348                  : group mynames = paige 0x12345678 joe patti
349                would result in:
350                  : cfg:group:mynames:patti;joe;0x12345678;paige
351
352     - curve :: The third field contains the curve names this version
353                of GnuPG supports, separated by semicolons. Using
354                =curveoid= prints OIDs instead of numbers.
355
356                  : cfg:curve:ed25519;nistp256;nistp384;nistp521
357
358
359 * Format of the --status-fd output
360
361   Every line is prefixed with "[GNUPG:] ", followed by a keyword with
362   the type of the status line and some arguments depending on the type
363   (maybe none); an application should always be willing to ignore
364   unknown keywords that may be emitted by future versions of GnuPG.
365   Also, new versions of GnuPG may add arguments to existing keywords.
366   Any additional arguments should be ignored for forward-compatibility.
367
368 ** General status codes
369 *** NEWSIG [<signers_uid>]
370     Is issued right before a signature verification starts.  This is
371     useful to define a context for parsing ERROR status messages.
372     arguments are currently defined.  If SIGNERS_UID is given and is
373     not "-" this is the percent escape value of the OpenPGP Signer's
374     User ID signature sub-packet.
375
376 *** GOODSIG  <long_keyid_or_fpr>  <username>
377     The signature with the keyid is good.  For each signature only one
378     of the codes GOODSIG, BADSIG, EXPSIG, EXPKEYSIG, REVKEYSIG or
379     ERRSIG will be emitted.  In the past they were used as a marker
380     for a new signature; new code should use the NEWSIG status
381     instead.  The username is the primary one encoded in UTF-8 and %XX
382     escaped. The fingerprint may be used instead of the long keyid if
383     it is available.  This is the case with CMS and might eventually
384     also be available for OpenPGP.
385
386 *** EXPSIG  <long_keyid_or_fpr>  <username>
387     The signature with the keyid is good, but the signature is
388     expired. The username is the primary one encoded in UTF-8 and %XX
389     escaped. The fingerprint may be used instead of the long keyid if
390     it is available.  This is the case with CMS and might eventually
391     also be available for OpenPGP.
392
393 *** EXPKEYSIG  <long_keyid_or_fpr> <username>
394     The signature with the keyid is good, but the signature was made
395     by an expired key. The username is the primary one encoded in
396     UTF-8 and %XX escaped.  The fingerprint may be used instead of the
397     long keyid if it is available.  This is the case with CMS and
398     might eventually also be available for OpenPGP.
399
400 *** REVKEYSIG  <long_keyid_or_fpr>  <username>
401     The signature with the keyid is good, but the signature was made
402     by a revoked key. The username is the primary one encoded in UTF-8
403     and %XX escaped. The fingerprint may be used instead of the long
404     keyid if it is available.  This is the case with CMS and might
405     eventually also beñ available for OpenPGP.
406
407 *** BADSIG  <long_keyid_or_fpr>  <username>
408     The signature with the keyid has not been verified okay.  The
409     username is the primary one encoded in UTF-8 and %XX escaped. The
410     fingerprint may be used instead of the long keyid if it is
411     available.  This is the case with CMS and might eventually also be
412     available for OpenPGP.
413
414 *** ERRSIG  <keyid>  <pkalgo> <hashalgo> <sig_class> <time> <rc>
415     It was not possible to check the signature.  This may be caused by
416     a missing public key or an unsupported algorithm.  A RC of 4
417     indicates unknown algorithm, a 9 indicates a missing public
418     key. The other fields give more information about this signature.
419     sig_class is a 2 byte hex-value.  The fingerprint may be used
420     instead of the keyid if it is available.  This is the case with
421     gpgsm and might eventually also be available for OpenPGP.
422
423     Note, that TIME may either be the number of seconds since Epoch or
424     an ISO 8601 string.  The latter can be detected by the presence of
425     the letter 'T'.
426
427 *** VALIDSIG <args>
428
429     The args are:
430
431     - <fingerprint_in_hex>
432     - <sig_creation_date>
433     - <sig-timestamp>
434     - <expire-timestamp>
435     - <sig-version>
436     - <reserved>
437     - <pubkey-algo>
438     - <hash-algo>
439     - <sig-class>
440     - [ <primary-key-fpr> ]
441
442     This status indicates that the signature is cryptographically
443     valid. This is similar to GOODSIG, EXPSIG, EXPKEYSIG, or REVKEYSIG
444     (depending on the date and the state of the signature and signing
445     key) but has the fingerprint as the argument. Multiple status
446     lines (VALIDSIG and the other appropriate *SIG status) are emitted
447     for a valid signature.  All arguments here are on one long line.
448     sig-timestamp is the signature creation time in seconds after the
449     epoch. expire-timestamp is the signature expiration time in
450     seconds after the epoch (zero means "does not
451     expire"). sig-version, pubkey-algo, hash-algo, and sig-class (a
452     2-byte hex value) are all straight from the signature packet.
453     PRIMARY-KEY-FPR is the fingerprint of the primary key or identical
454     to the first argument.  This is useful to get back to the primary
455     key without running gpg again for this purpose.
456
457     The primary-key-fpr parameter is used for OpenPGP and not
458     available for CMS signatures.  The sig-version as well as the sig
459     class is not defined for CMS and currently set to 0 and 00.
460
461     Note, that *-TIMESTAMP may either be a number of seconds since
462     Epoch or an ISO 8601 string which can be detected by the presence
463     of the letter 'T'.
464
465 *** SIG_ID  <radix64_string>  <sig_creation_date>  <sig-timestamp>
466     This is emitted only for signatures of class 0 or 1 which have
467     been verified okay.  The string is a signature id and may be used
468     in applications to detect replay attacks of signed messages.  Note
469     that only DLP algorithms give unique ids - others may yield
470     duplicated ones when they have been created in the same second.
471
472     Note, that SIG-TIMESTAMP may either be a number of seconds since
473     Epoch or an ISO 8601 string which can be detected by the presence
474     of the letter 'T'.
475
476 *** ENC_TO  <long_keyid>  <keytype>  <keylength>
477     The message is encrypted to this LONG_KEYID.  KEYTYPE is the
478     numerical value of the public key algorithm or 0 if it is not
479     known, KEYLENGTH is the length of the key or 0 if it is not known
480     (which is currently always the case).  Gpg prints this line
481     always; Gpgsm only if it knows the certificate.
482
483 *** BEGIN_DECRYPTION
484     Mark the start of the actual decryption process.  This is also
485     emitted when in --list-only mode.
486 *** END_DECRYPTION
487     Mark the end of the actual decryption process.  This are also
488     emitted when in --list-only mode.
489 *** DECRYPTION_INFO <mdc_method> <sym_algo>
490     Print information about the symmetric encryption algorithm and the
491     MDC method.  This will be emitted even if the decryption fails.
492
493 *** DECRYPTION_FAILED
494     The symmetric decryption failed - one reason could be a wrong
495     passphrase for a symmetrical encrypted message.
496
497 *** DECRYPTION_OKAY
498     The decryption process succeeded.  This means, that either the
499     correct secret key has been used or the correct passphrase for a
500     symmetric encrypted message was given.  The program itself may
501     return an errorcode because it may not be possible to verify a
502     signature for some reasons.
503
504 *** SESSION_KEY <algo>:<hexdigits>
505     The session key used to decrypt the message.  This message will
506     only be emitted if the option --show-session-key is used.  The
507     format is suitable to be passed as value for the option
508     --override-session-key.  It is not an indication that the
509     decryption will or has succeeded.
510
511 *** BEGIN_ENCRYPTION  <mdc_method> <sym_algo>
512     Mark the start of the actual encryption process.
513
514 *** END_ENCRYPTION
515     Mark the end of the actual encryption process.
516
517 *** FILE_START <what> <filename>
518     Start processing a file <filename>.  <what> indicates the performed
519     operation:
520     - 1 :: verify
521     - 2 :: encrypt
522     - 3 :: decrypt
523
524 *** FILE_DONE
525     Marks the end of a file processing which has been started
526     by FILE_START.
527
528 *** BEGIN_SIGNING
529     Mark the start of the actual signing process. This may be used as
530     an indication that all requested secret keys are ready for use.
531
532 *** ALREADY_SIGNED <long-keyid>
533     Warning: This is experimental and might be removed at any time.
534
535 *** SIG_CREATED <type> <pk_algo> <hash_algo> <class> <timestamp> <keyfpr>
536     A signature has been created using these parameters.
537     Values for type <type> are:
538       - D :: detached
539       - C :: cleartext
540       - S :: standard
541     (only the first character should be checked)
542
543     <class> are 2 hex digits with the OpenPGP signature class.
544
545     Note, that TIMESTAMP may either be a number of seconds since Epoch
546     or an ISO 8601 string which can be detected by the presence of the
547     letter 'T'.
548
549 *** NOTATION_
550     There are actually three related status codes to convey notation
551     data:
552
553     - NOTATION_NAME <name>
554     - NOTATION_FLAGS <critical> <human_readable>
555     - NOTATION_DATA <string>
556
557     <name> and <string> are %XX escaped.  The data may be split among
558     several NOTATION_DATA lines.  NOTATION_FLAGS is emitted after
559     NOTATION_NAME and gives the critical and human readable flags;
560     the flag values are either 0 or 1.
561
562 *** POLICY_URL <string>
563     Note that URL in <string> is %XX escaped.
564
565 *** PLAINTEXT <format> <timestamp> <filename>
566     This indicates the format of the plaintext that is about to be
567     written.  The format is a 1 byte hex code that shows the format of
568     the plaintext: 62 ('b') is binary data, 74 ('t') is text data with
569     no character set specified, and 75 ('u') is text data encoded in
570     the UTF-8 character set.  The timestamp is in seconds since the
571     epoch.  If a filename is available it gets printed as the third
572     argument, percent-escaped as usual.
573
574 *** PLAINTEXT_LENGTH <length>
575     This indicates the length of the plaintext that is about to be
576     written.  Note that if the plaintext packet has partial length
577     encoding it is not possible to know the length ahead of time.  In
578     that case, this status tag does not appear.
579
580 *** ATTRIBUTE <arguments>
581     The list or arguments are:
582     - <fpr>
583     - <octets>
584     - <type>
585     - <index>
586     - <count>
587     - <timestamp>
588     - <expiredate>
589     - <flags>
590
591     This is one long line issued for each attribute subpacket when an
592     attribute packet is seen during key listing.  <fpr> is the
593     fingerprint of the key.  <octets> is the length of the attribute
594     subpacket.  <type> is the attribute type (e.g. 1 for an image).
595     <index> and <count> indicate that this is the N-th indexed
596     subpacket of count total subpackets in this attribute packet.
597     <timestamp> and <expiredate> are from the self-signature on the
598     attribute packet.  If the attribute packet does not have a valid
599     self-signature, then the timestamp is 0.  <flags> are a bitwise OR
600     of:
601     - 0x01 :: this attribute packet is a primary uid
602     - 0x02 :: this attribute packet is revoked
603     - 0x04 :: this attribute packet is expired
604
605 *** SIG_SUBPACKET <type> <flags> <len> <data>
606     This indicates that a signature subpacket was seen.  The format is
607     the same as the "spk" record above.
608
609 ** Key related
610 *** INV_RECP, INV_SGNR
611     The two similar status codes:
612
613     - INV_RECP <reason> <requested_recipient>
614     - INV_SGNR <reason> <requested_sender>
615
616     are issued for each unusable recipient/sender. The reasons codes
617     currently in use are:
618
619        -  0 :: No specific reason given
620        -  1 :: Not Found
621        -  2 :: Ambigious specification
622        -  3 :: Wrong key usage
623        -  4 :: Key revoked
624        -  5 :: Key expired
625        -  6 :: No CRL known
626        -  7 :: CRL too old
627        -  8 :: Policy mismatch
628        -  9 :: Not a secret key
629        - 10 :: Key not trusted
630        - 11 :: Missing certificate
631        - 12 :: Missing issuer certificate
632        - 13 :: Key disabled
633        - 14 :: Syntax error in specification
634
635     If no specific reason was given a previously emitted status code
636     KEY_CONSIDERED may be used to analyzed the problem.
637
638     Note that for historical reasons the INV_RECP status is also used
639     for gpgsm's SIGNER command where it relates to signer's of course.
640     Newer GnuPG versions are using INV_SGNR; applications should
641     ignore the INV_RECP during the sender's command processing once
642     they have seen an INV_SGNR.  Different codes are used so that they
643     can be distinguish while doing an encrypt+sign operation.
644
645 *** NO_RECP <reserved>
646     Issued if no recipients are usable.
647
648 *** NO_SGNR <reserved>
649     Issued if no senders are usable.
650
651 *** KEY_CONSIDERED <fpr> <flags>
652     Issued to explian the lookup of a key.  FPR is the hexified
653     fingerprint of the primary key.  The bit values for FLAGS are:
654
655     - 1 :: The key has not been selected.
656     - 2 :: All subkeys of the key are expired or have been revoked.
657
658 *** KEYEXPIRED <expire-timestamp>
659     The key has expired.  expire-timestamp is the expiration time in
660     seconds since Epoch.  This status line is not very useful because
661     it will also be emitted for expired subkeys even if this subkey is
662     not used.  To check whether a key used to sign a message has
663     expired, the EXPKEYSIG status line is to be used.
664
665     Note, that the TIMESTAMP may either be a number of seconds since
666     Epoch or an ISO 8601 string which can be detected by the presence
667     of the letter 'T'.
668
669 *** KEYREVOKED
670     The used key has been revoked by its owner.  No arguments yet.
671
672 *** NO_PUBKEY  <long keyid>
673     The public key is not available
674
675 *** NO_SECKEY  <long keyid>
676     The secret key is not available
677
678 *** KEY_CREATED <type> <fingerprint> [<handle>]
679     A key has been created.  Values for <type> are:
680       - B :: primary and subkey
681       - P :: primary
682       - S :: subkey
683     The fingerprint is one of the primary key for type B and P and the
684     one of the subkey for S.  Handle is an arbitrary non-whitespace
685     string used to match key parameters from batch key creation run.
686
687 *** KEY_NOT_CREATED [<handle>]
688     The key from batch run has not been created due to errors.
689
690 *** TRUST_
691     These are several similar status codes:
692
693     - TRUST_UNDEFINED <error_token>
694     - TRUST_NEVER     <error_token>
695     - TRUST_MARGINAL  [0  [<validation_model>]]
696     - TRUST_FULLY     [0  [<validation_model>]]
697     - TRUST_ULTIMATE  [0  [<validation_model>]]
698
699     For good signatures one of these status lines are emitted to
700     indicate the validity of the key used to create the signature.
701     The error token values are currently only emitted by gpgsm.
702
703     VALIDATION_MODEL describes the algorithm used to check the
704     validity of the key.  The defaults are the standard Web of Trust
705     model for gpg and the the standard X.509 model for gpgsm.  The
706     defined values are
707
708        - pgp   :: The standard PGP WoT.
709        - shell :: The standard X.509 model.
710        - chain :: The chain model.
711        - steed :: The STEED model.
712        - tofu  :: The TOFU model
713
714     Note that the term =TRUST_= in the status names is used for
715     historic reasons; we now speak of validity.
716
717 *** TOFU_USER <fingerprint_in_hex> <mbox>
718
719     This status identifies the key and the userid for all following
720     Tofu information.  The fingerprint is the fingerprint of the
721     primary key and the mbox is in general the addr-spec part of the
722     userid encoded in UTF-8 and percent escaped.  The fingerprint is
723     identical for all TOFU_USER lines up to a NEWSIG line.
724
725 *** TOFU_STATS <MANY_ARGS>
726
727     Statistics for the current user id.
728
729     The <MANY_ARGS> are the usual space delimited arguments.  Here we
730     have too many of them to fit on one printed line and thus they are
731     given on 3 printed lines:
732
733     : <summary> <sign-count> <encryption-count>
734     : [<policy> [<tm1> <tm2> <tm3> <tm4>
735     : [<validity> [<sign-days> <encrypt-days>]]]]
736
737     Values for SUMMARY are:
738     - 0 :: attention, an interaction with the user is required (conflict)
739     - 1 :: key with no verification/encryption history
740     - 2 :: key with little history
741     - 3 :: key with enough history for basic trust
742     - 4 :: key with a lot of history
743
744     Values for POLICY are:
745     - none    :: No Policy set
746     - auto    :: Policy is "auto"
747     - good    :: Policy is "good"
748     - bad     :: Policy is "bad"
749     - ask     :: Policy is "ask"
750     - unknown :: Policy is "unknown" (TOFU information does not
751                  contribute to the key's validity)
752
753     TM1 is the time the first message was verified.  TM2 is the time
754     the most recent message was verified.  TM3 is the time the first
755     message was encrypted.  TM4 is the most recent encryption. All may
756     either be seconds since Epoch or an ISO time string
757     (yyyymmddThhmmss).
758
759     VALIDITY is the same as SUMMARY with the exception that VALIDITY
760     doesn't reflect whether the key needs attention.  That is it never
761     takes on value 0.  Instead, if there is a conflict, VALIDITY still
762     reflects the key's validity (values: 1-4).
763
764     SUMMARY values use the euclidean distance (m = sqrt(a² + b²)) rather
765     then the sum of the magnitudes (m = a + b) to ensure a balance between
766     verified signatures and encrypted messages.
767
768     Values are calculated based on the number of days where a key was used
769     for verifying a signature or to encrypt to it.
770     The ranges for the values are:
771
772     - 1 :: signature_days + encryption_days == 0
773     - 2 :: 1 <= sqrt(signature_days² + encryption_days²) < 8
774     - 3 :: 8 <= sqrt(signature_days² + encryption_days²) < 42
775     - 4 :: sqrt(signature_days² + encryption_days²) >= 42
776
777     SIGN-COUNT and ENCRYPTION-COUNT are the number of messages that we
778     have seen that have been signed by this key / encryption to this
779     key.
780
781     SIGN-DAYS and ENCRYPTION-DAYS are similar, but the number of days
782     (in UTC) on which we have seen messages signed by this key /
783     encrypted to this key.
784
785 *** TOFU_STATS_SHORT <long_string>
786
787     Information about the TOFU binding for the signature.
788     Example: "15 signatures verified. 10 messages encrypted"
789
790 *** TOFU_STATS_LONG <long_string>
791
792     Information about the TOFU binding for the signature in verbose
793     format.  The LONG_STRING is percent escaped.
794     Example: 'Verified 9 messages signed by "Werner Koch
795     (dist sig)" in the past 3 minutes, 40 seconds.  The most
796     recent message was verified 4 seconds ago.'
797
798 *** PKA_TRUST_
799     This is is one:
800
801     - PKA_TRUST_GOOD <addr-spec>
802     - PKA_TRUST_BAD  <addr-spec>
803
804     Depending on the outcome of the PKA check one of the above status
805     codes is emitted in addition to a =TRUST_*= status.
806
807 ** Remote control
808 *** GET_BOOL, GET_LINE, GET_HIDDEN, GOT_IT
809
810     These status line are used with --command-fd for interactive
811     control of the process.
812
813 *** USERID_HINT <long main keyid> <string>
814     Give a hint about the user ID for a certain keyID.
815
816 *** NEED_PASSPHRASE <long keyid> <long main keyid> <keytype> <keylength>
817     Issued whenever a passphrase is needed.  KEYTYPE is the numerical
818     value of the public key algorithm or 0 if this is not applicable,
819     KEYLENGTH is the length of the key or 0 if it is not known (this
820     is currently always the case).
821
822 *** NEED_PASSPHRASE_SYM <cipher_algo> <s2k_mode> <s2k_hash>
823     Issued whenever a passphrase for symmetric encryption is needed.
824
825 *** NEED_PASSPHRASE_PIN <card_type> <chvno> [<serialno>]
826     Issued whenever a PIN is requested to unlock a card.
827
828 *** MISSING_PASSPHRASE
829     No passphrase was supplied.  An application which encounters this
830     message may want to stop parsing immediately because the next
831     message will probably be a BAD_PASSPHRASE.  However, if the
832     application is a wrapper around the key edit menu functionality it
833     might not make sense to stop parsing but simply ignoring the
834     following BAD_PASSPHRASE.
835
836 *** BAD_PASSPHRASE <long keyid>
837     The supplied passphrase was wrong or not given.  In the latter
838     case you may have seen a MISSING_PASSPHRASE.
839
840 *** GOOD_PASSPHRASE
841     The supplied passphrase was good and the secret key material
842     is therefore usable.
843
844 ** Import/Export
845 *** IMPORT_CHECK <long keyid> <fingerprint> <user ID>
846     This status is emitted in interactive mode right before
847     the "import.okay" prompt.
848
849 *** IMPORTED   <long keyid>  <username>
850     The keyid and name of the signature just imported
851
852 *** IMPORT_OK  <reason> [<fingerprint>]
853     The key with the primary key's FINGERPRINT has been imported.
854     REASON flags are:
855
856     - 0 :: Not actually changed
857     - 1 :: Entirely new key.
858     - 2 :: New user IDs
859     - 4 :: New signatures
860     - 8 :: New subkeys
861     - 16 :: Contains private key.
862
863     The flags may be ORed.
864
865 *** IMPORT_PROBLEM <reason> [<fingerprint>]
866     Issued for each import failure.  Reason codes are:
867
868     - 0 :: No specific reason given.
869     - 1 :: Invalid Certificate.
870     - 2 :: Issuer Certificate missing.
871     - 3 :: Certificate Chain too long.
872     - 4 :: Error storing certificate.
873
874 *** IMPORT_RES <args>
875     Final statistics on import process (this is one long line). The
876     args are a list of unsigned numbers separated by white space:
877
878     - <count>
879     - <no_user_id>
880     - <imported>
881     - always 0 (formerly used for the number of RSA keys)
882     - <unchanged>
883     - <n_uids>
884     - <n_subk>
885     - <n_sigs>
886     - <n_revoc>
887     - <sec_read>
888     - <sec_imported>
889     - <sec_dups>
890     - <skipped_new_keys>
891     - <not_imported>
892     - <skipped_v3_keys>
893
894 *** EXPORTED  <fingerprint>
895     The key with <fingerprint> has been exported.  The fingerprint is
896     the fingerprint of the primary key even if the primary key has
897     been replaced by a stub key during secret key export.
898
899 *** EXPORT_RES <args>
900
901     Final statistics on export process (this is one long line). The
902     args are a list of unsigned numbers separated by white space:
903
904     - <count>
905     - <secret_count>
906     - <exported>
907
908
909 ** Smartcard related
910 *** CARDCTRL <what> [<serialno>]
911     This is used to control smartcard operations.  Defined values for
912     WHAT are:
913
914       - 1 :: Request insertion of a card.  Serialnumber may be given
915              to request a specific card.  Used by gpg 1.4 w/o
916              scdaemon
917       - 2 :: Request removal of a card.  Used by gpg 1.4 w/o scdaemon.
918       - 3 :: Card with serialnumber detected
919       - 4 :: No card available
920       - 5 :: No card reader available
921       - 6 :: No card support available
922       - 7 :: Card is in termination state
923
924 *** SC_OP_FAILURE [<code>]
925     An operation on a smartcard definitely failed.  Currently there is
926     no indication of the actual error code, but application should be
927     prepared to later accept more arguments.  Defined values for
928     <code> are:
929
930       - 0 :: unspecified error (identically to a missing CODE)
931       - 1 :: canceled
932       - 2 :: bad PIN
933
934 *** SC_OP_SUCCESS
935     A smart card operaion succeeded.  This status is only printed for
936     certain operation and is mostly useful to check whether a PIN
937     change really worked.
938
939 ** Miscellaneous status codes
940 *** NODATA  <what>
941     No data has been found.  Codes for WHAT are:
942
943     - 1 :: No armored data.
944     - 2 :: Expected a packet but did not found one.
945     - 3 :: Invalid packet found, this may indicate a non OpenPGP
946            message.
947     - 4 :: Signature expected but not found
948
949     You may see more than one of these status lines.
950
951 *** UNEXPECTED <what>
952     Unexpected data has been encountered.  Codes for WHAT are:
953     - 0 :: Not further specified
954     - 1 :: Corrupted message structure
955
956 *** TRUNCATED <maxno>
957     The output was truncated to MAXNO items.  This status code is
958     issued for certain external requests.
959
960 *** ERROR <error location> <error code> [<more>]
961     This is a generic error status message, it might be followed by
962     error location specific data. <error code> and <error_location>
963     should not contain spaces.  The error code is a either a string
964     commencing with a letter or such a string prefixed with a
965     numerical error code and an underscore; e.g.: "151011327_EOF".
966 *** WARNING <location> <error code> [<text>]
967     This is a generic warning status message, it might be followed by
968     error location specific data. <error code> and <location>
969     should not contain spaces.  The error code is a either a string
970     commencing with a letter or such a string prefixed with a
971     numerical error code and an underscore; e.g.: "151011327_EOF".
972 *** SUCCESS [<location>]
973     Positive confirmation that an operation succeeded.  It is used
974     similar to ISO-C's EXIT_SUCCESS.  <location> is optional but if
975     given should not contain spaces.  Used only with a few commands.
976
977 *** FAILURE <location> <error_code>
978     This is the counterpart to SUCCESS and used to indicate a program
979     failure.  It is used similar to ISO-C's EXIT_FAILURE but allows
980     conveying more information, in particular a gpg-error error code.
981     That numerical error code may optionally have a suffix made of an
982     underscore and a string with an error symbol like "151011327_EOF".
983     A dash may be used instead of <location>.
984
985 *** BADARMOR
986     The ASCII armor is corrupted.  No arguments yet.
987
988 *** DELETE_PROBLEM <reason_code>
989     Deleting a key failed.  Reason codes are:
990     - 1 :: No such key
991     - 2 :: Must delete secret key first
992     - 3 :: Ambigious specification
993     - 4 :: Key is stored on a smartcard.
994
995 *** PROGRESS <what> <char> <cur> <total> [<units>]
996     Used by the primegen and Public key functions to indicate
997     progress.  <char> is the character displayed with no --status-fd
998     enabled, with the linefeed replaced by an 'X'.  <cur> is the
999     current amount done and <total> is amount to be done; a <total> of
1000     0 indicates that the total amount is not known. The condition
1001       :       TOTAL && CUR == TOTAL
1002     may be used to detect the end of an operation.
1003
1004     Well known values for WHAT are:
1005
1006            - pk_dsa   :: DSA key generation
1007            - pk_elg   :: Elgamal key generation
1008            - primegen :: Prime generation
1009            - need_entropy :: Waiting for new entropy in the RNG
1010            - tick :: Generic tick without any special meaning - useful
1011                      for letting clients know that the server is still
1012                      working.
1013            - starting_agent :: A gpg-agent was started because it is not
1014                                 running as a daemon.
1015            - learncard :: Send by the agent and gpgsm while learing
1016                           the data of a smartcard.
1017            - card_busy :: A smartcard is still working
1018
1019     <units> is sometines used to describe the units for <current> and
1020     <total>.  For example "B", "KiB", or "MiB".
1021
1022 *** BACKUP_KEY_CREATED <fingerprint> <fname>
1023     A backup of a key identified by <fingerprint> has been writte to
1024     the file <fname>; <fname> is percent-escaped.
1025
1026 *** MOUNTPOINT <name>
1027     <name> is a percent-plus escaped filename describing the
1028     mountpoint for the current operation (e.g. used by "g13 --mount").
1029     This may either be the specified mountpoint or one randomly
1030     chosen by g13.
1031
1032 *** PINENTRY_LAUNCHED <pid>[:<extra>]
1033     This status line is emitted by gpg to notify a client that a
1034     Pinentry has been launched.  <pid> is the PID of the Pinentry.  It
1035     may be used to display a hint to the user but can't be used to
1036     synchronize with Pinentry.  Note that there is also an Assuan
1037     inquiry line with the same name used internally or, if enabled,
1038     send to the client instead of this status line.  Such an inquiry
1039     may be used to sync with Pinentry
1040
1041 ** Obsolete status codes
1042 *** SIGEXPIRED
1043     Removed on 2011-02-04.  This is deprecated in favor of KEYEXPIRED.
1044 *** RSA_OR_IDEA
1045     Obsolete.  This status message used to be emitted for requests to
1046     use the IDEA or RSA algorithms.  It has been dropped from GnuPG
1047     2.1 after the respective patents expired.
1048 *** SHM_INFO, SHM_GET, SHM_GET_BOOL, SHM_GET_HIDDEN
1049     These were used for the ancient shared memory based co-processing.
1050 *** BEGIN_STREAM, END_STREAM
1051     Used to issued by the experimental pipemode.
1052
1053
1054 * Format of the --attribute-fd output
1055
1056   When --attribute-fd is set, during key listings (--list-keys,
1057   --list-secret-keys) GnuPG dumps each attribute packet to the file
1058   descriptor specified.  --attribute-fd is intended for use with
1059   --status-fd as part of the required information is carried on the
1060   ATTRIBUTE status tag (see above).
1061
1062   The contents of the attribute data is specified by RFC 4880.  For
1063   convenience, here is the Photo ID format, as it is currently the
1064   only attribute defined:
1065
1066   - Byte 0-1 :: The length of the image header.  Due to a historical
1067                 accident (i.e. oops!) back in the NAI PGP days, this
1068                 is a little-endian number.  Currently 16 (0x10 0x00).
1069
1070   - Byte 2 :: The image header version.  Currently 0x01.
1071
1072   - Byte 3 :: Encoding format.  0x01 == JPEG.
1073
1074   - Byte 4-15 :: Reserved, and currently unused.
1075
1076   All other data after this header is raw image (JPEG) data.
1077
1078
1079 * Layout of the TrustDB
1080
1081   The TrustDB is built from fixed length records, where the first byte
1082   describes the record type.  All numeric values are stored in network
1083   byte order.  The length of each record is 40 bytes.  The first
1084   record of the DB is always of type 1 and this is the only record of
1085   this type.
1086
1087   The record types: directory(2), key(3), uid(4), pref(5), sigrec(6),
1088   and shadow directory(8) are not anymore used by version 2 of the
1089   TrustDB.
1090
1091 ** Record type 0
1092
1093    Unused record or deleted, can be reused for any purpose.  Such
1094    records should in general not exist because deleted records are of
1095    type 254 and kept in a linked list.
1096
1097 ** Version info (RECTYPE_VER, 1)
1098
1099    Version information for this TrustDB.  This is always the first
1100    record of the DB and the only one of this type.
1101
1102    - 1 u8 :: Record type (value: 1).
1103    - 3 byte :: Magic value ("gpg")
1104    - 1 u8 :: TrustDB version (value: 2).
1105    - 1 u8 :: =marginals=. How many marginal trusted keys are required.
1106    - 1 u8 :: =completes=. How many completely trusted keys are
1107              required.
1108    - 1 u8 :: =max_cert_depth=.  How deep is the WoT evaluated.  Along
1109              with =marginals= and =completes=, this value is used to
1110              check whether the cached validity value from a [FIXME
1111              dir] record can be used.
1112    - 1 u8 :: =trust_model=
1113    - 1 u8 :: =min_cert_level=
1114    - 2 byte :: Not used
1115    - 1 u32 :: =created=. Timestamp of trustdb creation.
1116    - 1 u32 :: =nextcheck=. Timestamp of last modification which may
1117               affect the validity of keys in the trustdb.  This value
1118               is checked against the validity timestamp in the dir
1119               records.
1120    - 1 u32 :: =reserved=.  Not used.
1121    - 1 u32 :: =reserved2=. Not used.
1122    - 1 u32 :: =firstfree=. Number of the record with the head record
1123               of the RECTYPE_FREE linked list.
1124    - 1 u32 :: =reserved3=. Not used.
1125    - 1 u32 :: =trusthashtbl=. Record number of the trusthashtable.
1126
1127
1128 ** Hash table (RECTYPE_HTBL, 10)
1129
1130    Due to the fact that we use fingerprints to lookup keys, we can
1131    implement quick access by some simple hash methods, and avoid the
1132    overhead of gdbm.  A property of fingerprints is that they can be
1133    used directly as hash values.  What we use is a dynamic multilevel
1134    architecture, which combines hash tables, record lists, and linked
1135    lists.
1136
1137    This record is a hash table of 256 entries with the property that
1138    all these records are stored consecutively to make one big
1139    table. The hash value is simple the 1st, 2nd, ... byte of the
1140    fingerprint (depending on the indirection level).
1141
1142    - 1 u8 :: Record type (value: 10).
1143    - 1 u8 :: Reserved
1144    - n u32 :: =recnum=.  A table with the hash table items fitting into
1145               this record.  =n= depends on the record length:
1146               $n=(reclen-2)/4$ which yields 9 for oure current record
1147               length of 40 bytes.
1148
1149    The total number of hash table records to form the table is:
1150    $m=(256+n-1)/n$.  This is 29 for our record length of 40.
1151
1152    To look up a key we use the first byte of the fingerprint to get
1153    the recnum from this hash table and then look up the addressed
1154    record:
1155
1156    - If that record is another hash table, we use 2nd byte to index
1157      that hash table and so on;
1158    - if that record is a hash list, we walk all entries until we find
1159      a matching one; or
1160    - if that record is a key record, we compare the fingerprint to
1161      decide whether it is the requested key;
1162
1163
1164 ** Hash list (RECTYPE_HLST, 11)
1165
1166    See hash table above on how it is used.  It may also be used for
1167    other purposes.
1168
1169    - 1 u8 :: Record type (value: 11).
1170    - 1 u8 :: Reserved.
1171    - 1 u32 :: =next=.  Record number of the next hash list record or 0
1172               if none.
1173    - n u32 :: =rnum=.  Array with record numbers to values.  With
1174               $n=(reclen-5)/5$ and our record length of 40, n is 7.
1175
1176 ** Trust record (RECTYPE_TRUST, 12)
1177
1178    - 1 u8 :: Record type (value: 12).
1179    - 1 u8 :: Reserved.
1180    - 20 byte :: =fingerprint=.
1181    - 1 u8 :: =ownertrust=.
1182    - 1 u8 :: =depth=.
1183    - 1 u8 :: =min_ownertrust=.
1184    - 1 byte :: Not used.
1185    - 1 u32 :: =validlist=.
1186    - 10 byte :: Not used.
1187
1188 ** Validity record (RECTYPE_VALID, 13)
1189
1190    - 1 u8 :: Record type (value: 13).
1191    - 1 u8 :: Reserved.
1192    - 20 byte :: =namehash=.
1193    - 1 u8 :: =validity=
1194    - 1 u32 :: =next=.
1195    - 1 u8 :: =full_count=.
1196    - 1 u8 :: =marginal_count=.
1197    - 11 byte :: Not used.
1198
1199 ** Free record (RECTYPE_FREE, 254)
1200
1201    All these records form a linked list of unused records in the TrustDB.
1202
1203    - 1 u8 :: Record type (value: 254)
1204    - 1 u8 :: Reserved.
1205    - 1 u32 :: =next=.  Record number of the next rcord of this type.
1206               The record number to the head of this linked list is
1207               stored in the version info record.
1208
1209
1210 * Database scheme for the TOFU info
1211
1212 #+begin_src sql
1213 --
1214 -- The VERSION table holds the version of our TOFU data structures.
1215 --
1216 CREATE TABLE version (
1217   version integer -- As of now this is always 1
1218 );
1219
1220 --
1221 -- The BINDINGS table associates mail addresses with keys.
1222 --
1223 CREATE TABLE bindings (
1224   oid integer primary key autoincrement,
1225   fingerprint text, -- The key's fingerprint in hex
1226   email text,       -- The normalized mail address destilled from user_id
1227   user_id text,     -- The unmodified user id
1228   time integer,     -- The time this binding was first observed.
1229   policy boolean check
1230        (policy in (1, 2, 3, 4, 5)), -- The trust policy with the values:
1231                                     --   1 := Auto
1232                                     --   2 := Good
1233                                     --   3 := Unknown
1234                                     --   4 := Bad
1235                                     --   5 := Ask
1236   conflict string,  -- NULL or a hex formatted fingerprint.
1237   unique (fingerprint, email)
1238 );
1239
1240 CREATE INDEX bindings_fingerprint_email on bindings (fingerprint, email);
1241 CREATE INDEX bindings_email on bindings (email);
1242
1243 --
1244 -- The SIGNATURES table records all data signatures we verified
1245 --
1246 CREATE TABLE signatures (
1247   binding integer not null, -- Link to bindings table,
1248                             -- references bindings.oid.
1249   sig_digest text,          -- The digest of the signed message.
1250   origin text,              -- String describing who initially fed
1251                             -- the signature to gpg (e.g. "email:claws").
1252   sig_time integer,         -- Timestamp from the signature.
1253   time integer,             -- Time this record was created.
1254   primary key (binding, sig_digest, origin)
1255 );
1256 #+end_src
1257
1258
1259 * GNU extensions to the S2K algorithm
1260
1261   1 octet  - S2K Usage: either 254 or 255.
1262   1 octet  - S2K Cipher Algo: 0
1263   1 octet  - S2K Specifier: 101
1264   3 octets - "GNU"
1265   1 octet  - GNU S2K Extension Number.
1266
1267   If such a GNU extension is used neither an IV nor any kind of
1268   checksum is used.  The defined GNU S2K Extension Numbers are:
1269
1270   - 1 :: Do not store the secret part at all.  No specific data
1271          follows.
1272
1273   - 2 :: A stub to access smartcards.  This data follows:
1274          - One octet with the length of the following serial number.
1275          - The serial number. Regardless of what the length octet
1276            indicates no more than 16 octets are stored.
1277
1278   Note that gpg stores the GNU S2K Extension Number internally as an
1279   S2K Specifier with an offset of 1000.
1280
1281
1282 * Keyserver helper message format
1283
1284   *This information is obsolete*
1285   (Keyserver helpers have been replaced by dirmngr)
1286
1287   The keyserver may be contacted by a Unix Domain socket or via TCP.
1288
1289   The format of a request is:
1290 #+begin_example
1291   command-tag
1292   "Content-length:" digits
1293   CRLF
1294 #+end_example
1295
1296   Where command-tag is
1297
1298 #+begin_example
1299   NOOP
1300   GET <user-name>
1301   PUT
1302   DELETE <user-name>
1303 #+end_example
1304
1305 The format of a response is:
1306
1307 #+begin_example
1308   "GNUPG/1.0" status-code status-text
1309   "Content-length:" digits
1310   CRLF
1311 #+end_example
1312 followed by <digits> bytes of data
1313
1314 Status codes are:
1315
1316   - 1xx :: Informational - Request received, continuing process
1317
1318   - 2xx :: Success - The action was successfully received, understood,
1319            and accepted
1320
1321   - 4xx :: Client Error - The request contains bad syntax or cannot be
1322            fulfilled
1323
1324   - 5xx :: Server Error - The server failed to fulfill an apparently
1325            valid request
1326
1327
1328 * Object identifiers
1329
1330   OIDs below the GnuPG arc:
1331
1332 #+begin_example
1333   1.3.6.1.4.1.11591.2          GnuPG
1334   1.3.6.1.4.1.11591.2.1          notation
1335   1.3.6.1.4.1.11591.2.1.1          pkaAddress
1336   1.3.6.1.4.1.11591.2.2          X.509 extensions
1337   1.3.6.1.4.1.11591.2.2.1          standaloneCertificate
1338   1.3.6.1.4.1.11591.2.2.2          wellKnownPrivateKey
1339   1.3.6.1.4.1.11591.2.12242973   invalid encoded OID
1340 #+end_example
1341
1342
1343
1344 * Debug flags
1345
1346 This tables gives the flag values for the --debug option along with
1347 the alternative names used by the components.
1348
1349 |       | gpg     | gpgsm   | agent   | scd     | dirmngr | g13     | wks     |
1350 |-------+---------+---------+---------+---------+---------+---------+---------|
1351 |     1 | packet  | x509    |         |         | x509    | mount   | mime    |
1352 |     2 | mpi     | mpi     | mpi     | mpi     |         |         | parser  |
1353 |     4 | crypto  | crypto  | crypto  | crypto  | crypto  | crypto  | crypto  |
1354 |     8 | filter  |         |         |         |         |         |         |
1355 |    16 | iobuf   |         |         |         | dns     |         |         |
1356 |    32 | memory  | memory  | memory  | memory  | memory  | memory  | memory  |
1357 |    64 | cache   | cache   | cache   | cache   | cache   |         |         |
1358 |   128 | memstat | memstat | memstat | memstat | memstat | memstat | memstat |
1359 |   256 | trust   |         |         |         |         |         |         |
1360 |   512 | hashing | hashing | hashing | hashing | hashing |         |         |
1361 |  1024 | ipc     | ipc     | ipc     | ipc     | ipc     | ipc     | ipc     |
1362 |  2048 |         |         |         | cardio  | network |         |         |
1363 |  4096 | clock   |         |         | reader  |         |         |         |
1364 |  8192 | lookup  |         |         |         | lookup  |         |         |
1365 | 16384 | extprog |         |         |         |         |         | extprog |
1366
1367 Description of some debug flags:
1368
1369   - cardio :: Used by scdaemon to trace the APDUs exchange with the
1370               card.
1371   - clock  :: Show execution times of certain functions.
1372   - crypto :: Trace crypto operations.
1373   - hashing :: Create files with the hashed data.
1374   - ipc :: Trace the Assuan commands.
1375   - mpi :: Show the values of the MPIs.
1376   - reader :: Used by scdaemon to trace card reader related code.  For
1377               example: Open and close reader.
1378
1379
1380
1381 * Miscellaneous notes
1382
1383 ** v3 fingerprints
1384    For packet version 3 we calculate the keyids this way:
1385     - RSA :: Low 64 bits of n
1386     - ELGAMAL :: Build a v3 pubkey packet (with CTB 0x99) and
1387                  calculate a RMD160 hash value from it. This is used
1388                  as the fingerprint and the low 64 bits are the keyid.
1389
1390 ** Simplified revocation certificates
1391   Revocation certificates consist only of the signature packet;
1392   "--import" knows how to handle this.  The rationale behind it is to
1393   keep them small.
1394
1395 ** Documentation on HKP (the http keyserver protocol):
1396
1397    A minimalistic HTTP server on port 11371 recognizes a GET for
1398    /pks/lookup.  The standard http URL encoded query parameters are
1399    this (always key=value):
1400
1401    - op=index (like pgp -kv), op=vindex (like pgp -kvv) and op=get (like
1402      pgp -kxa)
1403
1404    - search=<stringlist>. This is a list of words that must occur in the key.
1405      The words are delimited with space, points, @ and so on. The delimiters
1406      are not searched for and the order of the words doesn't matter (but see
1407      next option).
1408
1409    - exact=on. This switch tells the hkp server to only report exact matching
1410      keys back. In this case the order and the "delimiters" are important.
1411
1412    - fingerprint=on. Also reports the fingerprints when used with 'index' or
1413      'vindex'
1414
1415    The keyserver also recognizes http-POSTs to /pks/add. Use this to upload
1416    keys.
1417
1418
1419    A better way to do this would be a request like:
1420
1421       /pks/lookup/<gnupg_formatierte_user_id>?op=<operation>
1422
1423    This can be implemented using Hurd's translator mechanism.
1424    However, I think the whole keyserver stuff has to be re-thought;
1425    I have some ideas and probably create a white paper.
1426 ** Algorithm names for the "keygen.algo" prompt
1427
1428   When using a --command-fd controlled key generation or "addkey"
1429   there is way to know the number to enter on the "keygen.algo"
1430   prompt.  The displayed numbers are for human reception and may
1431   change with releases.  To provide a stable way to enter a desired
1432   algorithm choice the prompt also accepts predefined names for the
1433   algorithms, which will not change.
1434
1435    | Name    | No | Description                     |
1436    |---------+----+---------------------------------|
1437    | rsa+rsa |  1 | RSA and RSA (default)           |
1438    | dsa+elg |  2 | DSA and Elgamal                 |
1439    | dsa     |  3 | DSA (sign only)                 |
1440    | rsa/s   |  4 | RSA (sign only)                 |
1441    | elg     |  5 | Elgamal (encrypt only)          |
1442    | rsa/e   |  6 | RSA (encrypt only)              |
1443    | dsa/*   |  7 | DSA (set your own capabilities) |
1444    | rsa/*   |  8 | RSA (set your own capabilities) |
1445    | ecc+ecc |  9 | ECC and ECC                     |
1446    | ecc/s   | 10 | ECC (sign only)                 |
1447    | ecc/*   | 11 | ECC (set your own capabilities) |
1448    | ecc/e   | 12 | ECC (encrypt only)              |
1449    | keygrip | 13 | Existing key                    |
1450
1451    If one of the "foo/*" names are used a "keygen.flags" prompt needs
1452    to be answered as well.  Instead of toggling the predefined flags,
1453    it is also possible to set them direct: Use a "=" character
1454    directly followed by a comination of "a" (for authentication), "s"
1455    (for signing), or "c" (for certification).