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).
575 @c *******************************************
576 @c ******** ESOTERIC OPTIONS ***************
577 @c *******************************************
578 @node Esoteric Options
579 @subsection Doing things one usually don't want to do.
584 @item --extra-digest-algo @var{name}
585 @opindex extra-digest-algo
586 Sometimes signatures are broken in that they announce a different digest
587 algorithm than actually used. @command{gpgsm} uses a one-pass data
588 processing model and thus needs to rely on the announcde digest
589 algorithms to properly hash the data. As a workaround this option may
590 be used to tell gpg to also hash the data using the algorithm
591 @var{name}; this slows processing down a little bit but allows to verify
592 such broken signatures. If @command{gpgsm} prints an error like
593 ``digest algo 8 has not been enabled'' you may want to try this option,
594 with @samp{SHA256} for @var{name}.
597 @item --faked-system-time @var{epoch}
598 @opindex faked-system-time
599 This option is only useful for testing; it sets the system time back or
600 forth to @var{epoch} which is the number of seconds elapsed since the year
601 1970. Alternativly @var{epoch} may be given as a full ISO time string
602 (e.g. "20070924T154812").
604 @item --with-ephemeral-keys
605 @opindex with-ephemeral-keys
606 Include ephemeral flagged keys in the output of key listings. Note
607 that they are included anyway if the key specification for a listing
608 is given as fingerprint or keygrip.
610 @item --debug-level @var{level}
612 Select the debug level for investigating problems. @var{level} may be
619 some basic debug messages
621 more verbose debug messages
623 even more detailed messages
625 all of the debug messages you can get
628 How these messages are mapped to the actual debugging flags is not
629 specified and may change with newer releases of this program. They are
630 however carefully selected to best aid in debugging.
632 @item --debug @var{flags}
634 This option is only useful for debugging and the behaviour may change
635 at any time without notice; using @code{--debug-levels} is the
636 preferred method to select the debug verbosity. FLAGS are bit encoded
637 and may be given in usual C-Syntax. The currently defined bits are:
641 X.509 or OpenPGP protocol related data
643 values of big number integers
645 low level crypto operations
651 show memory statistics.
653 write hashed data to files named @code{dbgmd-000*}
655 trace Assuan protocol
658 Note, that all flags set using this option may get overriden by
659 @code{--debug-level}.
663 Same as @code{--debug=0xffffffff}
665 @item --debug-allow-core-dump
666 @opindex debug-allow-core-dump
667 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
668 disabling core dumps for security reasons. However, bugs are pretty
669 durable beasts and to squash them it is sometimes useful to have a core
670 dump. This option enables core dumps unless the Bad Thing happened
671 before the option parsing.
673 @item --debug-no-chain-validation
674 @opindex debug-no-chain-validation
675 This is actually not a debugging option but only useful as such. It
676 lets @command{gpgsm} bypass all certificate chain validation checks.
678 @item --debug-ignore-expiration
679 @opindex debug-ignore-expiration
680 This is actually not a debugging option but only useful as such. It
681 lets @command{gpgsm} ignore all notAfter dates, this is used by the regresssion
684 @item --fixed-passphrase @var{string}
685 @opindex fixed-passphrase
686 Supply the passphrase @var{string} to the gpg-protect-tool. This
687 option is only useful for the regression tests included with this
688 package and may be revised or removed at any time without notice.
690 @item --no-common-certs-import
691 @opindex no-common-certs-import
692 Suppress the import of common certificates on keybox creation.
696 All the long options may also be given in the configuration file after
697 stripping off the two leading dashes.
699 @c *******************************************
700 @c *************** ****************
701 @c *************** USER ID ****************
702 @c *************** ****************
703 @c *******************************************
704 @mansect how to specify a user id
706 @include specify-user-id.texi
709 @c *******************************************
710 @c *************** ****************
711 @c *************** FILES ****************
712 @c *************** ****************
713 @c *******************************************
715 @node GPGSM Configuration
716 @section Configuration files
718 There are a few configuration files to control certain aspects of
719 @command{gpgsm}'s operation. Unless noted, they are expected in the
720 current home directory (@pxref{option --homedir}).
726 This is the standard configuration file read by @command{gpgsm} on
727 startup. It may contain any valid long option; the leading two dashes
728 may not be entered and the option may not be abbreviated. This default
729 name may be changed on the command line (@pxref{option
734 This is a list of allowed CA policies. This file should list the
735 object identifiers of the policies line by line. Empty lines and
736 lines starting with a hash mark are ignored. Policies missing in this
737 file and not marked as critical in the certificate will print only a
738 warning; certificates with policies marked as critical and not listed
739 in this file will fail the signature verification.
741 For example, to allow only the policy 2.289.9.9, the file should look
752 @cindex qualified.txt
753 This is the list of root certificates used for qualified certificates.
754 They are defined as certificates capable of creating legally binding
755 signatures in the same way as handwritten signatures are. Comments
756 start with a hash mark and empty lines are ignored. Lines do have a
757 length limit but this is not a serious limitation as the format of the
758 entries is fixed and checked by gpgsm: A non-comment line starts with
759 optional whitespace, followed by exactly 40 hex character, white space
760 and a lowercased 2 letter country code. Additional data delimited with
761 by a white space is current ignored but might late be used for other
764 Note that even if a certificate is listed in this file, this does not
765 mean that the certificate is trusted; in general the certificates listed
766 in this file need to be listed also in @file{trustlist.txt}.
768 This is a global file an installed in the data directory
769 (e.g. @file{/usr/share/gnupg/qualified.txt}). GnuPG installs a suitable
770 file with root certificates as used in Germany. As new Root-CA
771 certificates may be issued over time, these entries may need to be
772 updated; new distributions of this software should come with an updated
773 list but it is still the responsibility of the Administrator to check
774 that this list is correct.
776 Everytime @command{gpgsm} uses a certificate for signing or verification
777 this file will be consulted to check whether the certificate under
778 question has ultimately been issued by one of these CAs. If this is the
779 case the user will be informed that the verified signature represents a
780 legally binding (``qualified'') signature. When creating a signature
781 using such a certificate an extra prompt will be issued to let the user
782 confirm that such a legally binding signature shall really be created.
784 Because this software has not yet been approved for use with such
785 certificates, appropriate notices will be shown to indicate this fact.
789 This is plain text file with a few help entries used with
790 @command{pinentry} as well as a large list of help items for
791 @command{gpg} and @command{gpgsm}. The standard file has English help
792 texts; to install localized versions use filenames like @file{help.LL.txt}
793 with LL denoting the locale. GnuPG comes with a set of predefined help
794 files in the data directory (e.g. @file{/usr/share/gnupg/help.de.txt})
795 and allows overriding of any help item by help files stored in the
796 system configuration directory (e.g. @file{/etc/gnupg/help.de.txt}).
797 For a reference of the help file's syntax, please see the installed
798 @file{help.txt} file.
802 @cindex com-certs.pem
803 This file is a collection of common certificates used to populated a
804 newly created @file{pubring.kbx}. An administrator may replace this
805 file with a custom one. The format is a concatenation of PEM encoded
806 X.509 certificates. This global file is installed in the data directory
807 (e.g. @file{/usr/share/gnupg/qualified.txt}).
812 Note that on larger installations, it is useful to put predefined files
813 into the directory @file{/etc/skel/.gnupg/} so that newly created users
814 start up with a working configuration. For existing users the a small
815 helper script is provided to create these files (@pxref{addgnupghome}).
817 For internal purposes gpgsm creates and maintaines a few other files;
818 they all live in in the current home directory (@pxref{option
819 --homedir}). Only @command{gpgsm} may modify these files.
825 This a database file storing the certificates as well as meta
826 information. For debugging purposes the tool @command{kbxutil} may be
827 used to show the internal structure of this file.
831 This content of this file is used to maintain the internal state of the
832 random number generator accross invocations. The same file is used by
833 other programs of this software too.
837 If this file exists and the environment variable @env{GPG_AGENT_INFO} is
838 not set, @command{gpgsm} will first try to connect to this socket for
839 accessing @command{gpg-agent} before starting a new @command{gpg-agent}
840 instance. Under Windows this socket (which in reality be a plain file
841 describing a regular TCP litening port) is the standard way of
842 connecting the @command{gpg-agent}.
847 @c *******************************************
848 @c *************** ****************
849 @c *************** EXAMPLES ****************
850 @c *************** ****************
851 @c *******************************************
857 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
864 @c *******************************************
865 @c *************** **************
866 @c *************** UNATTENDED **************
867 @c *************** **************
868 @c *******************************************
869 @node Unattended Usage
870 @section Unattended Usage
872 @command{gpgsm} is often used as a backend engine by other software. To help
873 with this a machine interface has been defined to have an unambiguous
874 way to do this. This is most likely used with the @code{--server} command
875 but may also be used in the standard operation mode by using the
876 @code{--status-fd} option.
879 * Automated signature checking:: Automated signature checking.
882 @node Automated signature checking,,,Unattended Usage
883 @section Automated signature checking
885 It is very important to understand the semantics used with signature
886 verification. Checking a signature is not as simple as it may sound and
887 so the ooperation si a bit complicated. In mosted cases it is required
888 to look at several status lines. Here is a table of all cases a signed
892 @item The signature is valid
893 This does mean that the signature has been successfully verified, the
894 certificates are all sane. However there are two subcases with
895 important information: One of the certificates may have expired or a
896 signature of a message itself as expired. It is a sound practise to
897 consider such a signature still as valid but additional information
898 should be displayed. Depending on the subcase @command{gpgsm} will issue
901 @item signature valid and nothing did expire
902 @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
903 @item signature valid but at least one certificate has expired
904 @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
905 @item signature valid but expired
906 @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
907 Note, that this case is currently not implemented.
910 @item The signature is invalid
911 This means that the signature verification failed (this is an indication
912 of af a transfer error, a programm error or tampering with the message).
913 @command{gpgsm} issues one of these status codes sequences:
916 @item @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
919 @item Error verifying a signature
920 For some reason the signature could not be verified, i.e. it can't be
921 decided whether the signature is valid or invalid. A common reason for
922 this is a missing certificate.
927 @c *******************************************
928 @c *************** *****************
929 @c *************** ASSSUAN *****************
930 @c *************** *****************
931 @c *******************************************
934 @section The Protocol the Server Mode Uses.
936 Description of the protocol used to access @command{GPGSM}.
937 @command{GPGSM} does implement the Assuan protocol and in addition
938 provides a regular command line interface which exhibits a full client
939 to this protocol (but uses internal linking). To start
940 @command{gpgsm} as a server the command line the option
941 @code{--server} must be used. Additional options are provided to
942 select the communication method (i.e. the name of the socket).
944 We assume that the connection has already been established; see the
945 Assuan manual for details.
948 * GPGSM ENCRYPT:: Encrypting a message.
949 * GPGSM DECRYPT:: Decrypting a message.
950 * GPGSM SIGN:: Signing a message.
951 * GPGSM VERIFY:: Verifying a message.
952 * GPGSM GENKEY:: Generating a key.
953 * GPGSM LISTKEYS:: List available keys.
954 * GPGSM EXPORT:: Export certificates.
955 * GPGSM IMPORT:: Import certificates.
956 * GPGSM DELETE:: Delete certificates.
957 * GPGSM GETINFO:: Information about the process
962 @subsection Encrypting a Message
964 Before encrytion can be done the recipient must be set using the
968 RECIPIENT @var{userID}
971 Set the recipient for the encryption. @var{userID} should be the
972 internal representation of the key; the server may accept any other way
973 of specification. If this is a valid and trusted recipient the server
974 does respond with OK, otherwise the return is an ERR with the reason why
975 the recipient can't be used, the encryption will then not be done for
976 this recipient. If the policy is not to encrypt at all if not all
977 recipients are valid, the client has to take care of this. All
978 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
979 successful @code{ENCRYPT} command.
982 INPUT FD[=@var{n}] [--armor|--base64|--binary]
985 Set the file descriptor for the message to be encrypted to @var{n}.
986 Obviously the pipe must be open at that point, the server establishes
987 its own end. If the server returns an error the client should consider
988 this session failed. If @var{n} is not given, this commands uses the
989 last file descriptor passed to the application.
990 @xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan
991 manual}, on how to do descriptor passing.
993 The @code{--armor} option may be used to advice the server that the
994 input data is in @acronym{PEM} format, @code{--base64} advices that a
995 raw base-64 encoding is used, @code{--binary} advices of raw binary
996 input (@acronym{BER}). If none of these options is used, the server
997 tries to figure out the used encoding, but this may not always be
1001 OUTPUT FD[=@var{n}] [--armor|--base64]
1004 Set the file descriptor to be used for the output (i.e. the encrypted
1005 message). Obviously the pipe must be open at that point, the server
1006 establishes its own end. If the server returns an error he client
1007 should consider this session failed.
1009 The option armor encodes the output in @acronym{PEM} format, the
1010 @code{--base64} option applies just a base 64 encoding. No option
1011 creates binary output (@acronym{BER}).
1013 The actual encryption is done using the command
1019 It takes the plaintext from the @code{INPUT} command, writes to the
1020 ciphertext to the file descriptor set with the @code{OUTPUT} command,
1021 take the recipients from all the recipients set so far. If this command
1022 fails the clients should try to delete all output currently done or
1023 otherwise mark it as invalid. @command{GPGSM} does ensure that there won't be any
1024 security problem with leftover data on the output in this case.
1026 This command should in general not fail, as all necessary checks have
1027 been done while setting the recipients. The input and output pipes are
1032 @subsection Decrypting a message
1034 Input and output FDs are set the same way as in encryption, but
1035 @code{INPUT} refers to the ciphertext and output to the plaintext. There
1036 is no need to set recipients. @command{GPGSM} automatically strips any
1037 @acronym{S/MIME} headers from the input, so it is valid to pass an
1038 entire MIME part to the INPUT pipe.
1040 The encryption is done by using the command
1046 It performs the decrypt operation after doing some check on the internal
1047 state. (e.g. that all needed data has been set). Because it utilizes
1048 the GPG-Agent for the session key decryption, there is no need to ask
1049 the client for a protecting passphrase - GpgAgent takes care of this by
1050 requesting this from the user.
1054 @subsection Signing a Message
1056 Signing is usually done with these commands:
1059 INPUT FD[=@var{n}] [--armor|--base64|--binary]
1062 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
1065 OUTPUT FD[=@var{m}] [--armor|--base64]
1068 Write the output to file descriptor @var{m}. If a detached signature is
1069 requested, only the signature is written.
1075 Sign the data set with the INPUT command and write it to the sink set by
1076 OUTPUT. With @code{--detached}, a detached signature is created
1079 The key used for signining is the default one or the one specified in
1080 the configuration file. To get finer control over the keys, it is
1081 possible to use the command
1087 to the signer's key. @var{userID} should be the
1088 internal representation of the key; the server may accept any other way
1089 of specification. If this is a valid and trusted recipient the server
1090 does respond with OK, otherwise the return is an ERR with the reason why
1091 the key can't be used, the signature will then not be created using
1092 this key. If the policy is not to sign at all if not all
1093 keys are valid, the client has to take care of this. All
1094 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
1095 Note that a @code{SIGN} does not reset this list of signers which is in
1096 contrats to the @code{RECIPIENT} command.
1100 @subsection Verifying a Message
1102 To verify a mesage the command:
1108 is used. It does a verify operation on the message send to the input FD.
1109 The result is written out using status lines. If an output FD was
1110 given, the signed text will be written to that. If the signature is a
1111 detached one, the server will inquire about the signed material and the
1112 client must provide it.
1115 @subsection Generating a Key
1117 This is used to generate a new keypair, store the secret part in the
1118 @acronym{PSE} and the public key in the key database. We will probably
1119 add optional commands to allow the client to select whether a hardware
1120 token is used to store the key. Configuration options to
1121 @command{GPGSM} can be used to restrict the use of this command.
1127 @command{GPGSM} checks whether this command is allowed and then does an
1128 INQUIRY to get the key parameters, the client should then send the
1129 key parameters in the native format:
1132 S: INQUIRE KEY_PARAM native
1138 Please note that the server may send Status info lines while reading the
1139 data lines from the client. After this the key generation takes place
1140 and the server eventually does send an ERR or OK response. Status lines
1141 may be issued as a progress indicator.
1144 @node GPGSM LISTKEYS
1145 @subsection List available keys
1147 To list the keys in the internal database or using an external key
1148 provider, the command:
1151 LISTKEYS @var{pattern}
1154 is used. To allow multiple patterns (which are ORed during the search)
1155 quoting is required: Spaces are to be translated into "+" or into "%20";
1156 in turn this requires that the usual escape quoting rules are done.
1159 LISTSECRETKEYS @var{pattern}
1162 Lists only the keys where a secret key is available.
1164 The list commands commands are affected by the option
1167 OPTION list-mode=@var{mode}
1173 Use default (which is usually the same as 1).
1175 List only the internal keys.
1177 List only the external keys.
1179 List internal and external keys.
1182 Note that options are valid for the entire session.
1186 @subsection Export certificates
1188 To export certificate from the internal key database the command:
1191 EXPORT [--data [--armor] [--base64]] [--] @var{pattern}
1194 is used. To allow multiple patterns (which are ORed) quoting is
1195 required: Spaces are to be translated into "+" or into "%20"; in turn
1196 this requires that the usual escape quoting rules are done.
1198 If the @option{--data} option has not been given, the format of the
1199 output depends on what was set with the OUTPUT command. When using
1200 @acronym{PEM} encoding a few informational lines are prepended.
1202 If the @option{--data} has been given, a target set via OUTPUT is
1203 ignored and the data is returned inline using standard
1204 @code{D}-lines. This avoids the need for an extra file descriptor. In
1205 this case the options @option{--armor} and @option{--base64} may be used
1206 in the same way as with the OUTPUT command.
1210 @subsection Import certificates
1212 To import certificates into the internal key database, the command
1218 is used. The data is expected on the file descriptor set with the
1219 @code{INPUT} command. Certain checks are performend on the
1220 certificate. Note that the code will also handle PKCS\#12 files and
1221 import private keys; a helper program is used for that.
1225 @subsection Delete certificates
1227 To delete a certificate the command
1230 DELKEYS @var{pattern}
1233 is used. To allow multiple patterns (which are ORed) quoting is
1234 required: Spaces are to be translated into "+" or into "%20"; in turn
1235 this requires that the usual escape quoting rules are done.
1237 The certificates must be specified unambiguously otherwise an error is
1241 @subsection Return information about the process
1243 This is a multipurpose function to return a variety of information.
1249 The value of @var{what} specifies the kind of information returned:
1252 Return the version of the program.
1254 Return the process id of the process.
1260 @command{gpg-agent}(1)
1262 @include see-also-note.texi