Imported Upstream version 2.1.22
[platform/upstream/gpg2.git] / doc / gpgsm.texi
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.
4
5 @include defs.inc
6
7 @node Invoking GPGSM
8 @chapter Invoking GPGSM
9 @cindex GPGSM command options
10 @cindex command options
11 @cindex options, GPGSM command
12
13 @manpage gpgsm.1
14 @ifset manverb
15 .B gpgsm
16 \- CMS encryption and signing tool
17 @end ifset
18
19 @mansect synopsis
20 @ifset manverb
21 .B  gpgsm
22 .RB [ \-\-homedir
23 .IR dir ]
24 .RB [ \-\-options
25 .IR file ]
26 .RI [ options ]
27 .I command
28 .RI [ args ]
29 @end ifset
30
31
32 @mansect description
33 @command{gpgsm} is a tool similar to @command{gpg} to provide digital
34 encryption and signing services on X.509 certificates and the CMS
35 protocol.  It is mainly used as a backend for S/MIME mail processing.
36 @command{gpgsm} includes a full featured certificate management and
37 complies with all rules defined for the German Sphinx project.
38
39 @manpause
40 @xref{Option Index}, for an index to @command{GPGSM}'s commands and options.
41 @mancont
42
43 @menu
44 * GPGSM Commands::        List of all commands.
45 * GPGSM Options::         List of all options.
46 * GPGSM Configuration::   Configuration files.
47 * GPGSM Examples::        Some usage examples.
48
49 Developer information:
50 * Unattended Usage::      Using @command{gpgsm} from other programs.
51 * GPGSM Protocol::        The protocol the server mode uses.
52 @end menu
53
54 @c *******************************************
55 @c ***************            ****************
56 @c ***************  COMMANDS  ****************
57 @c ***************            ****************
58 @c *******************************************
59 @mansect commands
60 @node GPGSM Commands
61 @section Commands
62
63 Commands are not distinguished from options except for the fact that
64 only one command is allowed.
65
66 @menu
67 * General GPGSM Commands::        Commands not specific to the functionality.
68 * Operational GPGSM Commands::    Commands to select the type of operation.
69 * Certificate Management::        How to manage certificates.
70 @end menu
71
72
73 @c *******************************************
74 @c **********  GENERAL COMMANDS  *************
75 @c *******************************************
76 @node General GPGSM Commands
77 @subsection Commands not specific to the function
78
79 @table @gnupgtabopt
80 @item --version
81 @opindex version
82 Print the program version and licensing information.  Note that you
83 cannot abbreviate this command.
84
85 @item --help, -h
86 @opindex help
87 Print a usage message summarizing the most useful command-line options.
88 Note that you cannot abbreviate this command.
89
90 @item --warranty
91 @opindex warranty
92 Print warranty information.  Note that you cannot abbreviate this
93 command.
94
95 @item --dump-options
96 @opindex dump-options
97 Print a list of all available options and commands.  Note that you cannot
98 abbreviate this command.
99 @end table
100
101
102 @c *******************************************
103 @c ********  OPERATIONAL COMMANDS  ***********
104 @c *******************************************
105 @node Operational GPGSM Commands
106 @subsection Commands to select the type of operation
107
108 @table @gnupgtabopt
109 @item --encrypt
110 @opindex encrypt
111 Perform an encryption.  The keys the data is encrypted to must be set
112 using the option @option{--recipient}.
113
114 @item --decrypt
115 @opindex decrypt
116 Perform a decryption; the type of input is automatically determined.  It
117 may either be in binary form or PEM encoded; automatic determination of
118 base-64 encoding is not done.
119
120 @item --sign
121 @opindex sign
122 Create a digital signature.  The key used is either the fist one found
123 in the keybox or those set with the @option{--local-user} option.
124
125 @item --verify
126 @opindex verify
127 Check a signature file for validity.  Depending on the arguments a
128 detached signature may also be checked.
129
130 @item --server
131 @opindex server
132 Run in server mode and wait for commands on the @code{stdin}.
133
134 @item --call-dirmngr @var{command} [@var{args}]
135 @opindex call-dirmngr
136 Behave as a Dirmngr client issuing the request @var{command} with the
137 optional list of @var{args}.  The output of the Dirmngr is printed
138 stdout.  Please note that file names given as arguments should have an
139 absolute file name (i.e. commencing with @code{/}) because they are
140 passed verbatim to the Dirmngr and the working directory of the
141 Dirmngr might not be the same as the one of this client.  Currently it
142 is not possible to pass data via stdin to the Dirmngr.  @var{command}
143 should not contain spaces.
144
145 This is command is required for certain maintaining tasks of the dirmngr
146 where a dirmngr must be able to call back to @command{gpgsm}.  See the Dirmngr
147 manual for details.
148
149 @item --call-protect-tool @var{arguments}
150 @opindex call-protect-tool
151 Certain maintenance operations are done by an external program call
152 @command{gpg-protect-tool}; this is usually not installed in a directory
153 listed in the PATH variable.  This command provides a simple wrapper to
154 access this tool.  @var{arguments} are passed verbatim to this command;
155 use @samp{--help} to get a list of supported operations.
156
157
158 @end table
159
160
161 @c *******************************************
162 @c *******  CERTIFICATE MANAGEMENT  **********
163 @c *******************************************
164 @node Certificate Management
165 @subsection How to manage the certificates and keys
166
167 @table @gnupgtabopt
168 @item --generate-key
169 @opindex generate-key
170 @itemx --gen-key
171 @opindex gen-key
172 This command allows the creation of a certificate signing request or a
173 self-signed certificate.  It is commonly used along with the
174 @option{--output} option to save the created CSR or certificate into a
175 file.  If used with the @option{--batch} a parameter file is used to
176 create the CSR or certificate and it is further possible to create
177 non-self-signed certificates.
178
179 @item --list-keys
180 @itemx -k
181 @opindex list-keys
182 List all available certificates stored in the local key database.
183 Note that the displayed data might be reformatted for better human
184 readability and illegal characters are replaced by safe substitutes.
185
186 @item --list-secret-keys
187 @itemx -K
188 @opindex list-secret-keys
189 List all available certificates for which a corresponding a secret key
190 is available.
191
192 @item --list-external-keys @var{pattern}
193 @opindex list-keys
194 List certificates matching @var{pattern} using an external server.  This
195 utilizes the @code{dirmngr} service.
196
197 @item --list-chain
198 @opindex list-chain
199 Same as @option{--list-keys} but also prints all keys making up the chain.
200
201
202 @item --dump-cert
203 @itemx --dump-keys
204 @opindex dump-cert
205 @opindex dump-keys
206 List all available certificates stored in the local key database using a
207 format useful mainly for debugging.
208
209 @item --dump-chain
210 @opindex dump-chain
211 Same as @option{--dump-keys} but also prints all keys making up the chain.
212
213 @item --dump-secret-keys
214 @opindex dump-secret-keys
215 List all available certificates for which a corresponding a secret key
216 is available using a format useful mainly for debugging.
217
218 @item --dump-external-keys @var{pattern}
219 @opindex dump-external-keys
220 List certificates matching @var{pattern} using an external server.
221 This utilizes the @code{dirmngr} service.  It uses a format useful
222 mainly for debugging.
223
224 @item --keydb-clear-some-cert-flags
225 @opindex keydb-clear-some-cert-flags
226 This is a debugging aid to reset certain flags in the key database
227 which are used to cache certain certificate stati.  It is especially
228 useful if a bad CRL or a weird running OCSP responder did accidentally
229 revoke certificate.  There is no security issue with this command
230 because @command{gpgsm} always make sure that the validity of a certificate is
231 checked right before it is used.
232
233 @item --delete-keys @var{pattern}
234 @opindex delete-keys
235 Delete the keys matching @var{pattern}.  Note that there is no command
236 to delete the secret part of the key directly.  In case you need to do
237 this, you should run the command @code{gpgsm --dump-secret-keys KEYID}
238 before you delete the key, copy the string of hex-digits in the
239 ``keygrip'' line and delete the file consisting of these hex-digits
240 and the suffix @code{.key} from the @file{private-keys-v1.d} directory
241 below our GnuPG home directory (usually @file{~/.gnupg}).
242
243 @item --export [@var{pattern}]
244 @opindex export
245 Export all certificates stored in the Keybox or those specified by the
246 optional @var{pattern}. Those pattern consist of a list of user ids
247 (@pxref{how-to-specify-a-user-id}).  When used along with the
248 @option{--armor} option a few informational lines are prepended before
249 each block.  There is one limitation: As there is no commonly agreed
250 upon way to pack more than one certificate into an ASN.1 structure,
251 the binary export (i.e. without using @option{armor}) works only for
252 the export of one certificate.  Thus it is required to specify a
253 @var{pattern} which yields exactly one certificate.  Ephemeral
254 certificate are only exported if all @var{pattern} are given as
255 fingerprints or keygrips.
256
257 @item --export-secret-key-p12 @var{key-id}
258 @opindex export-secret-key-p12
259 Export the private key and the certificate identified by @var{key-id} in
260 a PKCS#12 format. When used with the @code{--armor} option a few
261 informational lines are prepended to the output.  Note, that the PKCS#12
262 format is not very secure and this command is only provided if there is
263 no other way to exchange the private key. (@xref{option --p12-charset}.)
264
265 @item --export-secret-key-p8 @var{key-id}
266 @itemx --export-secret-key-raw @var{key-id}
267 @opindex export-secret-key-p8
268 @opindex export-secret-key-raw
269 Export the private key of the certificate identified by @var{key-id}
270 with any encryption stripped.  The @code{...-raw} command exports in
271 PKCS#1 format; the @code{...-p8} command exports in PKCS#8 format.
272 When used with the @code{--armor} option a few informational lines are
273 prepended to the output.  These commands are useful to prepare a key
274 for use on a TLS server.
275
276 @item --import [@var{files}]
277 @opindex import
278 Import the certificates from the PEM or binary encoded files as well as
279 from signed-only messages.  This command may also be used to import a
280 secret key from a PKCS#12 file.
281
282 @item --learn-card
283 @opindex learn-card
284 Read information about the private keys from the smartcard and import
285 the certificates from there.  This command utilizes the @command{gpg-agent}
286 and in turn the @command{scdaemon}.
287
288 @item --change-passphrase @var{user_id}
289 @opindex change-passphrase
290 @itemx --passwd @var{user_id}
291 @opindex passwd
292 Change the passphrase of the private key belonging to the certificate
293 specified as @var{user_id}.  Note, that changing the passphrase/PIN of a
294 smartcard is not yet supported.
295
296 @end table
297
298
299 @c *******************************************
300 @c ***************            ****************
301 @c ***************  OPTIONS   ****************
302 @c ***************            ****************
303 @c *******************************************
304 @mansect options
305 @node GPGSM Options
306 @section Option Summary
307
308 @command{GPGSM} features a bunch of options to control the exact behaviour
309 and to change the default configuration.
310
311 @menu
312 * Configuration Options::   How to change the configuration.
313 * Certificate Options::     Certificate related options.
314 * Input and Output::        Input and Output.
315 * CMS Options::             How to change how the CMS is created.
316 * Esoteric Options::        Doing things one usually do not want to do.
317 @end menu
318
319
320 @c *******************************************
321 @c ********  CONFIGURATION OPTIONS  **********
322 @c *******************************************
323 @node Configuration Options
324 @subsection How to change the configuration
325
326 These options are used to change the configuration and are usually found
327 in the option file.
328
329 @table @gnupgtabopt
330
331 @anchor{gpgsm-option --options}
332 @item --options @var{file}
333 @opindex options
334 Reads configuration from @var{file} instead of from the default
335 per-user configuration file.  The default configuration file is named
336 @file{gpgsm.conf} and expected in the @file{.gnupg} directory directly
337 below the home directory of the user.
338
339 @include opt-homedir.texi
340
341
342 @item -v
343 @item --verbose
344 @opindex v
345 @opindex verbose
346 Outputs additional information while running.
347 You can increase the verbosity by giving several
348 verbose commands to @command{gpgsm}, such as @samp{-vv}.
349
350 @item --policy-file @var{filename}
351 @opindex policy-file
352 Change the default name of the policy file to @var{filename}.
353
354 @item --agent-program @var{file}
355 @opindex agent-program
356 Specify an agent program to be used for secret key operations.  The
357 default value is determined by running the command @command{gpgconf}.
358 Note that the pipe symbol (@code{|}) is used for a regression test
359 suite hack and may thus not be used in the file name.
360
361 @item --dirmngr-program @var{file}
362 @opindex dirmngr-program
363 Specify a dirmngr program to be used for @acronym{CRL} checks.  The
364 default value is @file{@value{BINDIR}/dirmngr}.
365
366 @item --prefer-system-dirmngr
367 @opindex prefer-system-dirmngr
368 This option is obsolete and ignored.
369
370 @item --disable-dirmngr
371 Entirely disable the use of the Dirmngr.
372
373 @item --no-autostart
374 @opindex no-autostart
375 Do not start the gpg-agent or the dirmngr if it has not yet been
376 started and its service is required.  This option is mostly useful on
377 machines where the connection to gpg-agent has been redirected to
378 another machines.  If dirmngr is required on the remote machine, it
379 may be started manually using @command{gpgconf --launch dirmngr}.
380
381 @item --no-secmem-warning
382 @opindex no-secmem-warning
383 Do not print a warning when the so called "secure memory" cannot be used.
384
385 @item --log-file @var{file}
386 @opindex log-file
387 When running in server mode, append all logging output to @var{file}.
388 Use @file{socket://} to log to socket.
389
390 @end table
391
392
393 @c *******************************************
394 @c ********  CERTIFICATE OPTIONS  ************
395 @c *******************************************
396 @node Certificate Options
397 @subsection Certificate related options
398
399 @table @gnupgtabopt
400
401 @item  --enable-policy-checks
402 @itemx --disable-policy-checks
403 @opindex enable-policy-checks
404 @opindex disable-policy-checks
405 By default policy checks are enabled.  These options may be used to
406 change it.
407
408 @item  --enable-crl-checks
409 @itemx --disable-crl-checks
410 @opindex enable-crl-checks
411 @opindex disable-crl-checks
412 By default the @acronym{CRL} checks are enabled and the DirMngr is used
413 to check for revoked certificates.  The disable option is most useful
414 with an off-line network connection to suppress this check.
415
416 @item  --enable-trusted-cert-crl-check
417 @itemx --disable-trusted-cert-crl-check
418 @opindex enable-trusted-cert-crl-check
419 @opindex disable-trusted-cert-crl-check
420 By default the @acronym{CRL} for trusted root certificates are checked
421 like for any other certificates.  This allows a CA to revoke its own
422 certificates voluntary without the need of putting all ever issued
423 certificates into a CRL.  The disable option may be used to switch this
424 extra check off.  Due to the caching done by the Dirmngr, there will not be
425 any noticeable performance gain.  Note, that this also disables possible
426 OCSP checks for trusted root certificates.  A more specific way of
427 disabling this check is by adding the ``relax'' keyword to the root CA
428 line of the @file{trustlist.txt}
429
430
431 @item --force-crl-refresh
432 @opindex force-crl-refresh
433 Tell the dirmngr to reload the CRL for each request.  For better
434 performance, the dirmngr will actually optimize this by suppressing
435 the loading for short time intervals (e.g. 30 minutes). This option
436 is useful to make sure that a fresh CRL is available for certificates
437 hold in the keybox.  The suggested way of doing this is by using it
438 along with the option @option{--with-validation} for a key listing
439 command.  This option should not be used in a configuration file.
440
441 @item  --enable-ocsp
442 @itemx --disable-ocsp
443 @opindex enable-ocsp
444 @opindex disable-ocsp
445 By default @acronym{OCSP} checks are disabled.  The enable option may
446 be used to enable OCSP checks via Dirmngr.  If @acronym{CRL} checks
447 are also enabled, CRLs will be used as a fallback if for some reason an
448 OCSP request will not succeed.  Note, that you have to allow OCSP
449 requests in Dirmngr's configuration too (option
450 @option{--allow-ocsp}) and configure Dirmngr properly.  If you do not do
451 so you will get the error code @samp{Not supported}.
452
453 @item --auto-issuer-key-retrieve
454 @opindex auto-issuer-key-retrieve
455 If a required certificate is missing while validating the chain of
456 certificates, try to load that certificate from an external location.
457 This usually means that Dirmngr is employed to search for the
458 certificate.  Note that this option makes a "web bug" like behavior
459 possible.  LDAP server operators can see which keys you request, so by
460 sending you a message signed by a brand new key (which you naturally
461 will not have on your local keybox), the operator can tell both your IP
462 address and the time when you verified the signature.
463
464
465 @anchor{gpgsm-option --validation-model}
466 @item --validation-model @var{name}
467 @opindex validation-model
468 This option changes the default validation model.  The only possible
469 values are "shell" (which is the default), "chain" which forces the
470 use of the chain model and "steed" for a new simplified model.  The
471 chain model is also used if an option in the @file{trustlist.txt} or
472 an attribute of the certificate requests it.  However the standard
473 model (shell) is in that case always tried first.
474
475 @item --ignore-cert-extension @var{oid}
476 @opindex ignore-cert-extension
477 Add @var{oid} to the list of ignored certificate extensions.  The
478 @var{oid} is expected to be in dotted decimal form, like
479 @code{2.5.29.3}.  This option may be used more than once.  Critical
480 flagged certificate extensions matching one of the OIDs in the list
481 are treated as if they are actually handled and thus the certificate
482 will not be rejected due to an unknown critical extension.  Use this
483 option with care because extensions are usually flagged as critical
484 for a reason.
485
486 @end table
487
488 @c *******************************************
489 @c ***********  INPUT AND OUTPUT  ************
490 @c *******************************************
491 @node Input and Output
492 @subsection Input and Output
493
494 @table @gnupgtabopt
495 @item --armor
496 @itemx -a
497 @opindex armor
498 Create PEM encoded output.  Default is binary output.
499
500 @item --base64
501 @opindex base64
502 Create Base-64 encoded output; i.e. PEM without the header lines.
503
504 @item --assume-armor
505 @opindex assume-armor
506 Assume the input data is PEM encoded.  Default is to autodetect the
507 encoding but this is may fail.
508
509 @item --assume-base64
510 @opindex assume-base64
511 Assume the input data is plain base-64 encoded.
512
513 @item --assume-binary
514 @opindex assume-binary
515 Assume the input data is binary encoded.
516
517 @anchor{option --p12-charset}
518 @item --p12-charset @var{name}
519 @opindex p12-charset
520 @command{gpgsm} uses the UTF-8 encoding when encoding passphrases for
521 PKCS#12 files.  This option may be used to force the passphrase to be
522 encoded in the specified encoding @var{name}.  This is useful if the
523 application used to import the key uses a different encoding and thus
524 will not be able to import a file generated by @command{gpgsm}.  Commonly
525 used values for @var{name} are @code{Latin1} and @code{CP850}.  Note
526 that @command{gpgsm} itself automagically imports any file with a
527 passphrase encoded to the most commonly used encodings.
528
529
530 @item --default-key @var{user_id}
531 @opindex default-key
532 Use @var{user_id} as the standard key for signing.  This key is used if
533 no other key has been defined as a signing key.  Note, that the first
534 @option{--local-users} option also sets this key if it has not yet been
535 set; however @option{--default-key} always overrides this.
536
537
538 @item --local-user @var{user_id}
539 @item -u @var{user_id}
540 @opindex local-user
541 Set the user(s) to be used for signing.  The default is the first
542 secret key found in the database.
543
544
545 @item --recipient @var{name}
546 @itemx -r
547 @opindex recipient
548 Encrypt to the user id @var{name}.  There are several ways a user id
549 may be given (@pxref{how-to-specify-a-user-id}).
550
551
552 @item --output @var{file}
553 @itemx -o @var{file}
554 @opindex output
555 Write output to @var{file}.  The default is to write it to stdout.
556
557
558 @anchor{gpgsm-option --with-key-data}
559 @item --with-key-data
560 @opindex with-key-data
561 Displays extra information with the @code{--list-keys} commands.  Especially
562 a line tagged @code{grp} is printed which tells you the keygrip of a
563 key.  This string is for example used as the file name of the
564 secret key.  Implies @code{--with-colons}.
565
566 @anchor{gpgsm-option --with-validation}
567 @item --with-validation
568 @opindex with-validation
569 When doing a key listing, do a full validation check for each key and
570 print the result.  This is usually a slow operation because it
571 requires a CRL lookup and other operations.
572
573 When used along with @option{--import}, a validation of the certificate to
574 import is done and only imported if it succeeds the test.  Note that
575 this does not affect an already available certificate in the DB.
576 This option is therefore useful to simply verify a certificate.
577
578
579 @item --with-md5-fingerprint
580 For standard key listings, also print the MD5 fingerprint of the
581 certificate.
582
583 @item --with-keygrip
584 Include the keygrip in standard key listings.  Note that the keygrip is
585 always listed in @option{--with-colons} mode.
586
587 @item --with-secret
588 @opindex with-secret
589 Include info about the presence of a secret key in public key listings
590 done with @code{--with-colons}.
591
592 @end table
593
594 @c *******************************************
595 @c *************  CMS OPTIONS  ***************
596 @c *******************************************
597 @node CMS Options
598 @subsection How to change how the CMS is created
599
600 @table @gnupgtabopt
601 @item --include-certs @var{n}
602 @opindex include-certs
603 Using @var{n} of -2 includes all certificate except for the root cert,
604 -1 includes all certs, 0 does not include any certs, 1 includes only the
605 signers cert and all other positive values include up to @var{n}
606 certificates starting with the signer cert.  The default is -2.
607
608 @item --cipher-algo @var{oid}
609 @opindex cipher-algo
610 Use the cipher algorithm with the ASN.1 object identifier @var{oid} for
611 encryption.  For convenience the strings @code{3DES}, @code{AES} and
612 @code{AES256} may be used instead of their OIDs.  The default is
613 @code{AES} (2.16.840.1.101.3.4.1.2).
614
615 @item --digest-algo @code{name}
616 Use @code{name} as the message digest algorithm.  Usually this
617 algorithm is deduced from the respective signing certificate.  This
618 option forces the use of the given algorithm and may lead to severe
619 interoperability problems.
620
621 @end table
622
623
624
625 @c *******************************************
626 @c ********  ESOTERIC OPTIONS  ***************
627 @c *******************************************
628 @node Esoteric Options
629 @subsection Doing things one usually do not want to do
630
631
632 @table @gnupgtabopt
633
634 @item --extra-digest-algo @var{name}
635 @opindex extra-digest-algo
636 Sometimes signatures are broken in that they announce a different digest
637 algorithm than actually used.  @command{gpgsm} uses a one-pass data
638 processing model and thus needs to rely on the announced digest
639 algorithms to properly hash the data.  As a workaround this option may
640 be used to tell @command{gpgsm} to also hash the data using the algorithm
641 @var{name}; this slows processing down a little bit but allows verification of
642 such broken signatures.  If @command{gpgsm} prints an error like
643 ``digest algo 8 has not been enabled'' you may want to try this option,
644 with @samp{SHA256} for @var{name}.
645
646
647 @item --faked-system-time @var{epoch}
648 @opindex faked-system-time
649 This option is only useful for testing; it sets the system time back or
650 forth to @var{epoch} which is the number of seconds elapsed since the year
651 1970.  Alternatively @var{epoch} may be given as a full ISO time string
652 (e.g. "20070924T154812").
653
654 @item --with-ephemeral-keys
655 @opindex with-ephemeral-keys
656 Include ephemeral flagged keys in the output of key listings.  Note
657 that they are included anyway if the key specification for a listing
658 is given as fingerprint or keygrip.
659
660 @item --debug-level @var{level}
661 @opindex debug-level
662 Select the debug level for investigating problems. @var{level} may be
663 a numeric value or by a keyword:
664
665 @table @code
666 @item none
667 No debugging at all.  A value of less than 1 may be used instead of
668 the keyword.
669 @item basic
670 Some basic debug messages.  A value between 1 and 2 may be used
671 instead of the keyword.
672 @item advanced
673 More verbose debug messages.  A value between 3 and 5 may be used
674 instead of the keyword.
675 @item expert
676 Even more detailed messages.  A value between 6 and 8 may be used
677 instead of the keyword.
678 @item guru
679 All of the debug messages you can get. A value greater than 8 may be
680 used instead of the keyword.  The creation of hash tracing files is
681 only enabled if the keyword is used.
682 @end table
683
684 How these messages are mapped to the actual debugging flags is not
685 specified and may change with newer releases of this program. They are
686 however carefully selected to best aid in debugging.
687
688 @item --debug @var{flags}
689 @opindex debug
690 This option is only useful for debugging and the behaviour may change
691 at any time without notice; using @code{--debug-levels} is the
692 preferred method to select the debug verbosity.  FLAGS are bit encoded
693 and may be given in usual C-Syntax. The currently defined bits are:
694
695 @table @code
696 @item 0  (1)
697 X.509 or OpenPGP protocol related data
698 @item 1  (2)
699 values of big number integers
700 @item 2  (4)
701 low level crypto operations
702 @item 5  (32)
703 memory allocation
704 @item 6  (64)
705 caching
706 @item 7  (128)
707 show memory statistics
708 @item 9  (512)
709 write hashed data to files named @code{dbgmd-000*}
710 @item 10 (1024)
711 trace Assuan protocol
712 @end table
713
714 Note, that all flags set using this option may get overridden by
715 @code{--debug-level}.
716
717 @item --debug-all
718 @opindex debug-all
719 Same as @code{--debug=0xffffffff}
720
721 @item --debug-allow-core-dump
722 @opindex debug-allow-core-dump
723 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
724 disabling core dumps for security reasons.  However, bugs are pretty
725 durable beasts and to squash them it is sometimes useful to have a core
726 dump.  This option enables core dumps unless the Bad Thing happened
727 before the option parsing.
728
729 @item --debug-no-chain-validation
730 @opindex debug-no-chain-validation
731 This is actually not a debugging option but only useful as such.  It
732 lets @command{gpgsm} bypass all certificate chain validation checks.
733
734 @item --debug-ignore-expiration
735 @opindex debug-ignore-expiration
736 This is actually not a debugging option but only useful as such.  It
737 lets @command{gpgsm} ignore all notAfter dates, this is used by the regression
738 tests.
739
740 @item --passphrase-fd @code{n}
741 @opindex passphrase-fd
742 Read the passphrase from file descriptor @code{n}. Only the first line
743 will be read from file descriptor @code{n}. If you use 0 for @code{n},
744 the passphrase will be read from STDIN. This can only be used if only
745 one passphrase is supplied.
746
747 Note that this passphrase is only used if the option @option{--batch}
748 has also been given.
749
750 @item --pinentry-mode @code{mode}
751 @opindex pinentry-mode
752 Set the pinentry mode to @code{mode}.  Allowed values for @code{mode}
753 are:
754 @table @asis
755   @item default
756   Use the default of the agent, which is @code{ask}.
757   @item ask
758   Force the use of the Pinentry.
759   @item cancel
760   Emulate use of Pinentry's cancel button.
761   @item error
762   Return a Pinentry error (``No Pinentry'').
763   @item loopback
764   Redirect Pinentry queries to the caller.  Note that in contrast to
765   Pinentry the user is not prompted again if he enters a bad password.
766 @end table
767
768 @item --no-common-certs-import
769 @opindex no-common-certs-import
770 Suppress the import of common certificates on keybox creation.
771
772 @end table
773
774 All the long options may also be given in the configuration file after
775 stripping off the two leading dashes.
776
777 @c *******************************************
778 @c ***************            ****************
779 @c ***************  USER ID   ****************
780 @c ***************            ****************
781 @c *******************************************
782 @mansect how to specify a user id
783 @ifset isman
784 @include specify-user-id.texi
785 @end ifset
786
787 @c *******************************************
788 @c ***************            ****************
789 @c ***************   FILES    ****************
790 @c ***************            ****************
791 @c *******************************************
792 @mansect files
793 @node GPGSM Configuration
794 @section Configuration files
795
796 There are a few configuration files to control certain aspects of
797 @command{gpgsm}'s operation. Unless noted, they are expected in the
798 current home directory (@pxref{option --homedir}).
799
800 @table @file
801
802 @item gpgsm.conf
803 @efindex gpgsm.conf
804 This is the standard configuration file read by @command{gpgsm} on
805 startup.  It may contain any valid long option; the leading two dashes
806 may not be entered and the option may not be abbreviated.  This default
807 name may be changed on the command line (@pxref{gpgsm-option --options}).
808 You should backup this file.
809
810
811 @item policies.txt
812 @efindex policies.txt
813 This is a list of allowed CA policies.  This file should list the
814 object identifiers of the policies line by line.  Empty lines and
815 lines starting with a hash mark are ignored.  Policies missing in this
816 file and not marked as critical in the certificate will print only a
817 warning; certificates with policies marked as critical and not listed
818 in this file will fail the signature verification.  You should backup
819 this file.
820
821 For example, to allow only the policy 2.289.9.9, the file should look
822 like this:
823
824 @c man:.RS
825 @example
826 # Allowed policies
827 2.289.9.9
828 @end example
829 @c man:.RE
830
831 @item qualified.txt
832 @efindex qualified.txt
833 This is the list of root certificates used for qualified certificates.
834 They are defined as certificates capable of creating legally binding
835 signatures in the same way as handwritten signatures are.  Comments
836 start with a hash mark and empty lines are ignored.  Lines do have a
837 length limit but this is not a serious limitation as the format of the
838 entries is fixed and checked by @command{gpgsm}: A non-comment line starts with
839 optional whitespace, followed by exactly 40 hex characters, white space
840 and a lowercased 2 letter country code.  Additional data delimited with
841 by a white space is current ignored but might late be used for other
842 purposes.
843
844 Note that even if a certificate is listed in this file, this does not
845 mean that the certificate is trusted; in general the certificates listed
846 in this file need to be listed also in @file{trustlist.txt}.
847
848 This is a global file an installed in the data directory
849 (e.g. @file{@value{DATADIR}/qualified.txt}).  GnuPG installs a suitable
850 file with root certificates as used in Germany.  As new Root-CA
851 certificates may be issued over time, these entries may need to be
852 updated; new distributions of this software should come with an updated
853 list but it is still the responsibility of the Administrator to check
854 that this list is correct.
855
856 Every time @command{gpgsm} uses a certificate for signing or verification
857 this file will be consulted to check whether the certificate under
858 question has ultimately been issued by one of these CAs.  If this is the
859 case the user will be informed that the verified signature represents a
860 legally binding (``qualified'') signature.  When creating a signature
861 using such a certificate an extra prompt will be issued to let the user
862 confirm that such a legally binding signature shall really be created.
863
864 Because this software has not yet been approved for use with such
865 certificates, appropriate notices will be shown to indicate this fact.
866
867 @item help.txt
868 @efindex help.txt
869 This is plain text file with a few help entries used with
870 @command{pinentry} as well as a large list of help items for
871 @command{gpg} and @command{gpgsm}.  The standard file has English help
872 texts; to install localized versions use filenames like @file{help.LL.txt}
873 with LL denoting the locale.  GnuPG comes with a set of predefined help
874 files in the data directory (e.g. @file{@value{DATADIR}/gnupg/help.de.txt})
875 and allows overriding of any help item by help files stored in the
876 system configuration directory (e.g. @file{@value{SYSCONFDIR}/help.de.txt}).
877 For a reference of the help file's syntax, please see the installed
878 @file{help.txt} file.
879
880
881 @item com-certs.pem
882 @efindex com-certs.pem
883 This file is a collection of common certificates used to populated a
884 newly created @file{pubring.kbx}.  An administrator may replace this
885 file with a custom one.  The format is a concatenation of PEM encoded
886 X.509 certificates.  This global file is installed in the data directory
887 (e.g. @file{@value{DATADIR}/com-certs.pem}).
888
889 @end table
890
891 @c man:.RE
892 Note that on larger installations, it is useful to put predefined files
893 into the directory @file{/etc/skel/.gnupg/} so that newly created users
894 start up with a working configuration.  For existing users a small
895 helper script is provided to create these files (@pxref{addgnupghome}).
896
897 For internal purposes @command{gpgsm} creates and maintains a few other files;
898 they all live in the current home directory (@pxref{option
899 --homedir}).  Only @command{gpgsm} may modify these files.
900
901
902 @table @file
903 @item pubring.kbx
904 @efindex pubring.kbx
905 This a database file storing the certificates as well as meta
906 information.  For debugging purposes the tool @command{kbxutil} may be
907 used to show the internal structure of this file.  You should backup
908 this file.
909
910 @item random_seed
911 @efindex random_seed
912 This content of this file is used to maintain the internal state of the
913 random number generator across invocations.  The same file is used by
914 other programs of this software too.
915
916 @item S.gpg-agent
917 @efindex S.gpg-agent
918 If this file exists
919 @command{gpgsm} will first try to connect to this socket for
920 accessing @command{gpg-agent} before starting a new @command{gpg-agent}
921 instance.  Under Windows this socket (which in reality be a plain file
922 describing a regular TCP listening port) is the standard way of
923 connecting the @command{gpg-agent}.
924
925 @end table
926
927
928 @c *******************************************
929 @c ***************            ****************
930 @c ***************  EXAMPLES  ****************
931 @c ***************            ****************
932 @c *******************************************
933 @mansect examples
934 @node GPGSM Examples
935 @section Examples
936
937 @example
938 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
939 @end example
940
941
942 @c *******************************************
943 @c ***************              **************
944 @c ***************  UNATTENDED  **************
945 @c ***************              **************
946 @c *******************************************
947 @manpause
948 @node Unattended Usage
949 @section Unattended Usage
950
951 @command{gpgsm} is often used as a backend engine by other software.  To help
952 with this a machine interface has been defined to have an unambiguous
953 way to do this.  This is most likely used with the @code{--server} command
954 but may also be used in the standard operation mode by using the
955 @code{--status-fd} option.
956
957 @menu
958 * Automated signature checking::  Automated signature checking.
959 * CSR and certificate creation::  CSR and certificate creation.
960 @end menu
961
962 @node Automated signature checking
963 @subsection Automated signature checking
964
965 It is very important to understand the semantics used with signature
966 verification.  Checking a signature is not as simple as it may sound and
967 so the operation is a bit complicated.  In most cases it is required
968 to look at several status lines.  Here is a table of all cases a signed
969 message may have:
970
971 @table @asis
972 @item The signature is valid
973 This does mean that the signature has been successfully verified, the
974 certificates are all sane.  However there are two subcases with
975 important information:  One of the certificates may have expired or a
976 signature of a message itself as expired.  It is a sound practise to
977 consider such a signature still as valid but additional information
978 should be displayed.  Depending on the subcase @command{gpgsm} will issue
979 these status codes:
980   @table @asis
981   @item signature valid and nothing did expire
982   @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
983   @item signature valid but at least one certificate has expired
984   @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
985   @item signature valid but expired
986   @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
987   Note, that this case is currently not implemented.
988   @end table
989
990 @item The signature is invalid
991 This means that the signature verification failed (this is an indication
992 of a transfer error, a program error or tampering with the message).
993 @command{gpgsm} issues one of these status codes sequences:
994   @table @code
995   @item  @code{BADSIG}
996   @item  @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
997   @end table
998
999 @item Error verifying a signature
1000 For some reason the signature could not be verified, i.e. it cannot be
1001 decided whether the signature is valid or invalid.  A common reason for
1002 this is a missing certificate.
1003
1004 @end table
1005
1006 @node CSR and certificate creation
1007 @subsection CSR and certificate creation
1008
1009 The command @option{--generate-key} may be used along with the option
1010 @option{--batch} to either create a certificate signing request (CSR)
1011 or an X.509 certificate.  This is controlled by a parameter file; the
1012 format of this file is as follows:
1013
1014 @itemize @bullet
1015 @item Text only, line length is limited to about 1000 characters.
1016 @item UTF-8 encoding must be used to specify non-ASCII characters.
1017 @item Empty lines are ignored.
1018 @item Leading and trailing while space is ignored.
1019 @item A hash sign as the first non white space character indicates
1020 a comment line.
1021 @item Control statements are indicated by a leading percent sign, the
1022 arguments are separated by white space from the keyword.
1023 @item Parameters are specified by a keyword, followed by a colon.  Arguments
1024 are separated by white space.
1025 @item The first parameter must be @samp{Key-Type}, control statements
1026 may be placed anywhere.
1027 @item
1028 The order of the parameters does not matter except for @samp{Key-Type}
1029 which must be the first parameter.  The parameters are only used for
1030 the generated CSR/certificate; parameters from previous sets are not
1031 used.  Some syntactically checks may be performed.
1032 @item
1033 Key generation takes place when either the end of the parameter file
1034 is reached, the next @samp{Key-Type} parameter is encountered or at the
1035 control statement @samp{%commit} is encountered.
1036 @end itemize
1037
1038 @noindent
1039 Control statements:
1040
1041 @table @asis
1042
1043 @item %echo @var{text}
1044 Print @var{text} as diagnostic.
1045
1046 @item %dry-run
1047 Suppress actual key generation (useful for syntax checking).
1048
1049 @item %commit
1050 Perform the key generation.  Note that an implicit commit is done at
1051 the next @asis{Key-Type} parameter.
1052
1053 @c  %certfile <filename>
1054 @c      [Not yet implemented!]
1055 @c      Do not write the certificate to the keyDB but to <filename>.
1056 @c      This must be given before the first
1057 @c      commit to take place, duplicate specification of the same filename
1058 @c      is ignored, the last filename before a commit is used.
1059 @c      The filename is used until a new filename is used (at commit points)
1060 @c      and all keys are written to that file.  If a new filename is given,
1061 @c      this file is created (and overwrites an existing one).
1062 @c      Both control statements must be given.
1063 @end table
1064
1065 @noindent
1066 General Parameters:
1067
1068 @table @asis
1069
1070 @item Key-Type: @var{algo}
1071 Starts a new parameter block by giving the type of the primary
1072 key. The algorithm must be capable of signing.  This is a required
1073 parameter.  The only supported value for @var{algo} is @samp{rsa}.
1074
1075 @item Key-Length: @var{nbits}
1076 The requested length of a generated key in bits.  Defaults to 2048.
1077
1078 @item Key-Grip: @var{hexstring}
1079 This is optional and used to generate a CSR or certificate for an
1080 already existing key.  Key-Length will be ignored when given.
1081
1082 @item Key-Usage: @var{usage-list}
1083 Space or comma delimited list of key usage, allowed values are
1084 @samp{encrypt}, @samp{sign} and @samp{cert}.  This is used to generate
1085 the keyUsage extension.  Please make sure that the algorithm is
1086 capable of this usage.  Default is to allow encrypt and sign.
1087
1088 @item Name-DN: @var{subject-name}
1089 This is the Distinguished Name (DN) of the subject in RFC-2253 format.
1090
1091 @item Name-Email: @var{string}
1092 This is an email address for the altSubjectName.  This parameter is
1093 optional but may occur several times to add several email addresses to
1094 a certificate.
1095
1096 @item Name-DNS: @var{string}
1097 The is an DNS name for the altSubjectName.  This parameter is optional
1098 but may occur several times to add several DNS names to a certificate.
1099
1100 @item Name-URI: @var{string}
1101 This is an URI for the altSubjectName.  This parameter is optional but
1102 may occur several times to add several URIs to a certificate.
1103 @end table
1104
1105 @noindent
1106 Additional parameters used to create a certificate (in contrast to a
1107 certificate signing request):
1108
1109 @table @asis
1110
1111 @item Serial: @var{sn}
1112 If this parameter is given an X.509 certificate will be generated.
1113 @var{sn} is expected to be a hex string representing an unsigned
1114 integer of arbitrary length.  The special value @samp{random} can be
1115 used to create a 64 bit random serial number.
1116
1117 @item Issuer-DN: @var{issuer-name}
1118 This is the DN name of the issuer in RFC-2253 format.  If it is not set
1119 it will default to the subject DN and a special GnuPG extension will
1120 be included in the certificate to mark it as a standalone certificate.
1121
1122 @item Creation-Date: @var{iso-date}
1123 @itemx Not-Before: @var{iso-date}
1124 Set the notBefore date of the certificate.  Either a date like
1125 @samp{1986-04-26} or @samp{1986-04-26 12:00} or a standard ISO
1126 timestamp like @samp{19860426T042640} may be used.  The time is
1127 considered to be UTC.  If it is not given the current date is used.
1128
1129 @item Expire-Date: @var{iso-date}
1130 @itemx Not-After: @var{iso-date}
1131 Set the notAfter date of the certificate.  Either a date like
1132 @samp{2063-04-05} or @samp{2063-04-05 17:00} or a standard ISO
1133 timestamp like @samp{20630405T170000} may be used.  The time is
1134 considered to be UTC.  If it is not given a default value in the not
1135 too far future is used.
1136
1137 @item Signing-Key: @var{keygrip}
1138 This gives the keygrip of the key used to sign the certificate.  If it
1139 is not given a self-signed certificate will be created.  For
1140 compatibility with future versions, it is suggested to prefix the
1141 keygrip with a @samp{&}.
1142
1143 @item Hash-Algo: @var{hash-algo}
1144 Use @var{hash-algo} for this CSR or certificate.  The supported hash
1145 algorithms are: @samp{sha1}, @samp{sha256}, @samp{sha384} and
1146 @samp{sha512}; they may also be specified with uppercase letters.  The
1147 default is @samp{sha256}.
1148
1149 @end table
1150
1151 @c *******************************************
1152 @c ***************           *****************
1153 @c ***************  ASSSUAN  *****************
1154 @c ***************           *****************
1155 @c *******************************************
1156 @node GPGSM Protocol
1157 @section The Protocol the Server Mode Uses
1158
1159 Description of the protocol used to access @command{GPGSM}.
1160 @command{GPGSM} does implement the Assuan protocol and in addition
1161 provides a regular command line interface which exhibits a full client
1162 to this protocol (but uses internal linking).  To start
1163 @command{gpgsm} as a server the command line the option
1164 @code{--server} must be used.  Additional options are provided to
1165 select the communication method (i.e. the name of the socket).
1166
1167 We assume that the connection has already been established; see the
1168 Assuan manual for details.
1169
1170 @menu
1171 * GPGSM ENCRYPT::         Encrypting a message.
1172 * GPGSM DECRYPT::         Decrypting a message.
1173 * GPGSM SIGN::            Signing a message.
1174 * GPGSM VERIFY::          Verifying a message.
1175 * GPGSM GENKEY::          Generating a key.
1176 * GPGSM LISTKEYS::        List available keys.
1177 * GPGSM EXPORT::          Export certificates.
1178 * GPGSM IMPORT::          Import certificates.
1179 * GPGSM DELETE::          Delete certificates.
1180 * GPGSM GETAUDITLOG::     Retrieve an audit log.
1181 * GPGSM GETINFO::         Information about the process
1182 * GPGSM OPTION::          Session options.
1183 @end menu
1184
1185
1186 @node GPGSM ENCRYPT
1187 @subsection Encrypting a Message
1188
1189 Before encryption can be done the recipient must be set using the
1190 command:
1191
1192 @example
1193   RECIPIENT @var{userID}
1194 @end example
1195
1196 Set the recipient for the encryption.  @var{userID} should be the
1197 internal representation of the key; the server may accept any other way
1198 of specification.  If this is a valid and trusted recipient the server
1199 does respond with OK, otherwise the return is an ERR with the reason why
1200 the recipient cannot be used, the encryption will then not be done for
1201 this recipient.  If the policy is not to encrypt at all if not all
1202 recipients are valid, the client has to take care of this.  All
1203 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
1204 successful @code{ENCRYPT} command.
1205
1206 @example
1207   INPUT FD[=@var{n}] [--armor|--base64|--binary]
1208 @end example
1209
1210 Set the file descriptor for the message to be encrypted to @var{n}.
1211 Obviously the pipe must be open at that point, the server establishes
1212 its own end.  If the server returns an error the client should consider
1213 this session failed.  If @var{n} is not given, this commands uses the
1214 last file descriptor passed to the application.
1215 @xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan
1216 manual}, on how to do descriptor passing.
1217
1218 The @code{--armor} option may be used to advice the server that the
1219 input data is in @acronym{PEM} format, @code{--base64} advices that a
1220 raw base-64 encoding is used, @code{--binary} advices of raw binary
1221 input (@acronym{BER}).  If none of these options is used, the server
1222 tries to figure out the used encoding, but this may not always be
1223 correct.
1224
1225 @example
1226   OUTPUT FD[=@var{n}] [--armor|--base64]
1227 @end example
1228
1229 Set the file descriptor to be used for the output (i.e. the encrypted
1230 message). Obviously the pipe must be open at that point, the server
1231 establishes its own end.  If the server returns an error the client
1232 should consider this session failed.
1233
1234 The option @option{--armor} encodes the output in @acronym{PEM} format, the
1235 @option{--base64} option applies just a base-64 encoding.  No option
1236 creates binary output (@acronym{BER}).
1237
1238 The actual encryption is done using the command
1239
1240 @example
1241   ENCRYPT
1242 @end example
1243
1244 It takes the plaintext from the @code{INPUT} command, writes to the
1245 ciphertext to the file descriptor set with the @code{OUTPUT} command,
1246 take the recipients from all the recipients set so far.  If this command
1247 fails the clients should try to delete all output currently done or
1248 otherwise mark it as invalid.  @command{GPGSM} does ensure that there
1249 will not be any
1250 security problem with leftover data on the output in this case.
1251
1252 This command should in general not fail, as all necessary checks have
1253 been done while setting the recipients.  The input and output pipes are
1254 closed.
1255
1256
1257 @node GPGSM DECRYPT
1258 @subsection Decrypting a message
1259
1260 Input and output FDs are set the same way as in encryption, but
1261 @code{INPUT} refers to the ciphertext and @code{OUTPUT} to the plaintext. There
1262 is no need to set recipients.  @command{GPGSM} automatically strips any
1263 @acronym{S/MIME} headers from the input, so it is valid to pass an
1264 entire MIME part to the INPUT pipe.
1265
1266 The decryption is done by using the command
1267
1268 @example
1269   DECRYPT
1270 @end example
1271
1272 It performs the decrypt operation after doing some check on the internal
1273 state (e.g. that all needed data has been set).  Because it utilizes
1274 the GPG-Agent for the session key decryption, there is no need to ask
1275 the client for a protecting passphrase - GpgAgent takes care of this by
1276 requesting this from the user.
1277
1278
1279 @node GPGSM SIGN
1280 @subsection Signing a Message
1281
1282 Signing is usually done with these commands:
1283
1284 @example
1285   INPUT FD[=@var{n}] [--armor|--base64|--binary]
1286 @end example
1287
1288 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
1289
1290 @example
1291   OUTPUT FD[=@var{m}] [--armor|--base64]
1292 @end example
1293
1294 Write the output to file descriptor @var{m}.  If a detached signature is
1295 requested, only the signature is written.
1296
1297 @example
1298   SIGN [--detached]
1299 @end example
1300
1301 Sign the data set with the @code{INPUT} command and write it to the sink set by
1302 @code{OUTPUT}.  With @code{--detached}, a detached signature is created
1303 (surprise).
1304
1305 The key used for signing is the default one or the one specified in
1306 the configuration file.  To get finer control over the keys, it is
1307 possible to use the command
1308
1309 @example
1310   SIGNER @var{userID}
1311 @end example
1312
1313 to set the signer's key.  @var{userID} should be the
1314 internal representation of the key; the server may accept any other way
1315 of specification.  If this is a valid and trusted recipient the server
1316 does respond with OK, otherwise the return is an ERR with the reason why
1317 the key cannot be used, the signature will then not be created using
1318 this key.  If the policy is not to sign at all if not all
1319 keys are valid, the client has to take care of this.  All
1320 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
1321 Note that a @code{SIGN} does not reset this list of signers which is in
1322 contrast to the @code{RECIPIENT} command.
1323
1324
1325 @node GPGSM VERIFY
1326 @subsection Verifying a Message
1327
1328 To verify a message the command:
1329
1330 @example
1331   VERIFY
1332 @end example
1333
1334 is used. It does a verify operation on the message send to the input FD.
1335 The result is written out using status lines.  If an output FD was
1336 given, the signed text will be written to that.  If the signature is a
1337 detached one, the server will inquire about the signed material and the
1338 client must provide it.
1339
1340 @node GPGSM GENKEY
1341 @subsection Generating a Key
1342
1343 This is used to generate a new keypair, store the secret part in the
1344 @acronym{PSE} and the public key in the key database.  We will probably
1345 add optional commands to allow the client to select whether a hardware
1346 token is used to store the key.  Configuration options to
1347 @command{GPGSM} can be used to restrict the use of this command.
1348
1349 @example
1350   GENKEY
1351 @end example
1352
1353 @command{GPGSM} checks whether this command is allowed and then does an
1354 INQUIRY to get the key parameters, the client should then send the
1355 key parameters in the native format:
1356
1357 @example
1358     S: INQUIRE KEY_PARAM native
1359     C: D foo:fgfgfg
1360     C: D bar
1361     C: END
1362 @end example
1363
1364 Please note that the server may send Status info lines while reading the
1365 data lines from the client.  After this the key generation takes place
1366 and the server eventually does send an ERR or OK response.  Status lines
1367 may be issued as a progress indicator.
1368
1369
1370 @node GPGSM LISTKEYS
1371 @subsection List available keys
1372 @anchor{gpgsm-cmd listkeys}
1373
1374 To list the keys in the internal database or using an external key
1375 provider, the command:
1376
1377 @example
1378   LISTKEYS  @var{pattern}
1379 @end example
1380
1381 is used.  To allow multiple patterns (which are ORed during the search)
1382 quoting is required: Spaces are to be translated into "+" or into "%20";
1383 in turn this requires that the usual escape quoting rules are done.
1384
1385 @example
1386   LISTSECRETKEYS @var{pattern}
1387 @end example
1388
1389 Lists only the keys where a secret key is available.
1390
1391 The list commands are affected by the option
1392
1393 @example
1394   OPTION list-mode=@var{mode}
1395 @end example
1396
1397 where mode may be:
1398 @table @code
1399 @item 0
1400 Use default (which is usually the same as 1).
1401 @item 1
1402 List only the internal keys.
1403 @item 2
1404 List only the external keys.
1405 @item 3
1406 List internal and external keys.
1407 @end table
1408
1409 Note that options are valid for the entire session.
1410
1411
1412 @node GPGSM EXPORT
1413 @subsection Export certificates
1414
1415 To export certificate from the internal key database the command:
1416
1417 @example
1418   EXPORT [--data [--armor] [--base64]] [--] @var{pattern}
1419 @end example
1420
1421 is used.  To allow multiple patterns (which are ORed) quoting is
1422 required: Spaces are to be translated into "+" or into "%20"; in turn
1423 this requires that the usual escape quoting rules are done.
1424
1425 If the @option{--data} option has not been given, the format of the
1426 output depends on what was set with the @code{OUTPUT} command.  When using
1427 @acronym{PEM} encoding a few informational lines are prepended.
1428
1429 If the @option{--data} has been given, a target set via @code{OUTPUT} is
1430 ignored and the data is returned inline using standard
1431 @code{D}-lines. This avoids the need for an extra file descriptor.  In
1432 this case the options @option{--armor} and @option{--base64} may be used
1433 in the same way as with the @code{OUTPUT} command.
1434
1435
1436 @node GPGSM IMPORT
1437 @subsection Import certificates
1438
1439 To import certificates into the internal key database, the command
1440
1441 @example
1442   IMPORT [--re-import]
1443 @end example
1444
1445 is used.  The data is expected on the file descriptor set with the
1446 @code{INPUT} command.  Certain checks are performed on the
1447 certificate.  Note that the code will also handle PKCS#12 files and
1448 import private keys; a helper program is used for that.
1449
1450 With the option @option{--re-import} the input data is expected to a be
1451 a linefeed separated list of fingerprints.  The command will re-import
1452 the corresponding certificates; that is they are made permanent by
1453 removing their ephemeral flag.
1454
1455
1456 @node GPGSM DELETE
1457 @subsection Delete certificates
1458
1459 To delete a certificate the command
1460
1461 @example
1462   DELKEYS @var{pattern}
1463 @end example
1464
1465 is used.  To allow multiple patterns (which are ORed) quoting is
1466 required: Spaces are to be translated into "+" or into "%20"; in turn
1467 this requires that the usual escape quoting rules are done.
1468
1469 The certificates must be specified unambiguously otherwise an error is
1470 returned.
1471
1472 @node GPGSM GETAUDITLOG
1473 @subsection Retrieve an audit log
1474 @anchor{gpgsm-cmd getauditlog}
1475
1476 This command is used to retrieve an audit log.
1477
1478 @example
1479 GETAUDITLOG [--data] [--html]
1480 @end example
1481
1482 If @option{--data} is used, the audit log is send using D-lines
1483 instead of being sent to the file descriptor given by an @code{OUTPUT}
1484 command.  If @option{--html} is used, the output is formatted as an
1485 XHTML block. This is designed to be incorporated into a HTML
1486 document.
1487
1488
1489 @node GPGSM GETINFO
1490 @subsection  Return information about the process
1491
1492 This is a multipurpose function to return a variety of information.
1493
1494 @example
1495 GETINFO @var{what}
1496 @end example
1497
1498 The value of @var{what} specifies the kind of information returned:
1499 @table @code
1500 @item version
1501 Return the version of the program.
1502 @item pid
1503 Return the process id of the process.
1504 @item agent-check
1505 Return OK if the agent is running.
1506 @item cmd_has_option @var{cmd} @var{opt}
1507 Return OK if the command @var{cmd} implements the option @var{opt}.
1508 The leading two dashes usually used with @var{opt} shall not be given.
1509 @item offline
1510 Return OK if the connection is in offline mode.  This may be either
1511 due to a @code{OPTION offline=1} or due to @command{gpgsm} being
1512 started with option @option{--disable-dirmngr}.
1513 @end table
1514
1515 @node GPGSM OPTION
1516 @subsection  Session options
1517
1518 The standard Assuan option handler supports these options.
1519
1520 @example
1521 OPTION @var{name}[=@var{value}]
1522 @end example
1523
1524 These @var{name}s are recognized:
1525
1526 @table @code
1527
1528 @item putenv
1529 Change the session's environment to be passed via gpg-agent to
1530 Pinentry.  @var{value} is a string of the form
1531 @code{<KEY>[=[<STRING>]]}.  If only @code{<KEY>} is given the
1532 environment variable @code{<KEY>} is removed from the session
1533 environment, if @code{<KEY>=} is given that environment variable is
1534 set to the empty string, and if @code{<STRING>} is given it is set to
1535 that string.
1536
1537 @item display
1538 @efindex DISPLAY
1539 Set the session environment variable @code{DISPLAY} is set to @var{value}.
1540 @item ttyname
1541 @efindex GPG_TTY
1542 Set the session environment variable @code{GPG_TTY} is set to @var{value}.
1543 @item ttytype
1544 @efindex TERM
1545 Set the session environment variable @code{TERM} is set to @var{value}.
1546 @item lc-ctype
1547 @efindex LC_CTYPE
1548 Set the session environment variable @code{LC_CTYPE} is set to @var{value}.
1549 @item lc-messages
1550 @efindex LC_MESSAGES
1551 Set the session environment variable @code{LC_MESSAGES} is set to @var{value}.
1552 @item xauthority
1553 @efindex XAUTHORITY
1554 Set the session environment variable @code{XAUTHORITY} is set to @var{value}.
1555 @item pinentry-user-data
1556 @efindex PINENTRY_USER_DATA
1557 Set the session environment variable @code{PINENTRY_USER_DATA} is set
1558 to @var{value}.
1559
1560 @item include-certs
1561 This option overrides the command line option
1562 @option{--include-certs}.  A @var{value} of -2 includes all
1563 certificates except for the root certificate, -1 includes all
1564 certificates, 0 does not include any certificates, 1 includes only the
1565 signers certificate and all other positive values include up to
1566 @var{value} certificates starting with the signer cert.
1567
1568 @item list-mode
1569 @xref{gpgsm-cmd listkeys}.
1570
1571 @item list-to-output
1572 If @var{value} is true the output of the list commands
1573 (@pxref{gpgsm-cmd listkeys}) is written to the file descriptor set
1574 with the last @code{OUTPUT} command.  If @var{value} is false the output is
1575 written via data lines; this is the default.
1576
1577 @item with-validation
1578 If @var{value} is true for each listed certificate the validation
1579 status is printed.  This may result in the download of a CRL or the
1580 user being asked about the trustworthiness of a root certificate.  The
1581 default is given by a command line option (@pxref{gpgsm-option
1582 --with-validation}).
1583
1584
1585 @item with-secret
1586 If @var{value} is true certificates with a corresponding private key
1587 are marked by the list commands.
1588
1589 @item validation-model
1590 This option overrides the command line option
1591 @option{validation-model} for the session.
1592 (@xref{gpgsm-option --validation-model}.)
1593
1594 @item with-key-data
1595 This option globally enables the command line option
1596 @option{--with-key-data}.  (@xref{gpgsm-option --with-key-data}.)
1597
1598 @item enable-audit-log
1599 If @var{value} is true data to write an audit log is gathered.
1600 (@xref{gpgsm-cmd getauditlog}.)
1601
1602 @item allow-pinentry-notify
1603 If this option is used notifications about the launch of a Pinentry
1604 are passed back to the client.
1605
1606 @item with-ephemeral-keys
1607 If @var{value} is true ephemeral certificates are included in the
1608 output of the list commands.
1609
1610 @item no-encrypt-to
1611 If this option is used all keys set by the command line option
1612 @option{--encrypt-to} are ignored.
1613
1614 @item offline
1615 If @var{value} is true or @var{value} is not given all network access
1616 is disabled for this session.  This is the same as the command line
1617 option @option{--disable-dirmngr}.
1618
1619 @end table
1620
1621 @mansect see also
1622 @ifset isman
1623 @command{gpg2}(1),
1624 @command{gpg-agent}(1)
1625 @end ifset
1626 @include see-also-note.texi