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 execpt 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. Not that you can
81 abbreviate this command.
85 Print a usage message summarizing the most usefule command-line options.
86 Not that you can abbreviate this command.
90 Print warranty information.
94 Print a list of all available options and commands. Not that you can
95 abbreviate this command.
99 @c *******************************************
100 @c ******** OPERATIONAL COMMANDS ***********
101 @c *******************************************
102 @node Operational GPGSM Commands
103 @subsection Commands to select the type of operation
108 Perform an encryption.
112 Perform a decryption; the type of input is automatically detmerined. It
113 may either be in binary form or PEM encoded; automatic determination of
114 base-64 encoding is not done.
118 Create a digital signature. The key used is either the fist one found
119 in the keybox or thise set with the -u option
123 Check a signature file for validity. Depending on the arguments a
124 detached signatrue may also be checked.
128 Run in server mode and wait for commands on the @code{stdin}.
130 @item --call-dirmngr @var{command} [@var{args}]
131 @opindex call-dirmngr
132 Behave as a Dirmngr client issuing the request @var{command} with the
133 optional list of @var{args}. The output of the Dirmngr is printed
134 stdout. Please note that file names given as arguments should have an
135 absulte file name (i.e. commencing with @code{/} because they are
136 passed verbatim to the Dirmngr and the working directory of the
137 Dirmngr might not be the same as the one of this client. Currently it
138 is not possible to pass data via stdin to the Dirmngr. @var{command}
139 should not contain spaces.
141 This is command is required for certain maintaining tasks of the dirmngr
142 where a dirmngr must be able to call back to @command{gpgsm}. See the Dirmngr
145 @item --call-protect-tool @var{arguments}
146 @opindex call-protect-tool
147 Certain maintenance operations are done by an external program call
148 @command{gpg-protect-tool}; this is usually not installed in a directory
149 listed in the PATH variable. This command provides a simple wrapper to
150 access this tool. @var{arguments} are passed verbatim to this command;
151 use @samp{--help} to get a list of supported operations.
157 @c *******************************************
158 @c ******* CERTIFICATE MANAGEMENT **********
159 @c *******************************************
160 @node Certificate Management
161 @subsection How to manage the certificates and keys
166 Generate a new key and a certificate request.
171 List all available certificates stored in the local key database.
172 Note that the displayed data might be reformatted for better human
173 readability and illegal characters are replaced by safe substitutes.
175 @item --list-secret-keys
177 @opindex list-secret-keys
178 List all available certificates for which a corresponding a secret key
181 @item --list-external-keys @var{pattern}
183 List certificates matching @var{pattern} using an external server. This
184 utilizes the @code{dirmngr} service.
188 List all available certificates stored in the local key database using a
189 format useful mainly for debugging.
191 @item --dump-secret-keys
192 @opindex dump-secret-keys
193 List all available certificates for which a corresponding a secret key
194 is available using a format useful mainly for debugging.
196 @item --dump-external-keys @var{pattern}
197 @opindex dump-external-keys
198 List certificates matching @var{pattern} using an external server.
199 This utilizes the @code{dirmngr} service. It uses a format useful
200 mainly for debugging.
202 @item --keydb-clear-some-cert-flags
203 @opindex keydb-clear-some-cert-flags
204 This is a debugging aid to reset certain flags in the key database
205 which are used to cache certain certificate stati. It is especially
206 useful if a bad CRL or a weird running OCSP reponder did accidently
207 revoke certificate. There is no security issue with this command
208 because @command{gpgsm} always make sure that the validity of a certificate is
209 checked right before it is used.
211 @item --delete-keys @var{pattern}
213 Delete the keys matching @var{pattern}.
215 @item --export [@var{pattern}]
217 Export all certificates stored in the Keybox or those specified by the
218 optional @var{pattern}. When using along with the @code{--armor} option
219 a few informational lines are prepended before each block.
221 @item --export-secret-key-p12 @var{key-id}
223 Export the private key and the certificate identified by @var{key-id}
224 in a PKCS#12 format. When using along with the @code{--armor} option
225 a few informational lines are prepended to the output. Note, that the
226 PKCS#12 format is higly insecure and this command is only provided if
227 there is no other way to exchange the private key.
229 @item --import [@var{files}]
231 Import the certificates from the PEM or binary encoded files as well as
232 from signed-only messages. This command may also be used to import a
233 secret key from a PKCS#12 file.
237 Read information about the private keys from the smartcard and import
238 the certificates from there. This command utilizes the @command{gpg-agent}
239 and in turn the @command{scdaemon}.
241 @item --passwd @var{user_id}
243 Change the passphrase of the private key belonging to the certificate
244 specified as @var{user_id}. Note, that changing the passphrase/PIN of a
245 smartcard is not yet supported.
250 @c *******************************************
251 @c *************** ****************
252 @c *************** OPTIONS ****************
253 @c *************** ****************
254 @c *******************************************
257 @section Option Summary
259 @command{GPGSM} comes features a bunch ofoptions to control the exact behaviour
260 and to change the default configuration.
263 * Configuration Options:: How to change the configuration.
264 * Certificate Options:: Certificate related options.
265 * Input and Output:: Input and Output.
266 * CMS Options:: How to change how the CMS is created.
267 * Esoteric Options:: Doing things one usually don't want to do.
271 @c *******************************************
272 @c ******** CONFIGURATION OPTIONS **********
273 @c *******************************************
274 @node Configuration Options
275 @subsection How to change the configuration
277 These options are used to change the configuraton and are usually found
282 @item --options @var{file}
284 Reads configuration from @var{file} instead of from the default
285 per-user configuration file. The default configuration file is named
286 @file{gpgsm.conf} and expected in the @file{.gnupg} directory directly
287 below the home directory of the user.
289 @include opt-homedir.texi
296 Outputs additional information while running.
297 You can increase the verbosity by giving several
298 verbose commands to @command{gpgsm}, such as @samp{-vv}.
300 @item --policy-file @var{filename}
302 Change the default name of the policy file to @var{filename}.
304 @item --agent-program @var{file}
305 @opindex agent-program
306 Specify an agent program to be used for secret key operations. The
307 default value is the @file{/usr/local/bin/gpg-agent}. This is only used
308 as a fallback when the envrionment variable @code{GPG_AGENT_INFO} is not
309 set or a running agent can't be connected.
311 @item --dirmngr-program @var{file}
312 @opindex dirmnr-program
313 Specify a dirmngr program to be used for @acronym{CRL} checks. The
314 default value is @file{/usr/sbin/dirmngr}. This is only used as a
315 fallback when the environment variable @code{DIRMNGR_INFO} is not set or
316 a running dirmngr can't be connected.
318 @item --prefer-system-dirmngr
319 @opindex prefer-system-dirmngr
320 If a system wide @command{dirmngr} is running in daemon mode, first try
321 to connect to this one. Fallback to a pipe based server if this does
324 @item --no-secmem-warning
325 @opindex no-secmem-warning
326 Don't print a warning when the so called "secure memory" can't be used.
328 @item --log-file @var{file}
330 When running in server mode, append all logging output to @var{file}.
335 @c *******************************************
336 @c ******** CERTIFICATE OPTIONS ************
337 @c *******************************************
338 @node Certificate Options
339 @subsection Certificate related options
343 @item --enable-policy-checks
344 @itemx --disable-policy-checks
345 @opindex enable-policy-checks
346 @opindex disable-policy-checks
347 By default policy checks are enabled. These options may be used to
350 @item --enable-crl-checks
351 @itemx --disable-crl-checks
352 @opindex enable-crl-checks
353 @opindex disable-crl-checks
354 By default the @acronym{CRL} checks are enabled and the DirMngr is used
355 to check for revoked certificates. The disable option is most useful
356 with an off-line network connection to suppress this check.
358 @item --enable-trusted-cert-crl-check
359 @itemx --disable-trusted-cert-crl-check
360 @opindex enable-trusted-cert-crl-check
361 @opindex disable-trusted-cert-crl-check
362 By default the @acronym{CRL} for trusted root certificates are checked
363 like for any other certificates. This allows a CA to revoke its own
364 certificates voluntary without the need of putting all ever issued
365 certificates into a CRL. The disable option may be used to switch this
366 extra check off. Due to the caching done by the Dirmngr, there won't be
367 any noticeable performance gain. Note, that this also disables possible
368 OCSP checks for trusted root certificates.
370 @item --force-crl-refresh
371 @opindex force-crl-refresh
372 Tell the dirmngr to reload the CRL for each request. For better
373 performance, the dirmngr will actually optimize this by suppressing
374 the loading for short time intervalls (e.g. 30 minutes). This option
375 is useful to make sure that a fresh CRL is available for certificates
376 hold in the keybox. The suggested way of doing this is by using it
377 along with the option @option{--with-validation} for a key listing
378 command. This option should not be used in a configuration file.
381 @itemx --disable-ocsp
383 @opindex disable-ocsp
384 Be default @acronym{OCSP} checks are disabled. The enable opton may
385 be used to enable OCSP checks via Dirmngr. If @acronym{CRL} checks
386 are also enabled, CRLs will be used as a fallback if for some reason an
387 OCSP request won't succeed. Note, that you have to allow OCSP
388 requests in Dirmngr's configuration too (option
389 @option{--allow-ocsp} and configure dirmngr properly. If you don't do
390 so you will get the error code @samp{Not supported}.
394 @c *******************************************
395 @c *********** INPUT AND OUTPUT ************
396 @c *******************************************
397 @node Input and Output
398 @subsection Input and Output
405 Create PEM encoded output. Default is binary output.
409 Create Base-64 encoded output; i.e. PEM without the header lines.
412 @opindex assume-armor
413 Assume the input data is PEM encoded. Default is to autodetect the
414 encoding but this is may fail.
416 @item --assume-base64
417 @opindex assume-base64
418 Assume the input data is plain base-64 encoded.
420 @item --assume-binary
421 @opindex assume-binary
422 Assume the input data is binary encoded.
424 @item --local-user @var{user_id}
425 @item -u @var{user_id}
428 Set the user(s) to be used for signing. The default is the first
429 secret key found in the database.
431 @item --output @var{file}
434 Write output to @var{file}. The default is to write it to stdout.
437 @item --with-key-data
438 @opindex with-key-data
439 Displays extra information with the @code{--list-keys} commands. Especially
440 a line tagged @code{grp} is printed which tells you the keygrip of a
441 key. This string is for example used as the file name of the
444 @item --with-validation
445 @opindex with-validation
446 When doing a key listing, do a full validation check for each key and
447 print the result. This is usually a slow operation because it
448 requires a CRL lookup and other operations.
450 When used along with --import, a validation of the certificate to
451 import is done and only imported if it succeeds the test. Note that
452 this does not affect an already available cwertificate in the DB.
453 This option is therefore useful to simply verify a certificate.
456 @item --with-md5-fingerprint
457 For standard key listings, also print the MD5 fingerprint of the
462 @c *******************************************
463 @c ************* CMS OPTIONS ***************
464 @c *******************************************
466 @subsection How to change how the CMS is created.
469 @item --include-certs @var{n}
470 Using @var{n} of -2 includes all certificate except for the root cert,
471 -1 includes all certs, 0 does not include any certs, 1 includes only
472 the signers cert (this is the default) and all other positive
473 values include up to @var{n} certificates starting with the signer cert.
479 @c *******************************************
480 @c ******** ESOTERIC OPTIONS ***************
481 @c *******************************************
482 @node Esoteric Options
483 @subsection Doing things one usually don't want to do.
488 @item --faked-system-time @var{epoch}
489 @opindex faked-system-time
490 This option is only useful for testing; it sets the system time back or
491 forth to @var{epoch} which is the number of seconds elapsed since the year
494 @item --with-ephemeral-keys
495 @opindex with-ephemeral-keys
496 Include ephemeral flagged keys in the output of key listings.
498 @item --debug-level @var{level}
500 Select the debug level for investigating problems. @var{level} may be
507 some basic debug messages
509 more verbose debug messages
511 even more detailed messages
513 all of the debug messages you can get
516 How these messages are mapped to the actual debugging flags is not
517 specified and may change with newer releaes of this program. They are
518 however carefully selected to best aid in debugging.
520 @item --debug @var{flags}
522 This option is only useful for debugging and the behaviour may change
523 at any time without notice; using @code{--debug-levels} is the
524 preferred method to select the debug verbosity. FLAGS are bit encoded
525 and may be given in usual C-Syntax. The currently defined bits are:
529 X.509 or OpenPGP protocol related data
531 values of big number integers
533 low level crypto operations
539 show memory statistics.
541 write hashed data to files named @code{dbgmd-000*}
543 trace Assuan protocol
546 Note, that all flags set using this option may get overriden by
547 @code{--debug-level}.
551 Same as @code{--debug=0xffffffff}
553 @item --debug-allow-core-dump
554 @opindex debug-allow-core-dump
555 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
556 disabling core dumps for security reasons. However, bugs are pretty
557 durable beasts and to squash them it is sometimes useful to have a core
558 dump. This option enables core dumps unless the Bad Thing happened
559 before the option parsing.
561 @item --debug-no-chain-validation
562 @opindex debug-no-chain-validation
563 This is actually not a debugging option but only useful as such. It
564 lets @command{gpgsm} bypass all certificate chain validation checks.
566 @item --debug-ignore-expiration
567 @opindex debug-ignore-expiration
568 This is actually not a debugging option but only useful as such. It
569 lets @command{gpgsm} ignore all notAfter dates, this is used by the regresssion
572 @item --fixed-passphrase @var{string}
573 @opindex fixed-passphrase
574 Supply the passphrase @var{string} to the gpg-protect-tool. This
575 option is only useful for the regression tests included with this
576 package and may be revised or removed at any time without notice.
580 All the long options may also be given in the configuration file after
581 stripping off the two leading dashes.
584 @c *******************************************
585 @c *************** ****************
586 @c *************** FILES ****************
587 @c *************** ****************
588 @c *******************************************
590 @node GPGSM Configuration
591 @section Configuration files
593 There are a few configuration files to control certain aspects of
594 @command{gpgsm}'s operation. Unless noted, they are expected in the
595 current home directory (@pxref{option --homedir}).
601 This is the standard configuration file read by @command{gpgsm} on
602 startup. It may contain any valid long option; the leading two dashes
603 may not be entered and the option may not be abbreviated. This default
604 name may be changed on the command line (@pxref{option
609 This is a list of allowed CA policies. This file should list the
610 object identifiers of the policies line by line. Empty lines and
611 lines starting with a hash mark are ignored. Policies missing in this
612 file and not marked as critical in the certificate will print only a
613 warning; certificates with policies marked as critical and not listed
614 in this file will fail the signature verification.
616 For example, to allow only the policy 2.289.9.9, the file should look
627 @cindex qualified.txt
628 This is the list of root certificates used for qualified certificates.
629 They are defined as certificates capable of creating legally binding
630 signatures in the same way as handwritten signatures are. Comments
631 start with a hash mark and empty lines are ignored. Lines do have a
632 length limit but this is not a serious limitation as the format of the
633 entries is fixed and checked by gpgsm: A non-comment line starts with
634 optional white spaces, followed by exactly 40 hex character, white space
635 and a lowercased 2 letter country code. Additional data delimited with
636 by a white space is current ignored but might late be used for other
639 Note that even if a certificate is listed in this file, this does not
640 mean that thecertificate is trusted; in general the certificates listed
641 in this file need to be listed also in @file{trustlist.txt}.
643 This is a global file an installed in the data directory
644 (e.g. @file{/usr/share/gnupg/qualified.txt}). GnuPG installs a suitable
645 file with root certificates as used in Germany. As new Root-CA
646 certificates may be issued over time, these entries may need to be
647 updated; new distributions of this software should come with an updated
648 list but it is still the responsibility of the Administrator to check
649 that this list is correct.
651 Everytime @command{gpgsm} uses a certificate for signing or verification
652 this file will be consulted to check whether the certificate under
653 question has ultimately been issued by one of these CAs. If this is the
654 case the user will be informed that the verified signature represents a
655 legally binding (``qualified'') signature. When creating a signature
656 using such a certificate an extra prompt will be issued to let the user
657 confirm that such a legally binding signature shall really be created.
659 Because this software has not yet been approved for use with such
660 certificates, appropriate notices will be shown to indicate this fact.
665 Note that on larger installations, it is useful to put predefined files
666 into the directory @file{/etc/skel/.gnupg/} so that newly created users
667 start up with a working configuration. For existing users the a small
668 helper script is provided to create these files (@pxref{addgnupghome}).
670 For internal purposes gpgsm creates and maintaines a few other files;
671 They all live in in the current home directory (@pxref{option
672 --homedir}). Only @command{gpgsm} may modify these files.
678 This a database file storing the certificates as well as meta
679 information. For debugging purposes the tool @command{kbxutil} may be
680 used to show the internal structure of this file.
684 This content of this file is used to maintain the internal state of the
685 random number generator accross invocations. The same file is used by
686 other programs of this software too.
691 @c *******************************************
692 @c *************** ****************
693 @c *************** EXAMPLES ****************
694 @c *************** ****************
695 @c *******************************************
701 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
708 @c *******************************************
709 @c *************** **************
710 @c *************** UNATTENDED **************
711 @c *************** **************
712 @c *******************************************
713 @node Unattended Usage
714 @section Unattended Usage
716 @command{gpgsm} is often used as a backend engine by other software. To help
717 with this a machine interface has been defined to have an unambiguous
718 way to do this. This is most likely used with the @code{--server} command
719 but may also be used in the standard operation mode by using the
720 @code{--status-fd} option.
723 * Automated signature checking:: Automated signature checking.
726 @node Automated signature checking,,,Unattended Usage
727 @section Automated signature checking
729 It is very important to understand the semantics used with signature
730 verification. Checking a signature is not as simple as it may sound and
731 so the ooperation si a bit complicated. In mosted cases it is required
732 to look at several status lines. Here is a table of all cases a signed
736 @item The signature is valid
737 This does mean that the signature has been successfully verified, the
738 certificates are all sane. However there are two subcases with
739 important information: One of the certificates may have expired or a
740 signature of a message itself as expired. It is a sound practise to
741 consider such a signature still as valid but additional information
742 should be displayed. Depending on the subcase @command{gpgsm} will issue
745 @item signature valid and nothing did expire
746 @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
747 @item signature valid but at least one certificate has expired
748 @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
749 @item signature valid but expired
750 @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
751 Note, that this case is currently not implemented.
754 @item The signature is invalid
755 This means that the signature verification failed (this is an indication
756 of af a transfer error, a programm error or tampering with the message).
757 @command{gpgsm} issues one of these status codes sequences:
760 @item @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
763 @item Error verifying a signature
764 For some reason the signature could not be verified, i.e. it can't be
765 decided whether the signature is valid or invalid. A common reason for
766 this is a missing certificate.
771 @c *******************************************
772 @c *************** *****************
773 @c *************** ASSSUAN *****************
774 @c *************** *****************
775 @c *******************************************
778 @section The Protocol the Server Mode Uses.
780 Description of the protocol used to access @command{GPGSM}.
781 @command{GPGSM} does implement the Assuan protocol and in addition
782 provides a regular command line interface which exhibits a full client
783 to this protocol (but uses internal linking). To start
784 @command{gpgsm} as a server the command line the option
785 @code{--server} must be used. Additional options are provided to
786 select the communication method (i.e. the name of the socket).
788 We assume that the connection has already been established; see the
789 Assuan manual for details.
792 * GPGSM ENCRYPT:: Encrypting a message.
793 * GPGSM DECRYPT:: Decrypting a message.
794 * GPGSM SIGN:: Signing a message.
795 * GPGSM VERIFY:: Verifying a message.
796 * GPGSM GENKEY:: Generating a key.
797 * GPGSM LISTKEYS:: List available keys.
798 * GPGSM EXPORT:: Export certificates.
799 * GPGSM IMPORT:: Import certificates.
800 * GPGSM DELETE:: Delete certificates.
805 @subsection Encrypting a Message
807 Before encrytion can be done the recipient must be set using the
811 RECIPIENT @var{userID}
814 Set the recipient for the encryption. @var{userID} should be the
815 internal representation of the key; the server may accept any other way
816 of specification. If this is a valid and trusted recipient the server
817 does respond with OK, otherwise the return is an ERR with the reason why
818 the recipient can't be used, the encryption will then not be done for
819 this recipient. If the policy is not to encrypt at all if not all
820 recipients are valid, the client has to take care of this. All
821 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
822 successful @code{ENCRYPT} command.
825 INPUT FD=@var{n} [--armor|--base64|--binary]
828 Set the file descriptor for the message to be encrypted to @var{n}.
829 Obviously the pipe must be open at that point, the server establishes
830 its own end. If the server returns an error the client should consider
833 The @code{--armor} option may be used to advice the server that the
834 input data is in @acronym{PEM} format, @code{--base64} advices that a
835 raw base-64 encoding is used, @code{--binary} advices of raw binary
836 input (@acronym{BER}). If none of these options is used, the server
837 tries to figure out the used encoding, but this may not always be
841 OUTPUT FD=@var{n} [--armor|--base64]
844 Set the file descriptor to be used for the output (i.e. the encrypted
845 message). Obviously the pipe must be open at that point, the server
846 establishes its own end. If the server returns an error he client
847 should consider this session failed.
849 The option armor encodes the output in @acronym{PEM} format, the
850 @code{--base64} option applies just a base 64 encoding. No option
851 creates binary output (@acronym{BER}).
853 The actual encryption is done using the command
859 It takes the plaintext from the @code{INPUT} command, writes to the
860 ciphertext to the file descriptor set with the @code{OUTPUT} command,
861 take the recipients from all the recipients set so far. If this command
862 fails the clients should try to delete all output currently done or
863 otherwise mark it as invalid. @command{GPGSM} does ensure that there won't be any
864 security problem with leftover data on the output in this case.
866 This command should in general not fail, as all necessary checks have
867 been done while setting the recipients. The input and output pipes are
872 @subsection Decrypting a message
874 Input and output FDs are set the same way as in encryption, but
875 @code{INPUT} refers to the ciphertext and output to the plaintext. There
876 is no need to set recipients. @command{GPGSM} automatically strips any
877 @acronym{S/MIME} headers from the input, so it is valid to pass an
878 entire MIME part to the INPUT pipe.
880 The encryption is done by using the command
886 It performs the decrypt operation after doing some check on the internal
887 state. (e.g. that all needed data has been set). Because it utilizes
888 the GPG-Agent for the session key decryption, there is no need to ask
889 the client for a protecting passphrase - GpgAgent takes care of this by
890 requesting this from the user.
894 @subsection Signing a Message
896 Signing is usually done with these commands:
899 INPUT FD=@var{n} [--armor|--base64|--binary]
902 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
905 OUTPUT FD=@var{m} [--armor|--base64]
908 Write the output to file descriptor @var{m}. If a detached signature is
909 requested, only the signature is written.
915 Sign the data set with the INPUT command and write it to the sink set by
916 OUTPUT. With @code{--detached}, a detached signature is created
919 The key used for signining is the default one or the one specified in
920 the configuration file. To get finer control over the keys, it is
921 possible to use the command
927 to the signer's key. @var{userID} should be the
928 internal representation of the key; the server may accept any other way
929 of specification. If this is a valid and trusted recipient the server
930 does respond with OK, otherwise the return is an ERR with the reason why
931 the key can't be used, the signature will then not be created using
932 this key. If the policy is not to sign at all if not all
933 keys are valid, the client has to take care of this. All
934 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
935 Note that a @code{SIGN} does not reset this list of signers which is in
936 contrats to the @code{RECIPIENT} command.
940 @subsection Verifying a Message
942 To verify a mesage the command:
948 is used. It does a verify operation on the message send to the input FD.
949 The result is written out using status lines. If an output FD was
950 given, the signed text will be written to that. If the signature is a
951 detached one, the server will inquire about the signed material and the
952 client must provide it.
955 @subsection Generating a Key
957 This is used to generate a new keypair, store the secret part in the
958 @acronym{PSE} and the public key in the key database. We will probably
959 add optional commands to allow the client to select whether a hardware
960 token is used to store the key. Configuration options to
961 @command{GPGSM} can be used to restrict the use of this command.
967 @command{GPGSM} checks whether this command is allowed and then does an
968 INQUIRY to get the key parameters, the client should then send the
969 key parameters in the native format:
972 S: INQUIRE KEY_PARAM native
978 Please note that the server may send Status info lines while reading the
979 data lines from the client. After this the key generation takes place
980 and the server eventually does send an ERR or OK response. Status lines
981 may be issued as a progress indicator.
985 @subsection List available keys
987 To list the keys in the internal database or using an external key
988 provider, the command:
991 LISTKEYS @var{pattern}
994 is used. To allow multiple patterns (which are ORed during the search)
995 quoting is required: Spaces are to be translated into "+" or into "%20";
996 in turn this requires that the usual escape quoting rules are done.
999 LISTSECRETKEYS @var{pattern}
1002 Lists only the keys where a secret key is available.
1004 The list commands commands are affected by the option
1007 OPTION list-mode=@var{mode}
1013 Use default (which is usually the same as 1).
1015 List only the internal keys.
1017 List only the external keys.
1019 List internal and external keys.
1022 Note that options are valid for the entire session.
1026 @subsection Export certificates
1028 To export certificate from the internal key database the command:
1031 EXPORT @var{pattern}
1034 is used. To allow multiple patterns (which are ORed) quoting is
1035 required: Spaces are to be translated into "+" or into "%20"; in turn
1036 this requires that the usual escape quoting rules are done.
1038 The format of the output depends on what was set with the OUTPUT
1039 command. When using @acronym{PEM} encoding a few informational lines
1044 @subsection Import certificates
1046 To import certificates into the internal key database, the command
1052 is used. The data is expected on the file descriptor set with the
1053 @code{INPUT} command. Certain checks are performend on the
1054 certificate. Note that the code will also handle PKCS\#12 files and
1055 import private keys; a helper program is used for that.
1059 @subsection Delete certificates
1061 To delete certificate the command
1064 DELKEYS @var{pattern}
1067 is used. To allow multiple patterns (which are ORed) quoting is
1068 required: Spaces are to be translated into "+" or into "%20"; in turn
1069 this requires that the usual escape quoting rules are done.
1071 The certificates must be specified unambiguously otherwise an error is
1078 @command{gpg-agent}(1)
1080 @include see-also-note.texi