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.
6 @chapter Invoking GPGSM
7 @cindex GPGSM command options
8 @cindex command options
9 @cindex options, GPGSM command
14 \- CMS encryption and signing tool
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.
38 @xref{Option Index}, for an index to @command{GPGSM}'s commands and options.
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.
52 @c *******************************************
53 @c *************** ****************
54 @c *************** COMMANDS ****************
55 @c *************** ****************
56 @c *******************************************
61 Commands are not distinguished from options except for the fact that
62 only one command is allowed.
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.
71 @c *******************************************
72 @c ********** GENERAL COMMANDS *************
73 @c *******************************************
74 @node General GPGSM Commands
75 @subsection Commands not specific to the function
80 Print the program version and licensing information. Note that you
81 cannot abbreviate this command.
85 Print a usage message summarizing the most usefule command-line options.
86 Note that you cannot abbreviate this command.
90 Print warranty information. Note that you cannot abbreviate this
95 Print a list of all available options and commands. Note that you cannot
96 abbreviate this command.
100 @c *******************************************
101 @c ******** OPERATIONAL COMMANDS ***********
102 @c *******************************************
103 @node Operational GPGSM Commands
104 @subsection Commands to select the type of operation
109 Perform an encryption. The keys the data is encrypted too must be set
110 using the option @option{--recipient}.
114 Perform a decryption; the type of input is automatically determined. It
115 may either be in binary form or PEM encoded; automatic determination of
116 base-64 encoding is not done.
120 Create a digital signature. The key used is either the fist one found
121 in the keybox or those set with the @option{--local-user} option.
125 Check a signature file for validity. Depending on the arguments a
126 detached signatrue may also be checked.
130 Run in server mode and wait for commands on the @code{stdin}.
132 @item --call-dirmngr @var{command} [@var{args}]
133 @opindex call-dirmngr
134 Behave as a Dirmngr client issuing the request @var{command} with the
135 optional list of @var{args}. The output of the Dirmngr is printed
136 stdout. Please note that file names given as arguments should have an
137 absulte file name (i.e. commencing with @code{/} because they are
138 passed verbatim to the Dirmngr and the working directory of the
139 Dirmngr might not be the same as the one of this client. Currently it
140 is not possible to pass data via stdin to the Dirmngr. @var{command}
141 should not contain spaces.
143 This is command is required for certain maintaining tasks of the dirmngr
144 where a dirmngr must be able to call back to @command{gpgsm}. See the Dirmngr
147 @item --call-protect-tool @var{arguments}
148 @opindex call-protect-tool
149 Certain maintenance operations are done by an external program call
150 @command{gpg-protect-tool}; this is usually not installed in a directory
151 listed in the PATH variable. This command provides a simple wrapper to
152 access this tool. @var{arguments} are passed verbatim to this command;
153 use @samp{--help} to get a list of supported operations.
159 @c *******************************************
160 @c ******* CERTIFICATE MANAGEMENT **********
161 @c *******************************************
162 @node Certificate Management
163 @subsection How to manage the certificates and keys
168 This command allows the interactive creation of a certifcate signing
169 request. It is commonly used along with the @option{--output} option to
170 save the created CSR into a file.
175 List all available certificates stored in the local key database.
176 Note that the displayed data might be reformatted for better human
177 readability and illegal characters are replaced by safe substitutes.
179 @item --list-secret-keys
181 @opindex list-secret-keys
182 List all available certificates for which a corresponding a secret key
185 @item --list-external-keys @var{pattern}
187 List certificates matching @var{pattern} using an external server. This
188 utilizes the @code{dirmngr} service.
192 Same as @option{--list-keys} but also prints all keys making up the chain.
199 List all available certificates stored in the local key database using a
200 format useful mainly for debugging.
204 Same as @option{--dump-keys} but also prints all keys making up the chain.
206 @item --dump-secret-keys
207 @opindex dump-secret-keys
208 List all available certificates for which a corresponding a secret key
209 is available using a format useful mainly for debugging.
211 @item --dump-external-keys @var{pattern}
212 @opindex dump-external-keys
213 List certificates matching @var{pattern} using an external server.
214 This utilizes the @code{dirmngr} service. It uses a format useful
215 mainly for debugging.
217 @item --keydb-clear-some-cert-flags
218 @opindex keydb-clear-some-cert-flags
219 This is a debugging aid to reset certain flags in the key database
220 which are used to cache certain certificate stati. It is especially
221 useful if a bad CRL or a weird running OCSP reponder did accidently
222 revoke certificate. There is no security issue with this command
223 because @command{gpgsm} always make sure that the validity of a certificate is
224 checked right before it is used.
226 @item --delete-keys @var{pattern}
228 Delete the keys matching @var{pattern}. Note that there is no command
229 to delete the secret part of the key directly. In case you need to do
230 this, you should run the command @code{gpgsm --dump-secret-keys KEYID}
231 before you delete the key, copy the string of hex-digits in the
232 ``keygrip'' line and delete the file consisting of these hex-digits
233 and the suffix @code{.key} from the @file{private-keys-v1.d} directory
234 below our GnuPG home directory (usually @file{~/.gnupg}).
236 @item --export [@var{pattern}]
238 Export all certificates stored in the Keybox or those specified by the
239 optional @var{pattern}. Those pattern consist of a list of user ids
240 (@pxref{how-to-specify-a-user-id}). When used along with the
241 @option{--armor} option a few informational lines are prepended before
242 each block. There is one limitation: As there is no commonly agreed
243 upon way to pack more than one certificate into an ASN.1 structure,
244 the binary export (i.e. without using @option{armor}) works only for
245 the export of one certificate. Thus it is required to specify a
246 @var{pattern} which yields exactly one certificate. Ephemeral
247 certificate are only exported if all @var{pattern} are given as
248 fingerprints or keygrips.
250 @item --export-secret-key-p12 @var{key-id}
252 Export the private key and the certificate identified by @var{key-id} in
253 a PKCS#12 format. When using along with the @code{--armor} option a few
254 informational lines are prepended to the output. Note, that the PKCS#12
255 format is not very secure and this command is only provided if there is
256 no other way to exchange the private key. (@pxref{option --p12-charset})
258 @item --import [@var{files}]
260 Import the certificates from the PEM or binary encoded files as well as
261 from signed-only messages. This command may also be used to import a
262 secret key from a PKCS#12 file.
266 Read information about the private keys from the smartcard and import
267 the certificates from there. This command utilizes the @command{gpg-agent}
268 and in turn the @command{scdaemon}.
270 @item --passwd @var{user_id}
272 Change the passphrase of the private key belonging to the certificate
273 specified as @var{user_id}. Note, that changing the passphrase/PIN of a
274 smartcard is not yet supported.
279 @c *******************************************
280 @c *************** ****************
281 @c *************** OPTIONS ****************
282 @c *************** ****************
283 @c *******************************************
286 @section Option Summary
288 @command{GPGSM} comes features a bunch ofoptions to control the exact behaviour
289 and to change the default configuration.
292 * Configuration Options:: How to change the configuration.
293 * Certificate Options:: Certificate related options.
294 * Input and Output:: Input and Output.
295 * CMS Options:: How to change how the CMS is created.
296 * Esoteric Options:: Doing things one usually don't want to do.
300 @c *******************************************
301 @c ******** CONFIGURATION OPTIONS **********
302 @c *******************************************
303 @node Configuration Options
304 @subsection How to change the configuration
306 These options are used to change the configuraton and are usually found
311 @item --options @var{file}
313 Reads configuration from @var{file} instead of from the default
314 per-user configuration file. The default configuration file is named
315 @file{gpgsm.conf} and expected in the @file{.gnupg} directory directly
316 below the home directory of the user.
318 @include opt-homedir.texi
325 Outputs additional information while running.
326 You can increase the verbosity by giving several
327 verbose commands to @command{gpgsm}, such as @samp{-vv}.
329 @item --policy-file @var{filename}
331 Change the default name of the policy file to @var{filename}.
333 @item --agent-program @var{file}
334 @opindex agent-program
335 Specify an agent program to be used for secret key operations. The
336 default value is the @file{/usr/local/bin/gpg-agent}. This is only used
337 as a fallback when the envrionment variable @code{GPG_AGENT_INFO} is not
338 set or a running agent can't be connected.
340 @item --dirmngr-program @var{file}
341 @opindex dirmnr-program
342 Specify a dirmngr program to be used for @acronym{CRL} checks. The
343 default value is @file{/usr/sbin/dirmngr}. This is only used as a
344 fallback when the environment variable @code{DIRMNGR_INFO} is not set or
345 a running dirmngr can't be connected.
347 @item --prefer-system-dirmngr
348 @opindex prefer-system-dirmngr
349 If a system wide @command{dirmngr} is running in daemon mode, first try
350 to connect to this one. Fallback to a pipe based server if this does
351 not work. Under Windows this option is ignored because the system dirmngr is
354 @item --disable-dirmngr
355 Entirely disable the use of the Dirmngr.
357 @item --no-secmem-warning
358 @opindex no-secmem-warning
359 Don't print a warning when the so called "secure memory" can't be used.
361 @item --log-file @var{file}
363 When running in server mode, append all logging output to @var{file}.
368 @c *******************************************
369 @c ******** CERTIFICATE OPTIONS ************
370 @c *******************************************
371 @node Certificate Options
372 @subsection Certificate related options
376 @item --enable-policy-checks
377 @itemx --disable-policy-checks
378 @opindex enable-policy-checks
379 @opindex disable-policy-checks
380 By default policy checks are enabled. These options may be used to
383 @item --enable-crl-checks
384 @itemx --disable-crl-checks
385 @opindex enable-crl-checks
386 @opindex disable-crl-checks
387 By default the @acronym{CRL} checks are enabled and the DirMngr is used
388 to check for revoked certificates. The disable option is most useful
389 with an off-line network connection to suppress this check.
391 @item --enable-trusted-cert-crl-check
392 @itemx --disable-trusted-cert-crl-check
393 @opindex enable-trusted-cert-crl-check
394 @opindex disable-trusted-cert-crl-check
395 By default the @acronym{CRL} for trusted root certificates are checked
396 like for any other certificates. This allows a CA to revoke its own
397 certificates voluntary without the need of putting all ever issued
398 certificates into a CRL. The disable option may be used to switch this
399 extra check off. Due to the caching done by the Dirmngr, there won't be
400 any noticeable performance gain. Note, that this also disables possible
401 OCSP checks for trusted root certificates. A more specific way of
402 disabling this check is by adding the ``relax'' keyword to the root CA
403 line of the @file{trustlist.txt}
406 @item --force-crl-refresh
407 @opindex force-crl-refresh
408 Tell the dirmngr to reload the CRL for each request. For better
409 performance, the dirmngr will actually optimize this by suppressing
410 the loading for short time intervalls (e.g. 30 minutes). This option
411 is useful to make sure that a fresh CRL is available for certificates
412 hold in the keybox. The suggested way of doing this is by using it
413 along with the option @option{--with-validation} for a key listing
414 command. This option should not be used in a configuration file.
417 @itemx --disable-ocsp
419 @opindex disable-ocsp
420 Be default @acronym{OCSP} checks are disabled. The enable option may
421 be used to enable OCSP checks via Dirmngr. If @acronym{CRL} checks
422 are also enabled, CRLs will be used as a fallback if for some reason an
423 OCSP request won't succeed. Note, that you have to allow OCSP
424 requests in Dirmngr's configuration too (option
425 @option{--allow-ocsp} and configure dirmngr properly. If you don't do
426 so you will get the error code @samp{Not supported}.
428 @item --auto-issuer-key-retrieve
429 @opindex auto-issuer-key-retrieve
430 If a required certificate is missing while validating the chain of
431 certificates, try to load that certificate from an external location.
432 This usually means that Dirmngr is employed t search for the
433 certificate. Note that this option makes a "web bug" like behavior
434 possible. LDAP server operators can see which keys you request, so by
435 sending you a message signed by a brand new key (which you naturally
436 will not have on your local keybox), the operator can tell both your IP
437 address and the time when you verified the signature.
440 @item --validation-model @var{name}
441 @opindex validation-model
442 This option changes the default validation model. The only possible
443 values are "shell" (which is the default) and "chain" which forces the
444 use of the chain model. The chain model is also used if an option in
445 the @file{trustlist.txt} or an attribute of the certificate requests it.
446 However the standard model (shell) is in that case always tried first.
452 @c *******************************************
453 @c *********** INPUT AND OUTPUT ************
454 @c *******************************************
455 @node Input and Output
456 @subsection Input and Output
463 Create PEM encoded output. Default is binary output.
467 Create Base-64 encoded output; i.e. PEM without the header lines.
470 @opindex assume-armor
471 Assume the input data is PEM encoded. Default is to autodetect the
472 encoding but this is may fail.
474 @item --assume-base64
475 @opindex assume-base64
476 Assume the input data is plain base-64 encoded.
478 @item --assume-binary
479 @opindex assume-binary
480 Assume the input data is binary encoded.
482 @anchor{option --p12-charset}
483 @item --p12-charset @var{name}
485 @command{gpgsm} uses the UTF-8 encoding when encoding passphrases for
486 PKCS#12 files. This option may be used to force the passphrase to be
487 encoded in the specified encoding @var{name}. This is useful if the
488 application used to import the key uses a different encoding and thus
489 won't be able to import a file generated by @command{gpgsm}. Commonly
490 used values for @var{name} are @code{Latin1} and @code{CP850}. Note
491 that @command{gpgsm} itself automagically imports any file with a
492 passphrase encoded to the most commonly used encodings.
495 @item --default-key @var{user_id}
497 Use @var{user_id} as the standard key for signing. This key is used if
498 no other key has been defined as a signing key. Note, that the first
499 @option{--local-users} option also sets this key if it has not yet been
500 set; however @option{--default-key} always overrides this.
503 @item --local-user @var{user_id}
504 @item -u @var{user_id}
507 Set the user(s) to be used for signing. The default is the first
508 secret key found in the database.
511 @item --recipient @var{name}
514 Encrypt to the user id @var{name}. There are several ways a user id
515 may be given (@pxref{how-to-specify-a-user-id}).
518 @item --output @var{file}
521 Write output to @var{file}. The default is to write it to stdout.
524 @item --with-key-data
525 @opindex with-key-data
526 Displays extra information with the @code{--list-keys} commands. Especially
527 a line tagged @code{grp} is printed which tells you the keygrip of a
528 key. This string is for example used as the file name of the
531 @item --with-validation
532 @opindex with-validation
533 When doing a key listing, do a full validation check for each key and
534 print the result. This is usually a slow operation because it
535 requires a CRL lookup and other operations.
537 When used along with --import, a validation of the certificate to
538 import is done and only imported if it succeeds the test. Note that
539 this does not affect an already available cwertificate in the DB.
540 This option is therefore useful to simply verify a certificate.
543 @item --with-md5-fingerprint
544 For standard key listings, also print the MD5 fingerprint of the
549 @c *******************************************
550 @c ************* CMS OPTIONS ***************
551 @c *******************************************
553 @subsection How to change how the CMS is created.
556 @item --include-certs @var{n}
557 @opindex include-certs
558 Using @var{n} of -2 includes all certificate except for the root cert,
559 -1 includes all certs, 0 does not include any certs, 1 includes only
560 the signers cert (this is the default) and all other positive
561 values include up to @var{n} certificates starting with the signer cert.
564 @item --cipher-algo @var{oid}
566 Use the cipher algorithm with the ASN.1 object identifier @var{oid} for
567 encryption. For convenience the strings @code{3DES}, @code{AES} and
568 @code{AES256} may be used instead of their OIDs. The default is
569 @code{3DES} (1.2.840.113549.3.7).
571 @item --digest-algo @code{name}
572 Use @code{name} as the message digest algorithm. Usually this
573 algorithm is deduced from the respective signing certificate. This
574 option forces the use of the given algorithm and may lead to severe
575 interoperability problems.
581 @c *******************************************
582 @c ******** ESOTERIC OPTIONS ***************
583 @c *******************************************
584 @node Esoteric Options
585 @subsection Doing things one usually don't want to do.
590 @item --extra-digest-algo @var{name}
591 @opindex extra-digest-algo
592 Sometimes signatures are broken in that they announce a different digest
593 algorithm than actually used. @command{gpgsm} uses a one-pass data
594 processing model and thus needs to rely on the announcde digest
595 algorithms to properly hash the data. As a workaround this option may
596 be used to tell gpg to also hash the data using the algorithm
597 @var{name}; this slows processing down a little bit but allows to verify
598 such broken signatures. If @command{gpgsm} prints an error like
599 ``digest algo 8 has not been enabled'' you may want to try this option,
600 with @samp{SHA256} for @var{name}.
603 @item --faked-system-time @var{epoch}
604 @opindex faked-system-time
605 This option is only useful for testing; it sets the system time back or
606 forth to @var{epoch} which is the number of seconds elapsed since the year
607 1970. Alternativly @var{epoch} may be given as a full ISO time string
608 (e.g. "20070924T154812").
610 @item --with-ephemeral-keys
611 @opindex with-ephemeral-keys
612 Include ephemeral flagged keys in the output of key listings. Note
613 that they are included anyway if the key specification for a listing
614 is given as fingerprint or keygrip.
616 @item --debug-level @var{level}
618 Select the debug level for investigating problems. @var{level} may be
625 some basic debug messages
627 more verbose debug messages
629 even more detailed messages
631 all of the debug messages you can get
634 How these messages are mapped to the actual debugging flags is not
635 specified and may change with newer releases of this program. They are
636 however carefully selected to best aid in debugging.
638 @item --debug @var{flags}
640 This option is only useful for debugging and the behaviour may change
641 at any time without notice; using @code{--debug-levels} is the
642 preferred method to select the debug verbosity. FLAGS are bit encoded
643 and may be given in usual C-Syntax. The currently defined bits are:
647 X.509 or OpenPGP protocol related data
649 values of big number integers
651 low level crypto operations
657 show memory statistics.
659 write hashed data to files named @code{dbgmd-000*}
661 trace Assuan protocol
664 Note, that all flags set using this option may get overriden by
665 @code{--debug-level}.
669 Same as @code{--debug=0xffffffff}
671 @item --debug-allow-core-dump
672 @opindex debug-allow-core-dump
673 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
674 disabling core dumps for security reasons. However, bugs are pretty
675 durable beasts and to squash them it is sometimes useful to have a core
676 dump. This option enables core dumps unless the Bad Thing happened
677 before the option parsing.
679 @item --debug-no-chain-validation
680 @opindex debug-no-chain-validation
681 This is actually not a debugging option but only useful as such. It
682 lets @command{gpgsm} bypass all certificate chain validation checks.
684 @item --debug-ignore-expiration
685 @opindex debug-ignore-expiration
686 This is actually not a debugging option but only useful as such. It
687 lets @command{gpgsm} ignore all notAfter dates, this is used by the regresssion
690 @item --fixed-passphrase @var{string}
691 @opindex fixed-passphrase
692 Supply the passphrase @var{string} to the gpg-protect-tool. This
693 option is only useful for the regression tests included with this
694 package and may be revised or removed at any time without notice.
696 @item --no-common-certs-import
697 @opindex no-common-certs-import
698 Suppress the import of common certificates on keybox creation.
702 All the long options may also be given in the configuration file after
703 stripping off the two leading dashes.
705 @c *******************************************
706 @c *************** ****************
707 @c *************** USER ID ****************
708 @c *************** ****************
709 @c *******************************************
710 @mansect how to specify a user id
712 @include specify-user-id.texi
715 @c *******************************************
716 @c *************** ****************
717 @c *************** FILES ****************
718 @c *************** ****************
719 @c *******************************************
721 @node GPGSM Configuration
722 @section Configuration files
724 There are a few configuration files to control certain aspects of
725 @command{gpgsm}'s operation. Unless noted, they are expected in the
726 current home directory (@pxref{option --homedir}).
732 This is the standard configuration file read by @command{gpgsm} on
733 startup. It may contain any valid long option; the leading two dashes
734 may not be entered and the option may not be abbreviated. This default
735 name may be changed on the command line (@pxref{option
740 This is a list of allowed CA policies. This file should list the
741 object identifiers of the policies line by line. Empty lines and
742 lines starting with a hash mark are ignored. Policies missing in this
743 file and not marked as critical in the certificate will print only a
744 warning; certificates with policies marked as critical and not listed
745 in this file will fail the signature verification.
747 For example, to allow only the policy 2.289.9.9, the file should look
758 @cindex qualified.txt
759 This is the list of root certificates used for qualified certificates.
760 They are defined as certificates capable of creating legally binding
761 signatures in the same way as handwritten signatures are. Comments
762 start with a hash mark and empty lines are ignored. Lines do have a
763 length limit but this is not a serious limitation as the format of the
764 entries is fixed and checked by gpgsm: A non-comment line starts with
765 optional whitespace, followed by exactly 40 hex character, white space
766 and a lowercased 2 letter country code. Additional data delimited with
767 by a white space is current ignored but might late be used for other
770 Note that even if a certificate is listed in this file, this does not
771 mean that the certificate is trusted; in general the certificates listed
772 in this file need to be listed also in @file{trustlist.txt}.
774 This is a global file an installed in the data directory
775 (e.g. @file{/usr/share/gnupg/qualified.txt}). GnuPG installs a suitable
776 file with root certificates as used in Germany. As new Root-CA
777 certificates may be issued over time, these entries may need to be
778 updated; new distributions of this software should come with an updated
779 list but it is still the responsibility of the Administrator to check
780 that this list is correct.
782 Everytime @command{gpgsm} uses a certificate for signing or verification
783 this file will be consulted to check whether the certificate under
784 question has ultimately been issued by one of these CAs. If this is the
785 case the user will be informed that the verified signature represents a
786 legally binding (``qualified'') signature. When creating a signature
787 using such a certificate an extra prompt will be issued to let the user
788 confirm that such a legally binding signature shall really be created.
790 Because this software has not yet been approved for use with such
791 certificates, appropriate notices will be shown to indicate this fact.
795 This is plain text file with a few help entries used with
796 @command{pinentry} as well as a large list of help items for
797 @command{gpg} and @command{gpgsm}. The standard file has English help
798 texts; to install localized versions use filenames like @file{help.LL.txt}
799 with LL denoting the locale. GnuPG comes with a set of predefined help
800 files in the data directory (e.g. @file{/usr/share/gnupg/help.de.txt})
801 and allows overriding of any help item by help files stored in the
802 system configuration directory (e.g. @file{/etc/gnupg/help.de.txt}).
803 For a reference of the help file's syntax, please see the installed
804 @file{help.txt} file.
808 @cindex com-certs.pem
809 This file is a collection of common certificates used to populated a
810 newly created @file{pubring.kbx}. An administrator may replace this
811 file with a custom one. The format is a concatenation of PEM encoded
812 X.509 certificates. This global file is installed in the data directory
813 (e.g. @file{/usr/share/gnupg/qualified.txt}).
818 Note that on larger installations, it is useful to put predefined files
819 into the directory @file{/etc/skel/.gnupg/} so that newly created users
820 start up with a working configuration. For existing users the a small
821 helper script is provided to create these files (@pxref{addgnupghome}).
823 For internal purposes gpgsm creates and maintaines a few other files;
824 they all live in in the current home directory (@pxref{option
825 --homedir}). Only @command{gpgsm} may modify these files.
831 This a database file storing the certificates as well as meta
832 information. For debugging purposes the tool @command{kbxutil} may be
833 used to show the internal structure of this file.
837 This content of this file is used to maintain the internal state of the
838 random number generator accross invocations. The same file is used by
839 other programs of this software too.
843 If this file exists and the environment variable @env{GPG_AGENT_INFO} is
844 not set, @command{gpgsm} will first try to connect to this socket for
845 accessing @command{gpg-agent} before starting a new @command{gpg-agent}
846 instance. Under Windows this socket (which in reality be a plain file
847 describing a regular TCP litening port) is the standard way of
848 connecting the @command{gpg-agent}.
853 @c *******************************************
854 @c *************** ****************
855 @c *************** EXAMPLES ****************
856 @c *************** ****************
857 @c *******************************************
863 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
870 @c *******************************************
871 @c *************** **************
872 @c *************** UNATTENDED **************
873 @c *************** **************
874 @c *******************************************
875 @node Unattended Usage
876 @section Unattended Usage
878 @command{gpgsm} is often used as a backend engine by other software. To help
879 with this a machine interface has been defined to have an unambiguous
880 way to do this. This is most likely used with the @code{--server} command
881 but may also be used in the standard operation mode by using the
882 @code{--status-fd} option.
885 * Automated signature checking:: Automated signature checking.
888 @node Automated signature checking,,,Unattended Usage
889 @section Automated signature checking
891 It is very important to understand the semantics used with signature
892 verification. Checking a signature is not as simple as it may sound and
893 so the ooperation si a bit complicated. In mosted cases it is required
894 to look at several status lines. Here is a table of all cases a signed
898 @item The signature is valid
899 This does mean that the signature has been successfully verified, the
900 certificates are all sane. However there are two subcases with
901 important information: One of the certificates may have expired or a
902 signature of a message itself as expired. It is a sound practise to
903 consider such a signature still as valid but additional information
904 should be displayed. Depending on the subcase @command{gpgsm} will issue
907 @item signature valid and nothing did expire
908 @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
909 @item signature valid but at least one certificate has expired
910 @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
911 @item signature valid but expired
912 @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
913 Note, that this case is currently not implemented.
916 @item The signature is invalid
917 This means that the signature verification failed (this is an indication
918 of af a transfer error, a programm error or tampering with the message).
919 @command{gpgsm} issues one of these status codes sequences:
922 @item @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
925 @item Error verifying a signature
926 For some reason the signature could not be verified, i.e. it can't be
927 decided whether the signature is valid or invalid. A common reason for
928 this is a missing certificate.
933 @c *******************************************
934 @c *************** *****************
935 @c *************** ASSSUAN *****************
936 @c *************** *****************
937 @c *******************************************
940 @section The Protocol the Server Mode Uses.
942 Description of the protocol used to access @command{GPGSM}.
943 @command{GPGSM} does implement the Assuan protocol and in addition
944 provides a regular command line interface which exhibits a full client
945 to this protocol (but uses internal linking). To start
946 @command{gpgsm} as a server the command line the option
947 @code{--server} must be used. Additional options are provided to
948 select the communication method (i.e. the name of the socket).
950 We assume that the connection has already been established; see the
951 Assuan manual for details.
954 * GPGSM ENCRYPT:: Encrypting a message.
955 * GPGSM DECRYPT:: Decrypting a message.
956 * GPGSM SIGN:: Signing a message.
957 * GPGSM VERIFY:: Verifying a message.
958 * GPGSM GENKEY:: Generating a key.
959 * GPGSM LISTKEYS:: List available keys.
960 * GPGSM EXPORT:: Export certificates.
961 * GPGSM IMPORT:: Import certificates.
962 * GPGSM DELETE:: Delete certificates.
963 * GPGSM GETINFO:: Information about the process
968 @subsection Encrypting a Message
970 Before encrytion can be done the recipient must be set using the
974 RECIPIENT @var{userID}
977 Set the recipient for the encryption. @var{userID} should be the
978 internal representation of the key; the server may accept any other way
979 of specification. If this is a valid and trusted recipient the server
980 does respond with OK, otherwise the return is an ERR with the reason why
981 the recipient can't be used, the encryption will then not be done for
982 this recipient. If the policy is not to encrypt at all if not all
983 recipients are valid, the client has to take care of this. All
984 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
985 successful @code{ENCRYPT} command.
988 INPUT FD[=@var{n}] [--armor|--base64|--binary]
991 Set the file descriptor for the message to be encrypted to @var{n}.
992 Obviously the pipe must be open at that point, the server establishes
993 its own end. If the server returns an error the client should consider
994 this session failed. If @var{n} is not given, this commands uses the
995 last file descriptor passed to the application.
996 @xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan
997 manual}, on how to do descriptor passing.
999 The @code{--armor} option may be used to advice the server that the
1000 input data is in @acronym{PEM} format, @code{--base64} advices that a
1001 raw base-64 encoding is used, @code{--binary} advices of raw binary
1002 input (@acronym{BER}). If none of these options is used, the server
1003 tries to figure out the used encoding, but this may not always be
1007 OUTPUT FD[=@var{n}] [--armor|--base64]
1010 Set the file descriptor to be used for the output (i.e. the encrypted
1011 message). Obviously the pipe must be open at that point, the server
1012 establishes its own end. If the server returns an error he client
1013 should consider this session failed.
1015 The option armor encodes the output in @acronym{PEM} format, the
1016 @code{--base64} option applies just a base 64 encoding. No option
1017 creates binary output (@acronym{BER}).
1019 The actual encryption is done using the command
1025 It takes the plaintext from the @code{INPUT} command, writes to the
1026 ciphertext to the file descriptor set with the @code{OUTPUT} command,
1027 take the recipients from all the recipients set so far. If this command
1028 fails the clients should try to delete all output currently done or
1029 otherwise mark it as invalid. @command{GPGSM} does ensure that there won't be any
1030 security problem with leftover data on the output in this case.
1032 This command should in general not fail, as all necessary checks have
1033 been done while setting the recipients. The input and output pipes are
1038 @subsection Decrypting a message
1040 Input and output FDs are set the same way as in encryption, but
1041 @code{INPUT} refers to the ciphertext and output to the plaintext. There
1042 is no need to set recipients. @command{GPGSM} automatically strips any
1043 @acronym{S/MIME} headers from the input, so it is valid to pass an
1044 entire MIME part to the INPUT pipe.
1046 The encryption is done by using the command
1052 It performs the decrypt operation after doing some check on the internal
1053 state. (e.g. that all needed data has been set). Because it utilizes
1054 the GPG-Agent for the session key decryption, there is no need to ask
1055 the client for a protecting passphrase - GpgAgent takes care of this by
1056 requesting this from the user.
1060 @subsection Signing a Message
1062 Signing is usually done with these commands:
1065 INPUT FD[=@var{n}] [--armor|--base64|--binary]
1068 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
1071 OUTPUT FD[=@var{m}] [--armor|--base64]
1074 Write the output to file descriptor @var{m}. If a detached signature is
1075 requested, only the signature is written.
1081 Sign the data set with the INPUT command and write it to the sink set by
1082 OUTPUT. With @code{--detached}, a detached signature is created
1085 The key used for signining is the default one or the one specified in
1086 the configuration file. To get finer control over the keys, it is
1087 possible to use the command
1093 to the signer's key. @var{userID} should be the
1094 internal representation of the key; the server may accept any other way
1095 of specification. If this is a valid and trusted recipient the server
1096 does respond with OK, otherwise the return is an ERR with the reason why
1097 the key can't be used, the signature will then not be created using
1098 this key. If the policy is not to sign at all if not all
1099 keys are valid, the client has to take care of this. All
1100 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
1101 Note that a @code{SIGN} does not reset this list of signers which is in
1102 contrats to the @code{RECIPIENT} command.
1106 @subsection Verifying a Message
1108 To verify a mesage the command:
1114 is used. It does a verify operation on the message send to the input FD.
1115 The result is written out using status lines. If an output FD was
1116 given, the signed text will be written to that. If the signature is a
1117 detached one, the server will inquire about the signed material and the
1118 client must provide it.
1121 @subsection Generating a Key
1123 This is used to generate a new keypair, store the secret part in the
1124 @acronym{PSE} and the public key in the key database. We will probably
1125 add optional commands to allow the client to select whether a hardware
1126 token is used to store the key. Configuration options to
1127 @command{GPGSM} can be used to restrict the use of this command.
1133 @command{GPGSM} checks whether this command is allowed and then does an
1134 INQUIRY to get the key parameters, the client should then send the
1135 key parameters in the native format:
1138 S: INQUIRE KEY_PARAM native
1144 Please note that the server may send Status info lines while reading the
1145 data lines from the client. After this the key generation takes place
1146 and the server eventually does send an ERR or OK response. Status lines
1147 may be issued as a progress indicator.
1150 @node GPGSM LISTKEYS
1151 @subsection List available keys
1153 To list the keys in the internal database or using an external key
1154 provider, the command:
1157 LISTKEYS @var{pattern}
1160 is used. To allow multiple patterns (which are ORed during the search)
1161 quoting is required: Spaces are to be translated into "+" or into "%20";
1162 in turn this requires that the usual escape quoting rules are done.
1165 LISTSECRETKEYS @var{pattern}
1168 Lists only the keys where a secret key is available.
1170 The list commands commands are affected by the option
1173 OPTION list-mode=@var{mode}
1179 Use default (which is usually the same as 1).
1181 List only the internal keys.
1183 List only the external keys.
1185 List internal and external keys.
1188 Note that options are valid for the entire session.
1192 @subsection Export certificates
1194 To export certificate from the internal key database the command:
1197 EXPORT [--data [--armor] [--base64]] [--] @var{pattern}
1200 is used. To allow multiple patterns (which are ORed) quoting is
1201 required: Spaces are to be translated into "+" or into "%20"; in turn
1202 this requires that the usual escape quoting rules are done.
1204 If the @option{--data} option has not been given, the format of the
1205 output depends on what was set with the OUTPUT command. When using
1206 @acronym{PEM} encoding a few informational lines are prepended.
1208 If the @option{--data} has been given, a target set via OUTPUT is
1209 ignored and the data is returned inline using standard
1210 @code{D}-lines. This avoids the need for an extra file descriptor. In
1211 this case the options @option{--armor} and @option{--base64} may be used
1212 in the same way as with the OUTPUT command.
1216 @subsection Import certificates
1218 To import certificates into the internal key database, the command
1224 is used. The data is expected on the file descriptor set with the
1225 @code{INPUT} command. Certain checks are performend on the
1226 certificate. Note that the code will also handle PKCS\#12 files and
1227 import private keys; a helper program is used for that.
1231 @subsection Delete certificates
1233 To delete a certificate the command
1236 DELKEYS @var{pattern}
1239 is used. To allow multiple patterns (which are ORed) quoting is
1240 required: Spaces are to be translated into "+" or into "%20"; in turn
1241 this requires that the usual escape quoting rules are done.
1243 The certificates must be specified unambiguously otherwise an error is
1247 @subsection Return information about the process
1249 This is a multipurpose function to return a variety of information.
1255 The value of @var{what} specifies the kind of information returned:
1258 Return the version of the program.
1260 Return the process id of the process.
1266 @command{gpg-agent}(1)
1268 @include see-also-note.texi