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 creation of a certificate signing request. It
169 is commonly used along with the @option{--output} option to save the
170 created CSR into a file. If used with the @option{--batch} a parameter
171 file is used to create the CSR.
176 List all available certificates stored in the local key database.
177 Note that the displayed data might be reformatted for better human
178 readability and illegal characters are replaced by safe substitutes.
180 @item --list-secret-keys
182 @opindex list-secret-keys
183 List all available certificates for which a corresponding a secret key
186 @item --list-external-keys @var{pattern}
188 List certificates matching @var{pattern} using an external server. This
189 utilizes the @code{dirmngr} service.
193 Same as @option{--list-keys} but also prints all keys making up the chain.
200 List all available certificates stored in the local key database using a
201 format useful mainly for debugging.
205 Same as @option{--dump-keys} but also prints all keys making up the chain.
207 @item --dump-secret-keys
208 @opindex dump-secret-keys
209 List all available certificates for which a corresponding a secret key
210 is available using a format useful mainly for debugging.
212 @item --dump-external-keys @var{pattern}
213 @opindex dump-external-keys
214 List certificates matching @var{pattern} using an external server.
215 This utilizes the @code{dirmngr} service. It uses a format useful
216 mainly for debugging.
218 @item --keydb-clear-some-cert-flags
219 @opindex keydb-clear-some-cert-flags
220 This is a debugging aid to reset certain flags in the key database
221 which are used to cache certain certificate stati. It is especially
222 useful if a bad CRL or a weird running OCSP reponder did accidently
223 revoke certificate. There is no security issue with this command
224 because @command{gpgsm} always make sure that the validity of a certificate is
225 checked right before it is used.
227 @item --delete-keys @var{pattern}
229 Delete the keys matching @var{pattern}. Note that there is no command
230 to delete the secret part of the key directly. In case you need to do
231 this, you should run the command @code{gpgsm --dump-secret-keys KEYID}
232 before you delete the key, copy the string of hex-digits in the
233 ``keygrip'' line and delete the file consisting of these hex-digits
234 and the suffix @code{.key} from the @file{private-keys-v1.d} directory
235 below our GnuPG home directory (usually @file{~/.gnupg}).
237 @item --export [@var{pattern}]
239 Export all certificates stored in the Keybox or those specified by the
240 optional @var{pattern}. Those pattern consist of a list of user ids
241 (@pxref{how-to-specify-a-user-id}). When used along with the
242 @option{--armor} option a few informational lines are prepended before
243 each block. There is one limitation: As there is no commonly agreed
244 upon way to pack more than one certificate into an ASN.1 structure,
245 the binary export (i.e. without using @option{armor}) works only for
246 the export of one certificate. Thus it is required to specify a
247 @var{pattern} which yields exactly one certificate. Ephemeral
248 certificate are only exported if all @var{pattern} are given as
249 fingerprints or keygrips.
251 @item --export-secret-key-p12 @var{key-id}
253 Export the private key and the certificate identified by @var{key-id} in
254 a PKCS#12 format. When using along with the @code{--armor} option a few
255 informational lines are prepended to the output. Note, that the PKCS#12
256 format is not very secure and this command is only provided if there is
257 no other way to exchange the private key. (@pxref{option --p12-charset})
259 @item --import [@var{files}]
261 Import the certificates from the PEM or binary encoded files as well as
262 from signed-only messages. This command may also be used to import a
263 secret key from a PKCS#12 file.
267 Read information about the private keys from the smartcard and import
268 the certificates from there. This command utilizes the @command{gpg-agent}
269 and in turn the @command{scdaemon}.
271 @item --passwd @var{user_id}
273 Change the passphrase of the private key belonging to the certificate
274 specified as @var{user_id}. Note, that changing the passphrase/PIN of a
275 smartcard is not yet supported.
280 @c *******************************************
281 @c *************** ****************
282 @c *************** OPTIONS ****************
283 @c *************** ****************
284 @c *******************************************
287 @section Option Summary
289 @command{GPGSM} comes features a bunch ofoptions to control the exact behaviour
290 and to change the default configuration.
293 * Configuration Options:: How to change the configuration.
294 * Certificate Options:: Certificate related options.
295 * Input and Output:: Input and Output.
296 * CMS Options:: How to change how the CMS is created.
297 * Esoteric Options:: Doing things one usually don't want to do.
301 @c *******************************************
302 @c ******** CONFIGURATION OPTIONS **********
303 @c *******************************************
304 @node Configuration Options
305 @subsection How to change the configuration
307 These options are used to change the configuraton and are usually found
312 @item --options @var{file}
314 Reads configuration from @var{file} instead of from the default
315 per-user configuration file. The default configuration file is named
316 @file{gpgsm.conf} and expected in the @file{.gnupg} directory directly
317 below the home directory of the user.
319 @include opt-homedir.texi
326 Outputs additional information while running.
327 You can increase the verbosity by giving several
328 verbose commands to @command{gpgsm}, such as @samp{-vv}.
330 @item --policy-file @var{filename}
332 Change the default name of the policy file to @var{filename}.
334 @item --agent-program @var{file}
335 @opindex agent-program
336 Specify an agent program to be used for secret key operations. The
337 default value is the @file{/usr/local/bin/gpg-agent}. This is only used
338 as a fallback when the envrionment variable @code{GPG_AGENT_INFO} is not
339 set or a running agent can't be connected.
341 @item --dirmngr-program @var{file}
342 @opindex dirmnr-program
343 Specify a dirmngr program to be used for @acronym{CRL} checks. The
344 default value is @file{/usr/sbin/dirmngr}. This is only used as a
345 fallback when the environment variable @code{DIRMNGR_INFO} is not set or
346 a running dirmngr can't be connected.
348 @item --prefer-system-dirmngr
349 @opindex prefer-system-dirmngr
350 If a system wide @command{dirmngr} is running in daemon mode, first try
351 to connect to this one. Fallback to a pipe based server if this does
352 not work. Under Windows this option is ignored because the system dirmngr is
355 @item --disable-dirmngr
356 Entirely disable the use of the Dirmngr.
358 @item --no-secmem-warning
359 @opindex no-secmem-warning
360 Don't print a warning when the so called "secure memory" can't be used.
362 @item --log-file @var{file}
364 When running in server mode, append all logging output to @var{file}.
369 @c *******************************************
370 @c ******** CERTIFICATE OPTIONS ************
371 @c *******************************************
372 @node Certificate Options
373 @subsection Certificate related options
377 @item --enable-policy-checks
378 @itemx --disable-policy-checks
379 @opindex enable-policy-checks
380 @opindex disable-policy-checks
381 By default policy checks are enabled. These options may be used to
384 @item --enable-crl-checks
385 @itemx --disable-crl-checks
386 @opindex enable-crl-checks
387 @opindex disable-crl-checks
388 By default the @acronym{CRL} checks are enabled and the DirMngr is used
389 to check for revoked certificates. The disable option is most useful
390 with an off-line network connection to suppress this check.
392 @item --enable-trusted-cert-crl-check
393 @itemx --disable-trusted-cert-crl-check
394 @opindex enable-trusted-cert-crl-check
395 @opindex disable-trusted-cert-crl-check
396 By default the @acronym{CRL} for trusted root certificates are checked
397 like for any other certificates. This allows a CA to revoke its own
398 certificates voluntary without the need of putting all ever issued
399 certificates into a CRL. The disable option may be used to switch this
400 extra check off. Due to the caching done by the Dirmngr, there won't be
401 any noticeable performance gain. Note, that this also disables possible
402 OCSP checks for trusted root certificates. A more specific way of
403 disabling this check is by adding the ``relax'' keyword to the root CA
404 line of the @file{trustlist.txt}
407 @item --force-crl-refresh
408 @opindex force-crl-refresh
409 Tell the dirmngr to reload the CRL for each request. For better
410 performance, the dirmngr will actually optimize this by suppressing
411 the loading for short time intervalls (e.g. 30 minutes). This option
412 is useful to make sure that a fresh CRL is available for certificates
413 hold in the keybox. The suggested way of doing this is by using it
414 along with the option @option{--with-validation} for a key listing
415 command. This option should not be used in a configuration file.
418 @itemx --disable-ocsp
420 @opindex disable-ocsp
421 Be default @acronym{OCSP} checks are disabled. The enable option may
422 be used to enable OCSP checks via Dirmngr. If @acronym{CRL} checks
423 are also enabled, CRLs will be used as a fallback if for some reason an
424 OCSP request won't succeed. Note, that you have to allow OCSP
425 requests in Dirmngr's configuration too (option
426 @option{--allow-ocsp} and configure dirmngr properly. If you don't do
427 so you will get the error code @samp{Not supported}.
429 @item --auto-issuer-key-retrieve
430 @opindex auto-issuer-key-retrieve
431 If a required certificate is missing while validating the chain of
432 certificates, try to load that certificate from an external location.
433 This usually means that Dirmngr is employed t search for the
434 certificate. Note that this option makes a "web bug" like behavior
435 possible. LDAP server operators can see which keys you request, so by
436 sending you a message signed by a brand new key (which you naturally
437 will not have on your local keybox), the operator can tell both your IP
438 address and the time when you verified the signature.
441 @item --validation-model @var{name}
442 @opindex validation-model
443 This option changes the default validation model. The only possible
444 values are "shell" (which is the default) and "chain" which forces the
445 use of the chain model. The chain model is also used if an option in
446 the @file{trustlist.txt} or an attribute of the certificate requests it.
447 However the standard model (shell) is in that case always tried first.
453 @c *******************************************
454 @c *********** INPUT AND OUTPUT ************
455 @c *******************************************
456 @node Input and Output
457 @subsection Input and Output
464 Create PEM encoded output. Default is binary output.
468 Create Base-64 encoded output; i.e. PEM without the header lines.
471 @opindex assume-armor
472 Assume the input data is PEM encoded. Default is to autodetect the
473 encoding but this is may fail.
475 @item --assume-base64
476 @opindex assume-base64
477 Assume the input data is plain base-64 encoded.
479 @item --assume-binary
480 @opindex assume-binary
481 Assume the input data is binary encoded.
483 @anchor{option --p12-charset}
484 @item --p12-charset @var{name}
486 @command{gpgsm} uses the UTF-8 encoding when encoding passphrases for
487 PKCS#12 files. This option may be used to force the passphrase to be
488 encoded in the specified encoding @var{name}. This is useful if the
489 application used to import the key uses a different encoding and thus
490 won't be able to import a file generated by @command{gpgsm}. Commonly
491 used values for @var{name} are @code{Latin1} and @code{CP850}. Note
492 that @command{gpgsm} itself automagically imports any file with a
493 passphrase encoded to the most commonly used encodings.
496 @item --default-key @var{user_id}
498 Use @var{user_id} as the standard key for signing. This key is used if
499 no other key has been defined as a signing key. Note, that the first
500 @option{--local-users} option also sets this key if it has not yet been
501 set; however @option{--default-key} always overrides this.
504 @item --local-user @var{user_id}
505 @item -u @var{user_id}
508 Set the user(s) to be used for signing. The default is the first
509 secret key found in the database.
512 @item --recipient @var{name}
515 Encrypt to the user id @var{name}. There are several ways a user id
516 may be given (@pxref{how-to-specify-a-user-id}).
519 @item --output @var{file}
522 Write output to @var{file}. The default is to write it to stdout.
525 @item --with-key-data
526 @opindex with-key-data
527 Displays extra information with the @code{--list-keys} commands. Especially
528 a line tagged @code{grp} is printed which tells you the keygrip of a
529 key. This string is for example used as the file name of the
532 @item --with-validation
533 @opindex with-validation
534 When doing a key listing, do a full validation check for each key and
535 print the result. This is usually a slow operation because it
536 requires a CRL lookup and other operations.
538 When used along with --import, a validation of the certificate to
539 import is done and only imported if it succeeds the test. Note that
540 this does not affect an already available cwertificate in the DB.
541 This option is therefore useful to simply verify a certificate.
544 @item --with-md5-fingerprint
545 For standard key listings, also print the MD5 fingerprint of the
550 @c *******************************************
551 @c ************* CMS OPTIONS ***************
552 @c *******************************************
554 @subsection How to change how the CMS is created.
557 @item --include-certs @var{n}
558 @opindex include-certs
559 Using @var{n} of -2 includes all certificate except for the root cert,
560 -1 includes all certs, 0 does not include any certs, 1 includes only
561 the signers cert (this is the default) and all other positive
562 values include up to @var{n} certificates starting with the signer cert.
565 @item --cipher-algo @var{oid}
567 Use the cipher algorithm with the ASN.1 object identifier @var{oid} for
568 encryption. For convenience the strings @code{3DES}, @code{AES} and
569 @code{AES256} may be used instead of their OIDs. The default is
570 @code{3DES} (1.2.840.113549.3.7).
572 @item --digest-algo @code{name}
573 Use @code{name} as the message digest algorithm. Usually this
574 algorithm is deduced from the respective signing certificate. This
575 option forces the use of the given algorithm and may lead to severe
576 interoperability problems.
582 @c *******************************************
583 @c ******** ESOTERIC OPTIONS ***************
584 @c *******************************************
585 @node Esoteric Options
586 @subsection Doing things one usually don't want to do.
591 @item --extra-digest-algo @var{name}
592 @opindex extra-digest-algo
593 Sometimes signatures are broken in that they announce a different digest
594 algorithm than actually used. @command{gpgsm} uses a one-pass data
595 processing model and thus needs to rely on the announcde digest
596 algorithms to properly hash the data. As a workaround this option may
597 be used to tell gpg to also hash the data using the algorithm
598 @var{name}; this slows processing down a little bit but allows to verify
599 such broken signatures. If @command{gpgsm} prints an error like
600 ``digest algo 8 has not been enabled'' you may want to try this option,
601 with @samp{SHA256} for @var{name}.
604 @item --faked-system-time @var{epoch}
605 @opindex faked-system-time
606 This option is only useful for testing; it sets the system time back or
607 forth to @var{epoch} which is the number of seconds elapsed since the year
608 1970. Alternativly @var{epoch} may be given as a full ISO time string
609 (e.g. "20070924T154812").
611 @item --with-ephemeral-keys
612 @opindex with-ephemeral-keys
613 Include ephemeral flagged keys in the output of key listings. Note
614 that they are included anyway if the key specification for a listing
615 is given as fingerprint or keygrip.
617 @item --debug-level @var{level}
619 Select the debug level for investigating problems. @var{level} may be
626 some basic debug messages
628 more verbose debug messages
630 even more detailed messages
632 all of the debug messages you can get
635 How these messages are mapped to the actual debugging flags is not
636 specified and may change with newer releases of this program. They are
637 however carefully selected to best aid in debugging.
639 @item --debug @var{flags}
641 This option is only useful for debugging and the behaviour may change
642 at any time without notice; using @code{--debug-levels} is the
643 preferred method to select the debug verbosity. FLAGS are bit encoded
644 and may be given in usual C-Syntax. The currently defined bits are:
648 X.509 or OpenPGP protocol related data
650 values of big number integers
652 low level crypto operations
658 show memory statistics.
660 write hashed data to files named @code{dbgmd-000*}
662 trace Assuan protocol
665 Note, that all flags set using this option may get overriden by
666 @code{--debug-level}.
670 Same as @code{--debug=0xffffffff}
672 @item --debug-allow-core-dump
673 @opindex debug-allow-core-dump
674 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
675 disabling core dumps for security reasons. However, bugs are pretty
676 durable beasts and to squash them it is sometimes useful to have a core
677 dump. This option enables core dumps unless the Bad Thing happened
678 before the option parsing.
680 @item --debug-no-chain-validation
681 @opindex debug-no-chain-validation
682 This is actually not a debugging option but only useful as such. It
683 lets @command{gpgsm} bypass all certificate chain validation checks.
685 @item --debug-ignore-expiration
686 @opindex debug-ignore-expiration
687 This is actually not a debugging option but only useful as such. It
688 lets @command{gpgsm} ignore all notAfter dates, this is used by the regresssion
691 @item --fixed-passphrase @var{string}
692 @opindex fixed-passphrase
693 Supply the passphrase @var{string} to the gpg-protect-tool. This
694 option is only useful for the regression tests included with this
695 package and may be revised or removed at any time without notice.
697 @item --no-common-certs-import
698 @opindex no-common-certs-import
699 Suppress the import of common certificates on keybox creation.
703 All the long options may also be given in the configuration file after
704 stripping off the two leading dashes.
706 @c *******************************************
707 @c *************** ****************
708 @c *************** USER ID ****************
709 @c *************** ****************
710 @c *******************************************
711 @mansect how to specify a user id
713 @include specify-user-id.texi
716 @c *******************************************
717 @c *************** ****************
718 @c *************** FILES ****************
719 @c *************** ****************
720 @c *******************************************
722 @node GPGSM Configuration
723 @section Configuration files
725 There are a few configuration files to control certain aspects of
726 @command{gpgsm}'s operation. Unless noted, they are expected in the
727 current home directory (@pxref{option --homedir}).
733 This is the standard configuration file read by @command{gpgsm} on
734 startup. It may contain any valid long option; the leading two dashes
735 may not be entered and the option may not be abbreviated. This default
736 name may be changed on the command line (@pxref{option
741 This is a list of allowed CA policies. This file should list the
742 object identifiers of the policies line by line. Empty lines and
743 lines starting with a hash mark are ignored. Policies missing in this
744 file and not marked as critical in the certificate will print only a
745 warning; certificates with policies marked as critical and not listed
746 in this file will fail the signature verification.
748 For example, to allow only the policy 2.289.9.9, the file should look
759 @cindex qualified.txt
760 This is the list of root certificates used for qualified certificates.
761 They are defined as certificates capable of creating legally binding
762 signatures in the same way as handwritten signatures are. Comments
763 start with a hash mark and empty lines are ignored. Lines do have a
764 length limit but this is not a serious limitation as the format of the
765 entries is fixed and checked by gpgsm: A non-comment line starts with
766 optional whitespace, followed by exactly 40 hex character, white space
767 and a lowercased 2 letter country code. Additional data delimited with
768 by a white space is current ignored but might late be used for other
771 Note that even if a certificate is listed in this file, this does not
772 mean that the certificate is trusted; in general the certificates listed
773 in this file need to be listed also in @file{trustlist.txt}.
775 This is a global file an installed in the data directory
776 (e.g. @file{/usr/share/gnupg/qualified.txt}). GnuPG installs a suitable
777 file with root certificates as used in Germany. As new Root-CA
778 certificates may be issued over time, these entries may need to be
779 updated; new distributions of this software should come with an updated
780 list but it is still the responsibility of the Administrator to check
781 that this list is correct.
783 Everytime @command{gpgsm} uses a certificate for signing or verification
784 this file will be consulted to check whether the certificate under
785 question has ultimately been issued by one of these CAs. If this is the
786 case the user will be informed that the verified signature represents a
787 legally binding (``qualified'') signature. When creating a signature
788 using such a certificate an extra prompt will be issued to let the user
789 confirm that such a legally binding signature shall really be created.
791 Because this software has not yet been approved for use with such
792 certificates, appropriate notices will be shown to indicate this fact.
796 This is plain text file with a few help entries used with
797 @command{pinentry} as well as a large list of help items for
798 @command{gpg} and @command{gpgsm}. The standard file has English help
799 texts; to install localized versions use filenames like @file{help.LL.txt}
800 with LL denoting the locale. GnuPG comes with a set of predefined help
801 files in the data directory (e.g. @file{/usr/share/gnupg/help.de.txt})
802 and allows overriding of any help item by help files stored in the
803 system configuration directory (e.g. @file{/etc/gnupg/help.de.txt}).
804 For a reference of the help file's syntax, please see the installed
805 @file{help.txt} file.
809 @cindex com-certs.pem
810 This file is a collection of common certificates used to populated a
811 newly created @file{pubring.kbx}. An administrator may replace this
812 file with a custom one. The format is a concatenation of PEM encoded
813 X.509 certificates. This global file is installed in the data directory
814 (e.g. @file{/usr/share/gnupg/qualified.txt}).
819 Note that on larger installations, it is useful to put predefined files
820 into the directory @file{/etc/skel/.gnupg/} so that newly created users
821 start up with a working configuration. For existing users the a small
822 helper script is provided to create these files (@pxref{addgnupghome}).
824 For internal purposes gpgsm creates and maintaines a few other files;
825 they all live in in the current home directory (@pxref{option
826 --homedir}). Only @command{gpgsm} may modify these files.
832 This a database file storing the certificates as well as meta
833 information. For debugging purposes the tool @command{kbxutil} may be
834 used to show the internal structure of this file.
838 This content of this file is used to maintain the internal state of the
839 random number generator accross invocations. The same file is used by
840 other programs of this software too.
844 If this file exists and the environment variable @env{GPG_AGENT_INFO} is
845 not set, @command{gpgsm} will first try to connect to this socket for
846 accessing @command{gpg-agent} before starting a new @command{gpg-agent}
847 instance. Under Windows this socket (which in reality be a plain file
848 describing a regular TCP litening port) is the standard way of
849 connecting the @command{gpg-agent}.
854 @c *******************************************
855 @c *************** ****************
856 @c *************** EXAMPLES ****************
857 @c *************** ****************
858 @c *******************************************
864 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
871 @c *******************************************
872 @c *************** **************
873 @c *************** UNATTENDED **************
874 @c *************** **************
875 @c *******************************************
876 @node Unattended Usage
877 @section Unattended Usage
879 @command{gpgsm} is often used as a backend engine by other software. To help
880 with this a machine interface has been defined to have an unambiguous
881 way to do this. This is most likely used with the @code{--server} command
882 but may also be used in the standard operation mode by using the
883 @code{--status-fd} option.
886 * Automated signature checking:: Automated signature checking.
889 @node Automated signature checking,,,Unattended Usage
890 @section Automated signature checking
892 It is very important to understand the semantics used with signature
893 verification. Checking a signature is not as simple as it may sound and
894 so the ooperation si a bit complicated. In mosted cases it is required
895 to look at several status lines. Here is a table of all cases a signed
899 @item The signature is valid
900 This does mean that the signature has been successfully verified, the
901 certificates are all sane. However there are two subcases with
902 important information: One of the certificates may have expired or a
903 signature of a message itself as expired. It is a sound practise to
904 consider such a signature still as valid but additional information
905 should be displayed. Depending on the subcase @command{gpgsm} will issue
908 @item signature valid and nothing did expire
909 @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
910 @item signature valid but at least one certificate has expired
911 @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
912 @item signature valid but expired
913 @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
914 Note, that this case is currently not implemented.
917 @item The signature is invalid
918 This means that the signature verification failed (this is an indication
919 of af a transfer error, a programm error or tampering with the message).
920 @command{gpgsm} issues one of these status codes sequences:
923 @item @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
926 @item Error verifying a signature
927 For some reason the signature could not be verified, i.e. it can't be
928 decided whether the signature is valid or invalid. A common reason for
929 this is a missing certificate.
934 @c *******************************************
935 @c *************** *****************
936 @c *************** ASSSUAN *****************
937 @c *************** *****************
938 @c *******************************************
941 @section The Protocol the Server Mode Uses.
943 Description of the protocol used to access @command{GPGSM}.
944 @command{GPGSM} does implement the Assuan protocol and in addition
945 provides a regular command line interface which exhibits a full client
946 to this protocol (but uses internal linking). To start
947 @command{gpgsm} as a server the command line the option
948 @code{--server} must be used. Additional options are provided to
949 select the communication method (i.e. the name of the socket).
951 We assume that the connection has already been established; see the
952 Assuan manual for details.
955 * GPGSM ENCRYPT:: Encrypting a message.
956 * GPGSM DECRYPT:: Decrypting a message.
957 * GPGSM SIGN:: Signing a message.
958 * GPGSM VERIFY:: Verifying a message.
959 * GPGSM GENKEY:: Generating a key.
960 * GPGSM LISTKEYS:: List available keys.
961 * GPGSM EXPORT:: Export certificates.
962 * GPGSM IMPORT:: Import certificates.
963 * GPGSM DELETE:: Delete certificates.
964 * GPGSM GETINFO:: Information about the process
969 @subsection Encrypting a Message
971 Before encrytion can be done the recipient must be set using the
975 RECIPIENT @var{userID}
978 Set the recipient for the encryption. @var{userID} should be the
979 internal representation of the key; the server may accept any other way
980 of specification. If this is a valid and trusted recipient the server
981 does respond with OK, otherwise the return is an ERR with the reason why
982 the recipient can't be used, the encryption will then not be done for
983 this recipient. If the policy is not to encrypt at all if not all
984 recipients are valid, the client has to take care of this. All
985 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
986 successful @code{ENCRYPT} command.
989 INPUT FD[=@var{n}] [--armor|--base64|--binary]
992 Set the file descriptor for the message to be encrypted to @var{n}.
993 Obviously the pipe must be open at that point, the server establishes
994 its own end. If the server returns an error the client should consider
995 this session failed. If @var{n} is not given, this commands uses the
996 last file descriptor passed to the application.
997 @xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan
998 manual}, on how to do descriptor passing.
1000 The @code{--armor} option may be used to advice the server that the
1001 input data is in @acronym{PEM} format, @code{--base64} advices that a
1002 raw base-64 encoding is used, @code{--binary} advices of raw binary
1003 input (@acronym{BER}). If none of these options is used, the server
1004 tries to figure out the used encoding, but this may not always be
1008 OUTPUT FD[=@var{n}] [--armor|--base64]
1011 Set the file descriptor to be used for the output (i.e. the encrypted
1012 message). Obviously the pipe must be open at that point, the server
1013 establishes its own end. If the server returns an error he client
1014 should consider this session failed.
1016 The option armor encodes the output in @acronym{PEM} format, the
1017 @code{--base64} option applies just a base 64 encoding. No option
1018 creates binary output (@acronym{BER}).
1020 The actual encryption is done using the command
1026 It takes the plaintext from the @code{INPUT} command, writes to the
1027 ciphertext to the file descriptor set with the @code{OUTPUT} command,
1028 take the recipients from all the recipients set so far. If this command
1029 fails the clients should try to delete all output currently done or
1030 otherwise mark it as invalid. @command{GPGSM} does ensure that there won't be any
1031 security problem with leftover data on the output in this case.
1033 This command should in general not fail, as all necessary checks have
1034 been done while setting the recipients. The input and output pipes are
1039 @subsection Decrypting a message
1041 Input and output FDs are set the same way as in encryption, but
1042 @code{INPUT} refers to the ciphertext and output to the plaintext. There
1043 is no need to set recipients. @command{GPGSM} automatically strips any
1044 @acronym{S/MIME} headers from the input, so it is valid to pass an
1045 entire MIME part to the INPUT pipe.
1047 The encryption is done by using the command
1053 It performs the decrypt operation after doing some check on the internal
1054 state. (e.g. that all needed data has been set). Because it utilizes
1055 the GPG-Agent for the session key decryption, there is no need to ask
1056 the client for a protecting passphrase - GpgAgent takes care of this by
1057 requesting this from the user.
1061 @subsection Signing a Message
1063 Signing is usually done with these commands:
1066 INPUT FD[=@var{n}] [--armor|--base64|--binary]
1069 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
1072 OUTPUT FD[=@var{m}] [--armor|--base64]
1075 Write the output to file descriptor @var{m}. If a detached signature is
1076 requested, only the signature is written.
1082 Sign the data set with the INPUT command and write it to the sink set by
1083 OUTPUT. With @code{--detached}, a detached signature is created
1086 The key used for signining is the default one or the one specified in
1087 the configuration file. To get finer control over the keys, it is
1088 possible to use the command
1094 to the signer's key. @var{userID} should be the
1095 internal representation of the key; the server may accept any other way
1096 of specification. If this is a valid and trusted recipient the server
1097 does respond with OK, otherwise the return is an ERR with the reason why
1098 the key can't be used, the signature will then not be created using
1099 this key. If the policy is not to sign at all if not all
1100 keys are valid, the client has to take care of this. All
1101 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
1102 Note that a @code{SIGN} does not reset this list of signers which is in
1103 contrats to the @code{RECIPIENT} command.
1107 @subsection Verifying a Message
1109 To verify a mesage the command:
1115 is used. It does a verify operation on the message send to the input FD.
1116 The result is written out using status lines. If an output FD was
1117 given, the signed text will be written to that. If the signature is a
1118 detached one, the server will inquire about the signed material and the
1119 client must provide it.
1122 @subsection Generating a Key
1124 This is used to generate a new keypair, store the secret part in the
1125 @acronym{PSE} and the public key in the key database. We will probably
1126 add optional commands to allow the client to select whether a hardware
1127 token is used to store the key. Configuration options to
1128 @command{GPGSM} can be used to restrict the use of this command.
1134 @command{GPGSM} checks whether this command is allowed and then does an
1135 INQUIRY to get the key parameters, the client should then send the
1136 key parameters in the native format:
1139 S: INQUIRE KEY_PARAM native
1145 Please note that the server may send Status info lines while reading the
1146 data lines from the client. After this the key generation takes place
1147 and the server eventually does send an ERR or OK response. Status lines
1148 may be issued as a progress indicator.
1151 @node GPGSM LISTKEYS
1152 @subsection List available keys
1154 To list the keys in the internal database or using an external key
1155 provider, the command:
1158 LISTKEYS @var{pattern}
1161 is used. To allow multiple patterns (which are ORed during the search)
1162 quoting is required: Spaces are to be translated into "+" or into "%20";
1163 in turn this requires that the usual escape quoting rules are done.
1166 LISTSECRETKEYS @var{pattern}
1169 Lists only the keys where a secret key is available.
1171 The list commands commands are affected by the option
1174 OPTION list-mode=@var{mode}
1180 Use default (which is usually the same as 1).
1182 List only the internal keys.
1184 List only the external keys.
1186 List internal and external keys.
1189 Note that options are valid for the entire session.
1193 @subsection Export certificates
1195 To export certificate from the internal key database the command:
1198 EXPORT [--data [--armor] [--base64]] [--] @var{pattern}
1201 is used. To allow multiple patterns (which are ORed) quoting is
1202 required: Spaces are to be translated into "+" or into "%20"; in turn
1203 this requires that the usual escape quoting rules are done.
1205 If the @option{--data} option has not been given, the format of the
1206 output depends on what was set with the OUTPUT command. When using
1207 @acronym{PEM} encoding a few informational lines are prepended.
1209 If the @option{--data} has been given, a target set via OUTPUT is
1210 ignored and the data is returned inline using standard
1211 @code{D}-lines. This avoids the need for an extra file descriptor. In
1212 this case the options @option{--armor} and @option{--base64} may be used
1213 in the same way as with the OUTPUT command.
1217 @subsection Import certificates
1219 To import certificates into the internal key database, the command
1222 IMPORT [--re-import]
1225 is used. The data is expected on the file descriptor set with the
1226 @code{INPUT} command. Certain checks are performend on the
1227 certificate. Note that the code will also handle PKCS#12 files and
1228 import private keys; a helper program is used for that.
1230 With the option @option{--re-import} the input data is expected to a be
1231 a linefeed separated list of fingerprints. The command will re-import
1232 the corresponding certificates; that is they are made permanent by
1233 removing their ephemeral flag.
1237 @subsection Delete certificates
1239 To delete a certificate the command
1242 DELKEYS @var{pattern}
1245 is used. To allow multiple patterns (which are ORed) quoting is
1246 required: Spaces are to be translated into "+" or into "%20"; in turn
1247 this requires that the usual escape quoting rules are done.
1249 The certificates must be specified unambiguously otherwise an error is
1253 @subsection Return information about the process
1255 This is a multipurpose function to return a variety of information.
1261 The value of @var{what} specifies the kind of information returned:
1264 Return the version of the program.
1266 Return the process id of the process.
1268 Return success if the agent is running.
1269 @item cmd_has_option @var{cmd} @var{opt}
1270 Return success if the command @var{cmd} implements the option @var{opt}.
1271 The leading two dashes usually used with @var{opt} shall not be given.
1277 @command{gpg-agent}(1)
1279 @include see-also-note.texi