2008-01-15 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / doc / gpgsm.texi
blob12f882e09850616a26531529a69d8ae36b50ce12
1 @c Copyright (C) 2002 Free Software Foundation, Inc.
2 @c This is part of the GnuPG manual.
3 @c For copying conditions, see the file gnupg.texi.
5 @node Invoking GPGSM
6 @chapter Invoking GPGSM
7 @cindex GPGSM command options
8 @cindex command options
9 @cindex options, GPGSM command
11 @manpage gpgsm.1
12 @ifset manverb
13 .B gpgsm
14 \- CMS encryption and signing tool
15 @end ifset
17 @mansect synopsis
18 @ifset manverb
19 .B  gpgsm
20 .RB [ \-\-homedir
21 .IR dir ]
22 .RB [ \-\-options
23 .IR file ]
24 .RI [ options ]  
25 .I command
26 .RI [ args ]
27 @end ifset
30 @mansect description
31 @command{gpgsm} is a tool similar to @command{gpg} to provide digital
32 encryption and signing servicesd on X.509 certificates and the CMS
33 protocol.  It is mainly used as a backend for S/MIME mail processing.
34 @command{gpgsm} includes a full features certificate management and
35 complies with all rules defined for the German Sphinx project.
37 @manpause
38 @xref{Option Index}, for an index to @command{GPGSM}'s commands and options.
39 @mancont
41 @menu
42 * GPGSM Commands::        List of all commands.
43 * GPGSM Options::         List of all options.
44 * GPGSM Configuration::   Configuration files.
45 * GPGSM Examples::        Some usage examples.
47 Developer information:
48 * Unattended Usage::      Using @command{gpgsm} from other programs.
49 * GPGSM Protocol::        The protocol the server mode uses.
50 @end menu
52 @c *******************************************
53 @c ***************            ****************
54 @c ***************  COMMANDS  ****************
55 @c ***************            ****************
56 @c *******************************************
57 @mansect commands
58 @node GPGSM Commands
59 @section Commands
61 Commands are not distinguished from options execpt for the fact that
62 only one command is allowed.
64 @menu
65 * General GPGSM Commands::        Commands not specific to the functionality.
66 * Operational GPGSM Commands::    Commands to select the type of operation.
67 * Certificate Management::        How to manage certificates.
68 @end menu
71 @c *******************************************
72 @c **********  GENERAL COMMANDS  *************
73 @c *******************************************
74 @node General GPGSM Commands
75 @subsection Commands not specific to the function
77 @table @gnupgtabopt
78 @item --version
79 @opindex version
80 Print the program version and licensing information.  Not that you can
81 abbreviate this command.
83 @item --help, -h
84 @opindex help
85 Print a usage message summarizing the most usefule command-line options.
86 Not that you can abbreviate this command.
88 @item --warranty
89 @opindex warranty
90 Print warranty information.
92 @item --dump-options
93 @opindex dump-options
94 Print a list of all available options and commands.  Not that you can
95 abbreviate this command.
96 @end table
99 @c *******************************************
100 @c ********  OPERATIONAL COMMANDS  ***********
101 @c *******************************************
102 @node Operational GPGSM Commands
103 @subsection Commands to select the type of operation
105 @table @gnupgtabopt
106 @item --encrypt
107 @opindex encrypt
108 Perform an encryption.  The keys the data is encrypted too must be set
109 using the option @option{--recipient}.
111 @item --decrypt
112 @opindex decrypt
113 Perform a decryption; the type of input is automatically determined.  It
114 may either be in binary form or PEM encoded; automatic determination of
115 base-64 encoding is not done.
117 @item --sign
118 @opindex sign
119 Create a digital signature.  The key used is either the fist one found
120 in the keybox or those set with the @option{--local-user} option.
122 @item --verify
123 @opindex verify
124 Check a signature file for validity.  Depending on the arguments a
125 detached signatrue may also be checked.
127 @item --server
128 @opindex server
129 Run in server mode and wait for commands on the @code{stdin}.
131 @item --call-dirmngr @var{command} [@var{args}]
132 @opindex call-dirmngr
133 Behave as a Dirmngr client issuing the request @var{command} with the
134 optional list of @var{args}.  The output of the Dirmngr is printed
135 stdout.  Please note that file names given as arguments should have an
136 absulte file name (i.e. commencing with @code{/} because they are
137 passed verbatim to the Dirmngr and the working directory of the
138 Dirmngr might not be the same as the one of this client.  Currently it
139 is not possible to pass data via stdin to the Dirmngr.  @var{command}
140 should not contain spaces.
142 This is command is required for certain maintaining tasks of the dirmngr
143 where a dirmngr must be able to call back to @command{gpgsm}.  See the Dirmngr
144 manual for details.
146 @item --call-protect-tool @var{arguments}
147 @opindex call-protect-tool
148 Certain maintenance operations are done by an external program call
149 @command{gpg-protect-tool}; this is usually not installed in a directory
150 listed in the PATH variable.  This command provides a simple wrapper to
151 access this tool.  @var{arguments} are passed verbatim to this command;
152 use @samp{--help} to get a list of supported operations. 
155 @end table
158 @c *******************************************
159 @c *******  CERTIFICATE MANAGEMENT  **********
160 @c *******************************************
161 @node Certificate Management
162 @subsection How to manage the certificates and keys
164 @table @gnupgtabopt
165 @item --gen-key
166 @opindex gen-key
167 This command allows the interactive creation of a certifcate signing
168 request.  It is commonly used along with the @option{--output} option to
169 save the created CSR into a file.
171 @item --list-keys
172 @itemx -k 
173 @opindex list-keys
174 List all available certificates stored in the local key database.
175 Note that the displayed data might be reformatted for better human
176 readability and illegal characters are replaced by safe substitutes.
178 @item --list-secret-keys
179 @itemx -K
180 @opindex list-secret-keys
181 List all available certificates for which a corresponding a secret key
182 is available.
184 @item --list-external-keys @var{pattern}
185 @opindex list-keys
186 List certificates matching @var{pattern} using an external server.  This
187 utilizes the @code{dirmngr} service.  
189 @item --list-chain
190 @opindex list-chain
191 Same as @option{--list-keys} but also prints all keys making up the chain.
194 @item --dump-cert
195 @itemx --dump-keys
196 @opindex dump-cert
197 @opindex dump-keys
198 List all available certificates stored in the local key database using a
199 format useful mainly for debugging.
201 @item --dump-chain
202 @opindex dump-chain
203 Same as @option{--dump-keys} but also prints all keys making up the chain.
205 @item --dump-secret-keys
206 @opindex dump-secret-keys
207 List all available certificates for which a corresponding a secret key
208 is available using a format useful mainly for debugging.
210 @item --dump-external-keys @var{pattern}
211 @opindex dump-external-keys
212 List certificates matching @var{pattern} using an external server.
213 This utilizes the @code{dirmngr} service.  It uses a format useful
214 mainly for debugging.
216 @item --keydb-clear-some-cert-flags
217 @opindex keydb-clear-some-cert-flags
218 This is a debugging aid to reset certain flags in the key database
219 which are used to cache certain certificate stati.  It is especially
220 useful if a bad CRL or a weird running OCSP reponder did accidently
221 revoke certificate.  There is no security issue with this command
222 because @command{gpgsm} always make sure that the validity of a certificate is
223 checked right before it is used.
225 @item --delete-keys @var{pattern}
226 @opindex delete-keys
227 Delete the keys matching @var{pattern}.
229 @item --export [@var{pattern}]
230 @opindex export
231 Export all certificates stored in the Keybox or those specified by the
232 optional @var{pattern}. Those pattern consist of a list of user ids
233 (@pxref{how-to-specify-a-user-id}).  When used along with the
234 @option{--armor} option a few informational lines are prepended before
235 each block.  There is one limitation: As there is no commonly agreed
236 upon way to pack more than one certificate into an ASN.1 structure, the
237 binary export (i.e. without using @option{armor}) works only for the
238 export of one certificate.  Thus it is required to specify a
239 @var{pattern} which yields exactly one certificate.
241 @item --export-secret-key-p12 @var{key-id}
242 @opindex export
243 Export the private key and the certificate identified by @var{key-id} in
244 a PKCS#12 format. When using along with the @code{--armor} option a few
245 informational lines are prepended to the output.  Note, that the PKCS#12
246 format is not very secure and this command is only provided if there is
247 no other way to exchange the private key. (@pxref{option --p12-charset})
249 @item --import [@var{files}]
250 @opindex import
251 Import the certificates from the PEM or binary encoded files as well as
252 from signed-only messages.  This command may also be used to import a
253 secret key from a PKCS#12 file.
255 @item --learn-card
256 @opindex learn-card
257 Read information about the private keys from the smartcard and import
258 the certificates from there.  This command utilizes the @command{gpg-agent}
259 and in turn the @command{scdaemon}.
261 @item --passwd @var{user_id}
262 @opindex passwd
263 Change the passphrase of the private key belonging to the certificate
264 specified as @var{user_id}.  Note, that changing the passphrase/PIN of a
265 smartcard is not yet supported.
267 @end table
270 @c *******************************************
271 @c ***************            ****************
272 @c ***************  OPTIONS   ****************
273 @c ***************            ****************
274 @c *******************************************
275 @mansect options
276 @node GPGSM Options
277 @section Option Summary
279 @command{GPGSM} comes features a bunch ofoptions to control the exact behaviour
280 and to change the default configuration.
282 @menu 
283 * Configuration Options::   How to change the configuration.
284 * Certificate Options::     Certificate related options.
285 * Input and Output::        Input and Output.
286 * CMS Options::             How to change how the CMS is created.
287 * Esoteric Options::        Doing things one usually don't want to do.
288 @end menu
291 @c *******************************************
292 @c ********  CONFIGURATION OPTIONS  **********
293 @c *******************************************
294 @node Configuration Options
295 @subsection How to change the configuration
297 These options are used to change the configuraton and are usually found
298 in the option file.
300 @table @gnupgtabopt
302 @item --options @var{file}
303 @opindex options
304 Reads configuration from @var{file} instead of from the default
305 per-user configuration file.  The default configuration file is named
306 @file{gpgsm.conf} and expected in the @file{.gnupg} directory directly
307 below the home directory of the user.
309 @include opt-homedir.texi
312 @item -v
313 @item --verbose
314 @opindex v
315 @opindex verbose
316 Outputs additional information while running.
317 You can increase the verbosity by giving several
318 verbose commands to @command{gpgsm}, such as @samp{-vv}.
320 @item --policy-file @var{filename}
321 @opindex policy-file
322 Change the default name of the policy file to @var{filename}.
324 @item --agent-program @var{file}
325 @opindex agent-program
326 Specify an agent program to be used for secret key operations.  The
327 default value is the @file{/usr/local/bin/gpg-agent}.  This is only used
328 as a fallback when the envrionment variable @code{GPG_AGENT_INFO} is not
329 set or a running agent can't be connected.
330   
331 @item --dirmngr-program @var{file}
332 @opindex dirmnr-program
333 Specify a dirmngr program to be used for @acronym{CRL} checks.  The
334 default value is @file{/usr/sbin/dirmngr}.  This is only used as a
335 fallback when the environment variable @code{DIRMNGR_INFO} is not set or
336 a running dirmngr can't be connected.
338 @item --prefer-system-dirmngr
339 @opindex prefer-system-dirmngr
340 If a system wide @command{dirmngr} is running in daemon mode, first try
341 to connect to this one.  Fallback to a pipe based server if this does
342 not work.  Under Windows this option is ignored because the system dirmngr is
343 always used.
345 @item --no-secmem-warning
346 @opindex no-secmem-warning
347 Don't print a warning when the so called "secure memory" can't be used.
349 @item --log-file @var{file}
350 @opindex log-file
351 When running in server mode, append all logging output to @var{file}.
353 @end table
356 @c *******************************************
357 @c ********  CERTIFICATE OPTIONS  ************
358 @c *******************************************
359 @node Certificate Options
360 @subsection Certificate related options
362 @table @gnupgtabopt
364 @item  --enable-policy-checks
365 @itemx --disable-policy-checks
366 @opindex enable-policy-checks
367 @opindex disable-policy-checks
368 By default policy checks are enabled.  These options may be used to
369 change it.
371 @item  --enable-crl-checks
372 @itemx --disable-crl-checks
373 @opindex enable-crl-checks
374 @opindex disable-crl-checks
375 By default the @acronym{CRL} checks are enabled and the DirMngr is used
376 to check for revoked certificates.  The disable option is most useful
377 with an off-line network connection to suppress this check.
379 @item  --enable-trusted-cert-crl-check
380 @itemx --disable-trusted-cert-crl-check
381 @opindex enable-trusted-cert-crl-check
382 @opindex disable-trusted-cert-crl-check
383 By default the @acronym{CRL} for trusted root certificates are checked
384 like for any other certificates.  This allows a CA to revoke its own
385 certificates voluntary without the need of putting all ever issued
386 certificates into a CRL.  The disable option may be used to switch this
387 extra check off.  Due to the caching done by the Dirmngr, there won't be
388 any noticeable performance gain.  Note, that this also disables possible
389 OCSP checks for trusted root certificates.  A more specific way of
390 disabling this check is by adding the ``relax'' keyword to the root CA
391 line of the @file{trustlist.txt}
394 @item --force-crl-refresh
395 @opindex force-crl-refresh
396 Tell the dirmngr to reload the CRL for each request.  For better
397 performance, the dirmngr will actually optimize this by suppressing
398 the loading for short time intervalls (e.g. 30 minutes). This option
399 is useful to make sure that a fresh CRL is available for certificates
400 hold in the keybox.  The suggested way of doing this is by using it
401 along with the option @option{--with-validation} for a key listing
402 command.  This option should not be used in a configuration file. 
404 @item  --enable-ocsp
405 @itemx --disable-ocsp
406 @opindex enable-ocsp
407 @opindex disable-ocsp
408 Be default @acronym{OCSP} checks are disabled.  The enable option may
409 be used to enable OCSP checks via Dirmngr.  If @acronym{CRL} checks
410 are also enabled, CRLs will be used as a fallback if for some reason an
411 OCSP request won't succeed.  Note, that you have to allow OCSP
412 requests in Dirmngr's configuration too (option 
413 @option{--allow-ocsp} and configure dirmngr properly.  If you don't do
414 so you will get the error code @samp{Not supported}.
416 @item --auto-issuer-key-retrieve
417 @opindex auto-issuer-key-retrieve
418 If a required certificate is missing while validating the chain of
419 certificates, try to load that certificate from an external location.
420 This usually means that Dirmngr is employed t search for the
421 certificate.  Note that this option makes a "web bug" like behavior
422 possible.  LDAP server operators can see which keys you request, so by
423 sending you a message signed by a brand new key (which you naturally
424 will not have on your local keybox), the operator can tell both your IP
425 address and the time when you verified the signature.
428 @item --validation-model @var{name}
429 @opindex validation-model
430 This option changes the default validation model.  The only possible
431 values are "shell" (which is the default) and "chain" which forces the
432 use of the chain model.  The chain model is also used if an option in
433 the @file{trustlist.txt} or an attribute of the certificate requests it.
434 However the standard model (shell) is in that case always tried first.
438 @end table
440 @c *******************************************
441 @c ***********  INPUT AND OUTPUT  ************
442 @c *******************************************
443 @node Input and Output
444 @subsection Input and Output
446 @table @gnupgtabopt
447 @item --armor
448 @itemx -a
449 @opindex armor
450 @opindex -a
451 Create PEM encoded output.  Default is binary output. 
453 @item --base64 
454 @opindex base64
455 Create Base-64 encoded output; i.e. PEM without the header lines.
457 @item --assume-armor
458 @opindex assume-armor
459 Assume the input data is PEM encoded.  Default is to autodetect the
460 encoding but this is may fail.
462 @item --assume-base64
463 @opindex assume-base64
464 Assume the input data is plain base-64 encoded.
466 @item --assume-binary
467 @opindex assume-binary
468 Assume the input data is binary encoded.
470 @anchor{option --p12-charset}
471 @item --p12-charset @var{name}
472 @opindex p12-charset
473 @command{gpgsm} uses the UTF-8 encoding when encoding passphrases for
474 PKCS#12 files.  This option may be used to force the passphrase to be
475 encoded in the specified encoding @var{name}.  This is useful if the
476 application used to import the key uses a different encoding and thus
477 won't be able to import a file generated by @command{gpgsm}.  Commonly
478 used values for @var{name} are @code{Latin1} and @code{CP850}.  Note
479 that @command{gpgsm} itself automagically imports any file with a
480 passphrase encoded to the most commonly used encodings.
483 @item --default-key @var{user_id}
484 @opindex default-key
485 Use @var{user_id} as the standard key for signing.  This key is used if
486 no other key has been defined as a signing key.  Note, that the first
487 @option{--local-users} option also sets this key if it has not yet been
488 set; however @option{--default-key} always overrides this.
491 @item --local-user @var{user_id}
492 @item -u @var{user_id}
493 @opindex local-user
494 @opindex -u
495 Set the user(s) to be used for signing.  The default is the first
496 secret key found in the database.
499 @item --recipient @var{name}
500 @itemx -r
501 @opindex recipient
502 Encrypt to the user id @var{name}.  There are several ways a user id
503 may be given (@pxref{how-to-specify-a-user-id}).
506 @item --output @var{file}
507 @itemx -o @var{file}
508 @opindex output
509 Write output to @var{file}.  The default is to write it to stdout.
512 @item --with-key-data
513 @opindex with-key-data
514 Displays extra information with the @code{--list-keys} commands.  Especially
515 a line tagged @code{grp} is printed which tells you the keygrip of a
516 key.  This string is for example used as the file name of the
517 secret key.
519 @item --with-validation
520 @opindex with-validation
521 When doing a key listing, do a full validation check for each key and
522 print the result.  This is usually a slow operation because it
523 requires a CRL lookup and other operations. 
525 When used along with --import, a validation of the certificate to
526 import is done and only imported if it succeeds the test.  Note that
527 this does not affect an already available cwertificate in the DB.
528 This option is therefore useful to simply verify a certificate.
531 @item --with-md5-fingerprint
532 For standard key listings, also print the MD5 fingerprint of the
533 certificate.
535 @end table
537 @c *******************************************
538 @c *************  CMS OPTIONS  ***************
539 @c *******************************************
540 @node CMS Options
541 @subsection How to change how the CMS is created.
543 @table @gnupgtabopt
544 @item --include-certs @var{n}
545 @opindex include-certs
546 Using @var{n} of -2 includes all certificate except for the root cert,
547 -1 includes all certs, 0 does not include any certs, 1 includes only
548 the signers cert (this is the default) and all other positive
549 values include up to @var{n} certificates starting with the signer cert.
552 @item --cipher-algo @var{oid}
553 @opindex cipher-algo
554 Use the cipher algorithm with the ASN.1 object identifier @var{oid} for
555 encryption.  For convenience the strings @code{3DES}, @code{AES} and
556 @code{AES256} may be used instead of their OIDs.  The default is
557 @code{3DES} (1.2.840.113549.3.7).
558   
559 @end table
563 @c *******************************************
564 @c ********  ESOTERIC OPTIONS  ***************
565 @c *******************************************
566 @node Esoteric Options
567 @subsection Doing things one usually don't want to do.
570 @table @gnupgtabopt
572 @item --extra-digest-algo @var{name}
573 @opindex extra-digest-algo
574 Sometimes signatures are broken in that they announce a different digest
575 algorithm than actually used.  @command{gpgsm} uses a one-pass data
576 processing model and thus needs to rely on the announcde digest
577 algorithms to properly hash the data.  As a workaround this option may
578 be used to tell gpg to also hash the data using the algorithm
579 @var{name}; this slows processing down a little bit but allows to verify
580 such broken signatures.  If @command{gpgsm} prints an error like
581 ``digest algo 8 has not been enabled'' you may want to try this option,
582 with @samp{SHA256} for @var{name}.
585 @item --faked-system-time @var{epoch}
586 @opindex faked-system-time
587 This option is only useful for testing; it sets the system time back or
588 forth to @var{epoch} which is the number of seconds elapsed since the year
589 1970.  Alternativly @var{epoch} may be given as a full ISO time string
590 (e.g. "20070924T154812").
592 @item --with-ephemeral-keys
593 @opindex with-ephemeral-keys
594 Include ephemeral flagged keys in the output of key listings.
596 @item --debug-level @var{level}
597 @opindex debug-level
598 Select the debug level for investigating problems. @var{level} may be
599 one of:
601 @table @code
602 @item none
603 no debugging at all.
604 @item basic  
605 some basic debug messages
606 @item advanced
607 more verbose debug messages
608 @item expert
609 even more detailed messages
610 @item guru
611 all of the debug messages you can get
612 @end table
614 How these messages are mapped to the actual debugging flags is not
615 specified and may change with newer releaes of this program. They are
616 however carefully selected to best aid in debugging.
618 @item --debug @var{flags}
619 @opindex debug
620 This option is only useful for debugging and the behaviour may change
621 at any time without notice; using @code{--debug-levels} is the
622 preferred method to select the debug verbosity.  FLAGS are bit encoded
623 and may be given in usual C-Syntax. The currently defined bits are:
625 @table @code
626 @item 0  (1)
627 X.509 or OpenPGP protocol related data
628 @item 1  (2)  
629 values of big number integers 
630 @item 2  (4)
631 low level crypto operations
632 @item 5  (32)
633 memory allocation
634 @item 6  (64)
635 caching
636 @item 7  (128)
637 show memory statistics.
638 @item 9  (512)
639 write hashed data to files named @code{dbgmd-000*}
640 @item 10 (1024)
641 trace Assuan protocol
642 @end table
644 Note, that all flags set using this option may get overriden by
645 @code{--debug-level}.
647 @item --debug-all
648 @opindex debug-all
649 Same as @code{--debug=0xffffffff}
651 @item --debug-allow-core-dump
652 @opindex debug-allow-core-dump
653 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
654 disabling core dumps for security reasons.  However, bugs are pretty
655 durable beasts and to squash them it is sometimes useful to have a core
656 dump.  This option enables core dumps unless the Bad Thing happened
657 before the option parsing.
659 @item --debug-no-chain-validation
660 @opindex debug-no-chain-validation
661 This is actually not a debugging option but only useful as such.  It
662 lets @command{gpgsm} bypass all certificate chain validation checks.
664 @item --debug-ignore-expiration
665 @opindex debug-ignore-expiration
666 This is actually not a debugging option but only useful as such.  It
667 lets @command{gpgsm} ignore all notAfter dates, this is used by the regresssion
668 tests.
670 @item --fixed-passphrase @var{string}
671 @opindex fixed-passphrase
672 Supply the passphrase @var{string} to the gpg-protect-tool.  This
673 option is only useful for the regression tests included with this
674 package and may be revised or removed at any time without notice.
676 @end table
678 All the long options may also be given in the configuration file after
679 stripping off the two leading dashes.
681 @c *******************************************
682 @c ***************            ****************
683 @c ***************  USER ID   ****************
684 @c ***************            ****************
685 @c *******************************************
686 @mansect how to specify a user id
687 @ifset isman
688 @include specify-user-id.texi
689 @end ifset
691 @c *******************************************
692 @c ***************            ****************
693 @c ***************   FILES    ****************
694 @c ***************            ****************
695 @c *******************************************
696 @mansect files
697 @node GPGSM Configuration
698 @section Configuration files
700 There are a few configuration files to control certain aspects of
701 @command{gpgsm}'s operation. Unless noted, they are expected in the
702 current home directory (@pxref{option --homedir}).
704 @table @file
706 @item gpgsm.conf
707 @cindex gpgsm.conf
708 This is the standard configuration file read by @command{gpgsm} on
709 startup.  It may contain any valid long option; the leading two dashes
710 may not be entered and the option may not be abbreviated.  This default
711 name may be changed on the command line (@pxref{option
712   --options}).
714 @item policies.txt
715 @cindex policies.txt
716 This is a list of allowed CA policies.  This file should list the
717 object identifiers of the policies line by line.  Empty lines and
718 lines starting with a hash mark are ignored.  Policies missing in this
719 file and not marked as critical in the certificate will print only a
720 warning; certificates with policies marked as critical and not listed
721 in this file will fail the signature verification.
723 For example, to allow only the policy 2.289.9.9, the file should look
724 like this:
726 @c man:.RS
727 @example
728 # Allowed policies
729 2.289.9.9  
730 @end example
731 @c man:.RE
733 @item qualified.txt
734 @cindex qualified.txt
735 This is the list of root certificates used for qualified certificates.
736 They are defined as certificates capable of creating legally binding
737 signatures in the same way as handwritten signatures are.  Comments
738 start with a hash mark and empty lines are ignored.  Lines do have a
739 length limit but this is not a serious limitation as the format of the
740 entries is fixed and checked by gpgsm: A non-comment line starts with
741 optional white spaces, followed by exactly 40 hex character, white space
742 and a lowercased 2 letter country code.  Additional data delimited with
743 by a white space is current ignored but might late be used for other
744 purposes.
746 Note that even if a certificate is listed in this file, this does not
747 mean that the certificate is trusted; in general the certificates listed
748 in this file need to be listed also in @file{trustlist.txt}.
750 This is a global file an installed in the data directory
751 (e.g. @file{/usr/share/gnupg/qualified.txt}).  GnuPG installs a suitable
752 file with root certificates as used in Germany.  As new Root-CA
753 certificates may be issued over time, these entries may need to be
754 updated; new distributions of this software should come with an updated
755 list but it is still the responsibility of the Administrator to check
756 that this list is correct.
758 Everytime @command{gpgsm} uses a certificate for signing or verification
759 this file will be consulted to check whether the certificate under
760 question has ultimately been issued by one of these CAs.  If this is the
761 case the user will be informed that the verified signature represents a
762 legally binding (``qualified'') signature.  When creating a signature
763 using such a certificate an extra prompt will be issued to let the user
764 confirm that such a legally binding signature shall really be created.
766 Because this software has not yet been approved for use with such
767 certificates, appropriate notices will be shown to indicate this fact.
769 @item help.txt
770 @cindex help.txt
771 This is plain text file with a few help entries used with 
772 @command{pinentry} as well as a large list of help items for
773 @command{gpg} and @command{gpgsm}.  The standard file has English help
774 texts; to install localized versions use filenames like @file{help.LL.txt}
775 with LL denoting the locale.  GnuPG comes with a set of predefined help
776 files in the data directory (e.g. @file{/usr/share/gnupg/help.de.txt})
777 and allows overriding of any help item by help files stored in the
778 system configuration directory (e.g. @file{/etc/gnupg/help.de.txt}).
779 For a reference of the help file's syntax, please see the installed
780 @file{help.txt} file.
783 @end table
785 @c man:.RE
786 Note that on larger installations, it is useful to put predefined files
787 into the directory @file{/etc/skel/.gnupg/} so that newly created users
788 start up with a working configuration.  For existing users the a small
789 helper script is provided to create these files (@pxref{addgnupghome}).
791 For internal purposes gpgsm creates and maintaines a few other files;
792 They all live in in the current home directory (@pxref{option
793 --homedir}).  Only @command{gpgsm} may modify these files.
796 @table @file
797 @item pubring.kbx
798 @cindex pubring.kbx
799 This a database file storing the certificates as well as meta
800 information.  For debugging purposes the tool @command{kbxutil} may be
801 used to show the internal structure of this file.
802       
803 @item random_seed
804 @cindex random_seed
805 This content of this file is used to maintain the internal state of the
806 random number generator accross invocations.  The same file is used by
807 other programs of this software too.
809 @item S.gpg-agent
810 @cindex S.gpg-agent
811 If this file exists and the environment variable @env{GPG_AGENT_INFO} is
812 not set, @command{gpgsm} will first try to connect to this socket for
813 accessing @command{gpg-agent} before starting a new @command{gpg-agent}
814 instance.  Under Windows this socket (which in reality be a plain file
815 describing a regular TCP litening port) is the standard way of
816 connecting the @command{gpg-agent}.
818 @end table
821 @c *******************************************
822 @c ***************            ****************
823 @c ***************  EXAMPLES  ****************
824 @c ***************            ****************
825 @c *******************************************
826 @mansect examples
827 @node GPGSM Examples
828 @section Examples
830 @example
831 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
832 @end example
835 @c man end
838 @c *******************************************
839 @c ***************              **************
840 @c ***************  UNATTENDED  **************
841 @c ***************              **************
842 @c *******************************************
843 @node Unattended Usage
844 @section Unattended Usage
846 @command{gpgsm} is often used as a backend engine by other software.  To help
847 with this a machine interface has been defined to have an unambiguous
848 way to do this.  This is most likely used with the @code{--server} command
849 but may also be used in the standard operation mode by using the
850 @code{--status-fd} option.
852 @menu
853 * Automated signature checking::  Automated signature checking.
854 @end menu
856 @node Automated signature checking,,,Unattended Usage
857 @section Automated signature checking
859 It is very important to understand the semantics used with signature
860 verification.  Checking a signature is not as simple as it may sound and
861 so the ooperation si a bit complicated.  In mosted cases it is required
862 to look at several status lines.  Here is a table of all cases a signed
863 message may have:
865 @table @asis
866 @item The signature is valid
867 This does mean that the signature has been successfully verified, the
868 certificates are all sane.  However there are two subcases with
869 important information:  One of the certificates may have expired or a
870 signature of a message itself as expired.  It is a sound practise to
871 consider such a signature still as valid but additional information
872 should be displayed.  Depending on the subcase @command{gpgsm} will issue
873 these status codes:
874   @table @asis 
875   @item signature valid and nothing did expire
876   @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
877   @item signature valid but at least one certificate has expired
878   @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
879   @item signature valid but expired
880   @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
881   Note, that this case is currently not implemented.
882   @end table
884 @item The signature is invalid
885 This means that the signature verification failed (this is an indication
886 of af a transfer error, a programm error or tampering with the message).
887 @command{gpgsm} issues one of these status codes sequences:
888   @table @code
889   @item  @code{BADSIG}
890   @item  @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
891   @end table
893 @item Error verifying a signature
894 For some reason the signature could not be verified, i.e. it can't be
895 decided whether the signature is valid or invalid.  A common reason for
896 this is a missing certificate.
898 @end table
901 @c *******************************************
902 @c ***************           *****************
903 @c ***************  ASSSUAN  *****************
904 @c ***************           *****************
905 @c *******************************************
906 @manpause
907 @node GPGSM Protocol
908 @section The Protocol the Server Mode Uses.
910 Description of the protocol used to access @command{GPGSM}.
911 @command{GPGSM} does implement the Assuan protocol and in addition
912 provides a regular command line interface which exhibits a full client
913 to this protocol (but uses internal linking).  To start
914 @command{gpgsm} as a server the command line the option
915 @code{--server} must be used.  Additional options are provided to
916 select the communication method (i.e. the name of the socket).
918 We assume that the connection has already been established; see the
919 Assuan manual for details.
921 @menu
922 * GPGSM ENCRYPT::         Encrypting a message.
923 * GPGSM DECRYPT::         Decrypting a message.
924 * GPGSM SIGN::            Signing a message.
925 * GPGSM VERIFY::          Verifying a message.
926 * GPGSM GENKEY::          Generating a key.
927 * GPGSM LISTKEYS::        List available keys.
928 * GPGSM EXPORT::          Export certificates.
929 * GPGSM IMPORT::          Import certificates.
930 * GPGSM DELETE::          Delete certificates.
931 @end menu
934 @node GPGSM ENCRYPT
935 @subsection Encrypting a Message
937 Before encrytion can be done the recipient must be set using the
938 command:
940 @example
941   RECIPIENT @var{userID}
942 @end example
944 Set the recipient for the encryption.  @var{userID} should be the
945 internal representation of the key; the server may accept any other way
946 of specification.  If this is a valid and trusted recipient the server
947 does respond with OK, otherwise the return is an ERR with the reason why
948 the recipient can't be used, the encryption will then not be done for
949 this recipient.  If the policy is not to encrypt at all if not all
950 recipients are valid, the client has to take care of this.  All
951 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
952 successful @code{ENCRYPT} command.
954 @example
955   INPUT FD[=@var{n}] [--armor|--base64|--binary]
956 @end example
958 Set the file descriptor for the message to be encrypted to @var{n}.
959 Obviously the pipe must be open at that point, the server establishes
960 its own end.  If the server returns an error the client should consider
961 this session failed.  If @var{n} is not given, this commands uses the
962 last file descriptor passed to the application.
963 @xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan
964 manual}, on how to do descriptor passing.
966 The @code{--armor} option may be used to advice the server that the
967 input data is in @acronym{PEM} format, @code{--base64} advices that a
968 raw base-64 encoding is used, @code{--binary} advices of raw binary
969 input (@acronym{BER}).  If none of these options is used, the server
970 tries to figure out the used encoding, but this may not always be
971 correct.
973 @example
974   OUTPUT FD[=@var{n}] [--armor|--base64]
975 @end example
977 Set the file descriptor to be used for the output (i.e. the encrypted
978 message). Obviously the pipe must be open at that point, the server
979 establishes its own end.  If the server returns an error he client
980 should consider this session failed.
982 The option armor encodes the output in @acronym{PEM} format, the
983 @code{--base64} option applies just a base 64 encoding.  No option
984 creates binary output (@acronym{BER}).
985   
986 The actual encryption is done using the command
988 @example
989   ENCRYPT 
990 @end example
992 It takes the plaintext from the @code{INPUT} command, writes to the
993 ciphertext to the file descriptor set with the @code{OUTPUT} command,
994 take the recipients from all the recipients set so far.  If this command
995 fails the clients should try to delete all output currently done or
996 otherwise mark it as invalid.  @command{GPGSM} does ensure that there won't be any
997 security problem with leftover data on the output in this case.
999 This command should in general not fail, as all necessary checks have
1000 been done while setting the recipients.  The input and output pipes are
1001 closed.
1004 @node GPGSM DECRYPT
1005 @subsection Decrypting a message
1007 Input and output FDs are set the same way as in encryption, but
1008 @code{INPUT} refers to the ciphertext and output to the plaintext. There
1009 is no need to set recipients.  @command{GPGSM} automatically strips any
1010 @acronym{S/MIME} headers from the input, so it is valid to pass an
1011 entire MIME part to the INPUT pipe.
1013 The encryption is done by using the command
1015 @example
1016   DECRYPT
1017 @end example
1019 It performs the decrypt operation after doing some check on the internal
1020 state. (e.g. that all needed data has been set).  Because it utilizes
1021 the GPG-Agent for the session key decryption, there is no need to ask
1022 the client for a protecting passphrase - GpgAgent takes care of this by
1023 requesting this from the user.
1026 @node GPGSM SIGN
1027 @subsection Signing a Message
1029 Signing is usually done with these commands:
1031 @example
1032   INPUT FD[=@var{n}] [--armor|--base64|--binary]
1033 @end example
1035 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
1037 @example
1038   OUTPUT FD[=@var{m}] [--armor|--base64]
1039 @end example
1041 Write the output to file descriptor @var{m}.  If a detached signature is
1042 requested, only the signature is written.
1044 @example
1045   SIGN [--detached] 
1046 @end example
1048 Sign the data set with the INPUT command and write it to the sink set by
1049 OUTPUT.  With @code{--detached}, a detached signature is created
1050 (surprise).
1052 The key used for signining is the default one or the one specified in
1053 the configuration file.  To get finer control over the keys, it is
1054 possible to use the command
1056 @example
1057   SIGNER @var{userID}
1058 @end example
1060 to the signer's key.  @var{userID} should be the
1061 internal representation of the key; the server may accept any other way
1062 of specification.  If this is a valid and trusted recipient the server
1063 does respond with OK, otherwise the return is an ERR with the reason why
1064 the key can't be used, the signature will then not be created using
1065 this key.  If the policy is not to sign at all if not all
1066 keys are valid, the client has to take care of this.  All
1067 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
1068 Note that a @code{SIGN} does not reset this list of signers which is in
1069 contrats to the @code{RECIPIENT} command.
1072 @node GPGSM VERIFY
1073 @subsection Verifying a Message
1075 To verify a mesage the command:
1077 @example
1078   VERIFY
1079 @end example
1081 is used. It does a verify operation on the message send to the input FD.
1082 The result is written out using status lines.  If an output FD was
1083 given, the signed text will be written to that.  If the signature is a
1084 detached one, the server will inquire about the signed material and the
1085 client must provide it.
1087 @node GPGSM GENKEY
1088 @subsection Generating a Key
1090 This is used to generate a new keypair, store the secret part in the
1091 @acronym{PSE} and the public key in the key database.  We will probably
1092 add optional commands to allow the client to select whether a hardware
1093 token is used to store the key.  Configuration options to
1094 @command{GPGSM} can be used to restrict the use of this command.
1096 @example
1097   GENKEY 
1098 @end example
1100 @command{GPGSM} checks whether this command is allowed and then does an
1101 INQUIRY to get the key parameters, the client should then send the
1102 key parameters in the native format:
1104 @example
1105     S: INQUIRE KEY_PARAM native
1106     C: D foo:fgfgfg
1107     C: D bar
1108     C: END
1109 @end example    
1111 Please note that the server may send Status info lines while reading the
1112 data lines from the client.  After this the key generation takes place
1113 and the server eventually does send an ERR or OK response.  Status lines
1114 may be issued as a progress indicator.
1117 @node GPGSM LISTKEYS
1118 @subsection List available keys
1120 To list the keys in the internal database or using an external key
1121 provider, the command:
1123 @example
1124   LISTKEYS  @var{pattern}
1125 @end example
1127 is used.  To allow multiple patterns (which are ORed during the search)
1128 quoting is required: Spaces are to be translated into "+" or into "%20";
1129 in turn this requires that the usual escape quoting rules are done.
1131 @example
1132   LISTSECRETKEYS @var{pattern}
1133 @end example
1135 Lists only the keys where a secret key is available.
1137 The list commands  commands are affected by the option
1139 @example
1140   OPTION list-mode=@var{mode}
1141 @end example
1143 where mode may be:
1144 @table @code
1145 @item 0 
1146 Use default (which is usually the same as 1).
1147 @item 1
1148 List only the internal keys.
1149 @item 2
1150 List only the external keys.
1151 @item 3
1152 List internal and external keys.
1153 @end table
1155 Note that options are valid for the entire session.
1156     
1158 @node GPGSM EXPORT
1159 @subsection Export certificates
1161 To export certificate from the internal key database the command:
1163 @example
1164   EXPORT [--data [--armor] [--base64]] [--] @var{pattern}
1165 @end example
1167 is used.  To allow multiple patterns (which are ORed) quoting is
1168 required: Spaces are to be translated into "+" or into "%20"; in turn
1169 this requires that the usual escape quoting rules are done.
1171 If the @option{--data} option has not been given, the format of the
1172 output depends on what was set with the OUTPUT command.  When using
1173 @acronym{PEM} encoding a few informational lines are prepended.
1175 If the @option{--data} has been given, a target set via OUTPUT is
1176 ignored and the data is returned inline using standard
1177 @code{D}-lines. This avoids the need for an extra file descriptor.  In
1178 this case the options @option{--armor} and @option{--base64} may be used
1179 in the same way as with the OUTPUT command.
1182 @node GPGSM IMPORT
1183 @subsection Import certificates
1185 To import certificates into the internal key database, the command
1187 @example
1188   IMPORT
1189 @end example
1191 is used.  The data is expected on the file descriptor set with the
1192 @code{INPUT} command.  Certain checks are performend on the
1193 certificate.  Note that the code will also handle PKCS\#12 files and
1194 import private keys; a helper program is used for that.
1197 @node GPGSM DELETE
1198 @subsection Delete certificates
1200 To delete certificate the command
1202 @example
1203   DELKEYS @var{pattern}
1204 @end example
1206 is used.  To allow multiple patterns (which are ORed) quoting is
1207 required: Spaces are to be translated into "+" or into "%20"; in turn
1208 this requires that the usual escape quoting rules are done.
1210 The certificates must be specified unambiguously otherwise an error is
1211 returned.
1214 @mansect see also
1215 @ifset isman
1216 @command{gpg2}(1), 
1217 @command{gpg-agent}(1)
1218 @end ifset
1219 @include see-also-note.texi