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