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.
5 @node Invoking GPG-AGENT
6 @chapter Invoking GPG-AGENT
7 @cindex GPG-AGENT command options
8 @cindex command options
9 @cindex options, GPG-AGENT command
14 \- Secret key management for GnuPG
45 @command{gpg-agent} is a daemon to manage secret (private) keys
46 independently from any protocol. It is used as a backend for
47 @command{gpg} and @command{gpgsm} as well as for a couple of other
51 The usual way to run the agent is from the @code{~/.xsession} file:
54 eval $(gpg-agent --daemon)
58 If you don't use an X server, you can also put this into your regular
59 startup file @code{~/.profile} or @code{.bash_profile}. It is best not
60 to run multiple instance of the @command{gpg-agent}, so you should make
61 sure that only one is running: @command{gpg-agent} uses an environment
62 variable to inform clients about the communication parameters. You can
63 write the content of this environment variable to a file so that you can
64 test for a running agent. Here is an example using Bourne shell synax:
67 gpg-agent --daemon --enable-ssh-support \
68 --write-env-file "$@{HOME@}/.gpg-agent-info"
71 This code should only be run once per user session to initially fire up
72 the agent. In the example the optional support for the included Secure
73 Shell agent is enabled and the information about the agent is written to
74 a file in the HOME directory. Note that by running gpg-agent without
75 arguments you may test whether an agent is already running; however such
76 a test may lead to a race condition, thus it is not suggested.
79 The second script needs to be run for each interactive session:
82 if [ -f "$@{HOME@}/.gpg-agent-info" ]; then
83 . "$@{HOME@}/.gpg-agent-info"
91 It reads the data out of the file and exports the variables. If you
92 don't use Secure Shell, you don't need the last two export statements.
95 You should always add the following lines to your @code{.bashrc} or
96 whatever initialization file is used for all shell invocations:
104 It is important that this environment variable always reflects the
105 output of the @code{tty} command. For W32 systems this option is not
108 Please make sure that a proper pinentry program has been installed
109 under the default filename (which is system dependant) or use the
110 option @option{pinentry-program} to specify the full name of that program.
111 It is often useful to install a symbolic link from the actual used
112 pinentry (e.g. @file{/usr/bin/pinentry-gtk}) to the expected
113 one (e.g. @file{/usr/bin/pinentry}).
117 @xref{Option Index},for an index to @command{GPG-AGENT}'s commands and options.
121 * Agent Commands:: List of all commands.
122 * Agent Options:: List of all options.
123 * Agent Configuration:: Configuration files.
124 * Agent Signals:: Use of some signals.
125 * Agent Examples:: Some usage examples.
126 * Agent Protocol:: The protocol the agent uses.
133 Commands are not distinguished from options except for the fact that
134 only one command is allowed.
139 Print the program version and licensing information. Not that you can
140 abbreviate this command.
145 Print a usage message summarizing the most useful command-line options.
146 Not that you can abbreviate this command.
149 @opindex dump-options
150 Print a list of all available options and commands. Not that you can
151 abbreviate this command.
155 Run in server mode and wait for commands on the @code{stdin}. The
156 default mode is to create a socket and listen for commands there.
158 @item --daemon [@var{command line}]
160 Run the program in the background. This option is required to prevent
161 it from being accidently running in the background. A common way to do
165 $ eval $(gpg-agent --daemon)
171 @section Option Summary
175 @anchor{option --options}
176 @item --options @var{file}
178 Reads configuration from @var{file} instead of from the default
179 per-user configuration file. The default configuration file is named
180 @file{gpg-agent.conf} and expected in the @file{.gnupg} directory directly
181 below the home directory of the user.
183 @anchor{option --homedir}
184 @include opt-homedir.texi
191 Outputs additional information while running.
192 You can increase the verbosity by giving several
193 verbose commands to @command{gpgsm}, such as @samp{-vv}.
199 Try to be as quiet as possible.
203 Don't invoke a pinentry or do any other thing requiring human interaction.
205 @item --faked-system-time @var{epoch}
206 @opindex faked-system-time
207 This option is only useful for testing; it sets the system time back or
208 forth to @var{epoch} which is the number of seconds elapsed since the year
211 @item --debug-level @var{level}
213 Select the debug level for investigating problems. @var{level} may be
220 some basic debug messages
222 more verbose debug messages
224 even more detailed messages
226 all of the debug messages you can get
229 How these messages are mapped to the actual debugging flags is not
230 specified and may change with newer releases of this program. They are
231 however carefully selected to best aid in debugging.
233 @item --debug @var{flags}
235 This option is only useful for debugging and the behaviour may change at
236 any time without notice. FLAGS are bit encoded and may be given in
237 usual C-Syntax. The currently defined bits are:
241 X.509 or OpenPGP protocol related data
243 values of big number integers
245 low level crypto operations
251 show memory statistics.
253 write hashed data to files named @code{dbgmd-000*}
255 trace Assuan protocol
257 bypass all certificate validation
262 Same as @code{--debug=0xffffffff}
264 @item --debug-wait @var{n}
266 When running in server mode, wait @var{n} seconds before entering the
267 actual processing loop and print the pid. This gives time to attach a
272 Don't detach the process from the console. This is mainly useful for
283 Format the info output in daemon mode for use with the standard Bourne
284 shell or the C-shell respectively. The default is to guess it based on
285 the environment variable @code{SHELL} which is correct in almost all
288 @item --write-env-file @var{file}
289 @opindex write-env-file
290 Often it is required to connect to the agent from a process not being an
291 inferior of @command{gpg-agent} and thus the environment variable with
292 the socket name is not available. To help setting up those variables in
293 other sessions, this option may be used to write the information into
294 @var{file}. If @var{file} is not specified the default name
295 @file{$@{HOME@}/.gpg-agent-info} will be used. The format is suitable
296 to be evaluated by a Bourne shell like in this simple example:
299 eval $(cat @var{file})
300 eval $(cut -d= -f 1 < @var{file} | xargs echo export)
307 Tell the pinentry not to grab the keyboard and mouse. This option
308 should in general not be used to avoid X-sniffing attacks.
310 @item --log-file @var{file}
312 Append all logging output to @var{file}. This is very helpful in
313 seeing what the agent actually does.
315 @anchor{option --allow-mark-trusted}
316 @item --allow-mark-trusted
317 @opindex allow-mark-trusted
318 Allow clients to mark keys as trusted, i.e. put them into the
319 @file{trustlist.txt} file. This is by default not allowed to make it
320 harder for users to inadvertently accept Root-CA keys.
322 @item --ignore-cache-for-signing
323 @opindex ignore-cache-for-signing
324 This option will let @command{gpg-agent} bypass the passphrase cache for all
325 signing operation. Note that there is also a per-session option to
326 control this behaviour but this command line option takes precedence.
328 @item --default-cache-ttl @var{n}
329 @opindex default-cache-ttl
330 Set the time a cache entry is valid to @var{n} seconds. The default is
333 @item --default-cache-ttl-ssh @var{n}
334 @opindex default-cache-ttl
335 Set the time a cache entry used for SSH keys is valid to @var{n}
336 seconds. The default is 1800 seconds.
338 @item --max-cache-ttl @var{n}
339 @opindex max-cache-ttl
340 Set the maximum time a cache entry is valid to @var{n} seconds. After
341 this time a cache entry will be expired even if it has been accessed
342 recently. The default is 2 hours (7200 seconds).
344 @item --max-cache-ttl-ssh @var{n}
345 @opindex max-cache-ttl-ssh
346 Set the maximum time a cache entry used for SSH keys is valid to @var{n}
347 seconds. After this time a cache entry will be expired even if it has
348 been accessed recently. The default is 2 hours (7200 seconds).
350 @item --enforce-passphrase-constraints
351 @opindex enforce-passphrase-constraints
352 Enforce the passphrase constraints by not allowing the user to bypass
353 them using the ``Take it anyway'' button.
355 @item --min-passphrase-len @var{n}
356 @opindex min-passphrase-len
357 Set the minimal length of a passphrase. When entering a new passphrase
358 shorter than this value a warning will be displayed. Defaults to 8.
360 @item --min-passphrase-nonalpha @var{n}
361 @opindex min-passphrase-nonalpha
362 Set the minimal number of digits or special characters required in a
363 passphrase. When entering a new passphrase with less than this number
364 of digits or special characters a warning will be displayed. Defaults
367 @item --check-passphrase-pattern @var{file}
368 @opindex check-passphrase-pattern
369 Check the passphrase against the pattern given in @var{file}. When
370 entering a new passphrase matching one of these pattern a warning will
371 be displayed. @var{file} should be an absolute filename. The default is
372 not to use any pattern file.
374 Security note: It is known that checking a passphrase against a list of
375 pattern or even against a complete dictionary is not very effective to
376 enforce good passphrases. Users will soon figure up ways to bypass such
377 a policy. A better policy is to educate users on good security
378 behavior and optionally to run a passphrase cracker regularly on all
379 users passphrases to catch the very simple ones.
381 @item --max-passphrase-days @var{n}
382 @opindex max-passphrase-days
383 Ask the user to change the passphrase if @var{n} days have passed since
384 the last change. With @option{--enforce-passphrase-constraints} set the
385 user may not bypass this check.
387 @item --enable-passphrase-history
388 @opindex enable-passphrase-history
389 This option does nothing yet.
391 @item --pinentry-program @var{filename}
392 @opindex pinentry-program
393 Use program @var{filename} as the PIN entry. The default is installation
394 dependent and can be shown with the @code{--version} command.
396 @item --pinentry-touch-file @var{filename}
397 @opindex pinentry-touch-file
398 By default the filename of the socket gpg-agent is listening for
399 requests is passed to Pinentry, so that it can touch that file before
400 exiting (it does this only in curses mode). This option changes the
401 file passed to Pinentry to @var{filename}. The special name
402 @code{/dev/null} may be used to completely disable this feature. Note
403 that Pinentry will not create that file, it will only change the
404 modification and access time.
407 @item --scdaemon-program @var{filename}
408 @opindex scdaemon-program
409 Use program @var{filename} as the Smartcard daemon. The default is
410 installation dependent and can be shown with the @code{--version}
413 @item --disable-scdaemon
414 @opindex disable-scdaemon
415 Do not make use of the scdaemon tool. This option has the effect of
416 disabling the ability to do smartcard operations. Note, that enabling
417 this option at runtime does not kill an already forked scdaemon.
419 @item --use-standard-socket
420 @itemx --no-use-standard-socket
421 @opindex use-standard-socket
422 @opindex no-use-standard-socket
423 By enabling this option @command{gpg-agent} will listen on the socket
424 named @file{S.gpg-agent}, located in the home directory, and not create
425 a random socket below a temporary directory. Tools connecting to
426 @command{gpg-agent} should first try to connect to the socket given in
427 environment variable @var{GPG_AGENT_INFO} and then fall back to this
428 socket. This option may not be used if the home directory is mounted as
429 a remote file system. Note, that @option{--use-standard-socket} is the
430 default on Windows systems.
433 @item --display @var{string}
434 @itemx --ttyname @var{string}
435 @itemx --ttytype @var{string}
436 @itemx --lc-ctype @var{string}
437 @itemx --lc-messages @var{string}
438 @itemx --xauthority @var{string}
445 These options are used with the server mode to pass localization
449 @itemx --keep-display
451 @opindex keep-display
452 Ignore requests to change the current @code{tty} or X window system's
453 @code{DISPLAY} variable respectively. This is useful to lock the
454 pinentry to pop up at the @code{tty} or display you started the agent.
456 @anchor{option --enable-ssh-support}
457 @item --enable-ssh-support
458 @opindex enable-ssh-support
460 Enable emulation of the OpenSSH Agent protocol.
462 In this mode of operation, the agent does not only implement the
463 gpg-agent protocol, but also the agent protocol used by OpenSSH
464 (through a separate socket). Consequently, it should be possible to use
465 the gpg-agent as a drop-in replacement for the well known ssh-agent.
467 SSH Keys, which are to be used through the agent, need to be added to
468 the gpg-agent initially through the ssh-add utility. When a key is
469 added, ssh-add will ask for the password of the provided key file and
470 send the unprotected key material to the agent; this causes the
471 gpg-agent to ask for a passphrase, which is to be used for encrypting
472 the newly received key and storing it in a gpg-agent specific
475 Once a key has been added to the gpg-agent this way, the gpg-agent
476 will be ready to use the key.
478 Note: in case the gpg-agent receives a signature request, the user might
479 need to be prompted for a passphrase, which is necessary for decrypting
480 the stored key. Since the ssh-agent protocol does not contain a
481 mechanism for telling the agent on which display/terminal it is running,
482 gpg-agent's ssh-support will use the TTY or X display where gpg-agent
483 has been started. To switch this display to the current one, the
484 following command may be used:
487 echo UPDATESTARTUPTTY | gpg-connect-agent
494 All the long options may also be given in the configuration file after
495 stripping off the two leading dashes.
499 @node Agent Configuration
500 @section Configuration
502 There are a few configuration files needed for the operation of the
503 agent. By default they may all be found in the current home directory
504 (@pxref{option --homedir}).
509 @cindex gpg-agent.conf
510 This is the standard configuration file read by @command{gpg-agent} on
511 startup. It may contain any valid long option; the leading
512 two dashes may not be entered and the option may not be abbreviated.
513 This file is also read after a @code{SIGHUP} however only a few
514 options will actually have an effect. This default name may be
515 changed on the command line (@pxref{option --options}).
518 This is the list of trusted keys. Comment lines, indicated by a leading
519 hash mark, as well as empty lines are ignored. To mark a key as trusted
520 you need to enter its fingerprint followed by a space and a capital
521 letter @code{S}. Colons may optionally be used to separate the bytes of
522 a fingerprint; this allows to cut and paste the fingerprint from a key
523 listing output. If the line is prefixed with a @code{!} the key is
524 explicitly marked as not trusted.
526 Here is an example where two keys are marked as ultimately trusted
527 and one as not trusted:
530 # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
531 A6935DD34EF3087973C706FC311AA2CCF733765B S
533 # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
534 DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S
536 # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
537 !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S
540 Before entering a key into this file, you need to ensure its
541 authenticity. How to do this depends on your organisation; your
542 administrator might have already entered those keys which are deemed
543 trustworthy enough into this file. Places where to look for the
544 fingerprint of a root certificate are letters received from the CA or
545 the website of the CA (after making 100% sure that this is indeed the
546 website of that CA). You may want to consider allowing interactive
547 updates of this file by using the @xref{option --allow-mark-trusted}.
548 This is however not as secure as maintaining this file manually. It is
549 even advisable to change the permissions to read-only so that this file
550 can't be changed inadvertently.
552 As a special feature a line @code{include-default} will include a global
553 list of trusted certificates (e.g. @file{/etc/gnupg/trustlist.txt}).
554 This global list is also used if the local list is not available.
556 It is possible to add further flags after the @code{S} for use by the
561 Relax checking of some root certificate requirements. This is for
562 example required if the certificate is missing the basicConstraints
563 attribute (despite that it is a MUST for CA certificates).
566 If validation of a certificate finally issued by a CA with this flag set
567 fails, try again using the chain validation model.
574 This file is used when support for the secure shell agent protocol has
575 been enabled (@pxref{option --enable-ssh-support}). Only keys present
576 in this file are used in the SSH protocol. The @command{ssh-add} tool
577 may be used to add new entries to this file; you may also add them
578 manually. Comment lines, indicated by a leading hash mark, as well as
579 empty lines are ignored. An entry starts with optional whitespace,
580 followed by the keygrip of the key given as 40 hex digits, optionally
581 followed by the caching TTL in seconds and another optional field for
582 arbitrary flags. The keygrip may be prefixed with a @code{!} to
585 The following example lists exactly one key. Note that keys available
586 through a OpenPGP smartcard in the active smartcard reader are
587 implicitly added to this list; i.e. there is no need to list them.
590 # Key added on 2005-02-25 15:08:29
591 5A6592BF45DC73BD876874A28FD4639282E29B52 0
594 @item private-keys-v1.d/
596 This is the directory where gpg-agent stores the private keys. Each
597 key is stored in a file with the name made up of the keygrip and the
603 Note that on larger installations, it is useful to put predefined
604 files into the directory @file{/etc/skel/.gnupg/} so that newly created
605 users start up with a working configuration. For existing users the
606 a small helper script is provided to create these files (@pxref{addgnupghome}).
615 @section Use of some signals.
616 A running @command{gpg-agent} may be controlled by signals, i.e. using
617 the @command{kill} command to send a signal to the process.
619 Here is a list of supported signals:
625 This signal flushes all cached passphrases and if the program has been
626 started with a configuration file, the configuration file is read again.
627 Only certain options are honored: @code{quiet}, @code{verbose},
628 @code{debug}, @code{debug-all}, @code{debug-level}, @code{no-grab},
629 @code{pinentry-program}, @code{default-cache-ttl}, @code{max-cache-ttl},
630 @code{ignore-cache-for-signing}, @code{allow-mark-trusted} and
631 @code{disable-scdaemon}. @code{scdaemon-program} is also supported but
632 due to the current implementation, which calls the scdaemon only once,
633 it is not of much use unless you manually kill the scdaemon.
638 Shuts down the process but waits until all current requests are
639 fulfilled. If the process has received 3 of these signals and requests
640 are still pending, a shutdown is forced.
644 Shuts down the process immediately.
648 Dump internal information to the log file.
652 This signal is used for internal purposes.
663 The usual way to invoke @command{gpg-agent} is
666 $ eval $(gpg-agent --daemon)
669 An alternative way is by replacing @command{ssh-agent} with
670 @command{gpg-agent}. If for example @command{ssh-agent} is started as
671 part of the Xsession initialization, you may simply replace
672 @command{ssh-agent} by a script like:
678 exec /usr/local/bin/gpg-agent --enable-ssh-support --daemon \
679 --write-env-file $@{HOME@}/.gpg-agent-info "$@@"
684 and add something like (for Bourne shells)
688 if [ -f "$@{HOME@}/.gpg-agent-info" ]; then
689 . "$@{HOME@}/.gpg-agent-info"
690 export GPG_AGENT_INFO
698 to your shell initialization file (e.g. @file{~/.bashrc}).
705 @section Agent's Assuan Protocol
707 Note: this section does only document the protocol, which is used by
708 GnuPG components; it does not deal with the ssh-agent protocol.
710 The @command{gpg-agent} should be started by the login shell and set an
711 environment variable to tell clients about the socket to be used.
712 Clients should deny to access an agent with a socket name which does
713 not match its own configuration. An application may choose to start
714 an instance of the gpgagent if it does not figure that any has been
715 started; it should not do this if a gpgagent is running but not
716 usable. Because @command{gpg-agent} can only be used in background mode, no
717 special command line option is required to activate the use of the
720 To identify a key we use a thing called keygrip which is the SHA-1 hash
721 of an canoncical encoded S-Expression of the the public key as used in
722 Libgcrypt. For the purpose of this interface the keygrip is given as a
723 hex string. The advantage of using this and not the hash of a
724 certificate is that it will be possible to use the same keypair for
725 different protocols, thereby saving space on the token used to keep the
729 * Agent PKDECRYPT:: Decrypting a session key
730 * Agent PKSIGN:: Signing a Hash
731 * Agent GENKEY:: Generating a Key
732 * Agent IMPORT:: Importing a Secret Key
733 * Agent EXPORT:: Exporting a Secret Key
734 * Agent ISTRUSTED:: Importing a Root Certificate
735 * Agent GET_PASSPHRASE:: Ask for a passphrase
736 * Agent GET_CONFIRMATION:: Ask for confirmation
737 * Agent HAVEKEY:: Check whether a key is available
738 * Agent LEARN:: Register a smartcard
739 * Agent PASSWD:: Change a Passphrase
740 * Agent UPDATESTARTUPTTY:: Change the Standard Display
741 * Agent GETEVENTCOUNTER:: Get the Event Counters
742 * Agent GETINFO:: Return information about the process
745 @node Agent PKDECRYPT
746 @subsection Decrypting a session key
748 The client asks the server to decrypt a session key. The encrypted
749 session key should have all information needed to select the
750 appropriate secret key or to delegate it to a smartcard.
756 Tell the server about the key to be used for decryption. If this is
757 not used, @command{gpg-agent} may try to figure out the key by trying to
758 decrypt the message with each key available.
764 The agent checks whether this command is allowed and then does an
765 INQUIRY to get the ciphertext the client should then send the cipher
769 S: INQUIRE CIPHERTEXT
775 Please note that the server may send status info lines while reading the
776 data lines from the client. The data send is a SPKI like S-Exp with
782 (<param_name1> <mpi>)
784 (<param_namen> <mpi>)))
787 Where algo is a string with the name of the algorithm; see the libgcrypt
788 documentation for a list of valid algorithms. The number and names of
789 the parameters depend on the algorithm. The agent does return an error
790 if there is an inconsistency.
792 If the decryption was successful the decrypted data is returned by
795 Here is an example session:
799 S: INQUIRE CIPHERTEXT
800 C: D (enc-val elg (a 349324324)
801 C: D (b 3F444677CA)))
803 S: # session key follows
804 S: D (value 1234567890ABCDEF0)
805 S: OK descryption successful
810 @subsection Signing a Hash
812 The client ask the agent to sign a given hash value. A default key
813 will be chosen if no key has been set. To set a key a client first
820 This can be used multiple times to create multiple signature, the list
821 of keys is reset with the next PKSIGN command or a RESET. The server
822 test whether the key is a valid key to sign something and responds with
826 SETHASH --hash=<name>|<algo> <hexstring>
829 The client can use this command to tell the server about the data <hexstring>
830 (which usually is a hash) to be signed. <algo> is the decimal encoded hash
831 algorithm number as used by Libgcrypt. Either <algo> or --hash=<name>
832 must be given. Valid names for <name> are:
843 The actual signing is done using
849 Options are not yet defined, but my later be used to choosen among
850 different algorithms. The agent does then some checks, asks for the
851 passphrase and as a result the server returns the signature as an SPKI
852 like S-expression in "D" lines:
857 (<param_name1> <mpi>)
859 (<param_namen> <mpi>)))
863 The operation is affected by the option
866 OPTION use-cache-for-signing=0|1
869 The default of @code{1} uses the cache. Setting this option to @code{0}
870 will lead @command{gpg-agent} to ignore the passphrase cache. Note, that there is
871 also a global command line option for @command{gpg-agent} to globally disable the
875 Here is an example session:
883 S: # I did ask the user whether he really wants to sign
884 S: # I did ask the user for the passphrase
886 C: D ABCDEF012345678901234
888 S: # signature follows
889 S: D (sig-val rsa (s 45435453654612121212))
895 @subsection Generating a Key
897 This is used to create a new keypair and store the secret key inside the
898 active PSE --- which is in most cases a Soft-PSE. An not yet defined
899 option allows to choose the storage location. To get the secret key out
900 of the PSE, a special export tool has to be used.
906 Invokes the key generation process and the server will then inquire
907 on the generation parameters, like:
911 C: D (genkey (rsa (nbits 1024)))
915 The format of the key parameters which depends on the algorithm is of
921 (parameter_name_1 ....)
923 (parameter_name_n ....)))
926 If everything succeeds, the server returns the *public key* in a SPKI
927 like S-Expression like this:
936 Here is an example session:
941 C: D (genkey (rsa (nbits 1024)))
944 S: D (rsa (n 326487324683264) (e 10001)))
949 @subsection Importing a Secret Key
951 This operation is not yet supportted by GpgAgent. Specialized tools
952 are to be used for this.
954 There is no actual need because we can expect that secret keys
955 created by a 3rd party are stored on a smartcard. If we have
956 generated the key ourself, we do not need to import it.
959 @subsection Export a Secret Key
963 Should be done by an extra tool.
965 @node Agent ISTRUSTED
966 @subsection Importing a Root Certificate
968 Actually we do not import a Root Cert but provide a way to validate
969 any piece of data by storing its Hash along with a description and
970 an identifier in the PSE. Here is the interface desription:
973 ISTRUSTED <fingerprint>
976 Check whether the OpenPGP primary key or the X.509 certificate with the
977 given fingerprint is an ultimately trusted key or a trusted Root CA
978 certificate. The fingerprint should be given as a hexstring (without
979 any blanks or colons or whatever in between) and may be left padded with
980 00 in case of an MD5 fingerprint. GPGAgent will answer with:
986 The key is in the table of trusted keys.
989 ERR 304 (Not Trusted)
992 The key is not in this table.
994 Gpg needs the entire list of trusted keys to maintain the web of
995 trust; the following command is therefore quite helpful:
1001 GpgAgent returns a list of trusted keys line by line:
1004 S: D 000000001234454556565656677878AF2F1ECCFF P
1005 S: D 340387563485634856435645634856438576457A P
1006 S: D FEDC6532453745367FD83474357495743757435D S
1010 The first item on a line is the hexified fingerprint where MD5
1011 ingerprints are @code{00} padded to the left and the second item is a
1012 flag to indicate the type of key (so that gpg is able to only take care
1013 of PGP keys). P = OpenPGP, S = S/MIME. A client should ignore the rest
1014 of the line, so that we can extend the format in the future.
1016 Finally a client should be able to mark a key as trusted:
1019 MARKTRUSTED @var{fingerprint} "P"|"S"
1022 The server will then pop up a window to ask the user whether she
1023 really trusts this key. For this it will probably ask for a text to
1024 be displayed like this:
1027 S: INQUIRE TRUSTDESC
1028 C: D Do you trust the key with the fingerprint @@FPR@@
1029 C: D bla fasel blurb.
1034 Known sequences with the pattern @@foo@@ are replaced according to this
1039 Format the fingerprint according to gpg rules for a v3 keys.
1041 Format the fingerprint according to gpg rules for a v4 keys.
1043 Choose an appropriate format to format the fingerprint.
1045 Replaced by a single @code{@@}
1048 @node Agent GET_PASSPHRASE
1049 @subsection Ask for a passphrase
1051 This function is usually used to ask for a passphrase to be used for
1052 conventional encryption, but may also be used by programs which need
1053 special handling of passphrases. This command uses a syntax which helps
1054 clients to use the agent with minimum effort.
1057 GET_PASSPHRASE [--data] [--check] [--no-ask] @var{cache_id} [@var{error_message} @var{prompt} @var{description}]
1060 @var{cache_id} is expected to be a string used to identify a cached
1061 passphrase. Use a @code{X} to bypass the cache. With no other
1062 arguments the agent returns a cached passphrase or an error. By
1063 convention either the hexified fingerprint of the key shall be used for
1064 @var{cache_id} or an arbitrary string prefixed with the name of the
1065 calling application and a colon: Like @code{gpg:somestring}.
1067 @var{error_message} is either a single @code{X} for no error message or
1068 a string to be shown as an error message like (e.g. "invalid
1069 passphrase"). Blanks must be percent escaped or replaced by @code{+}'.
1071 @var{prompt} is either a single @code{X} for a default prompt or the
1072 text to be shown as the prompt. Blanks must be percent escaped or
1073 replaced by @code{+}.
1075 @var{description} is a text shown above the entry field. Blanks must be
1076 percent escaped or replaced by @code{+}.
1078 The agent either returns with an error or with a OK followed by the hex
1079 encoded passphrase. Note that the length of the strings is implicitly
1080 limited by the maximum length of a command. If the option
1081 @option{--data} is used, the passphrase is not returned on the OK line
1082 but by regular data lines; this is the preferred method.
1084 If the option @option{--check} is used, the standard passphrase
1085 constraints checks are applied. A check is not done if the passphrase
1086 has been found in the cache.
1088 If the option @option{--no-ask} is used and the passphrase is not in the
1089 cache the user will not be asked to enter a passphrase but the error
1090 code @code{GPG_ERR_NO_DATA} is returned.
1094 CLEAR_PASSPHRASE @var{cache_id}
1097 may be used to invalidate the cache entry for a passphrase. The
1098 function returns with OK even when there is no cached passphrase.
1101 @node Agent GET_CONFIRMATION
1102 @subsection Ask for confirmation
1104 This command may be used to ask for a simple confirmation by
1105 presenting a text and 2 bottonts: Okay and Cancel.
1108 GET_CONFIRMATION @var{description}
1111 @var{description}is displayed along with a Okay and Cancel
1112 button. Blanks must be percent escaped or replaced by @code{+}. A
1113 @code{X} may be used to display confirmation dialog with a default
1116 The agent either returns with an error or with a OK. Note, that the
1117 length of @var{description} is implicitly limited by the maximum
1118 length of a command.
1123 @subsection Check whether a key is available
1125 This can be used to see whether a secret key is available. It does
1126 not return any information on whether the key is somehow protected.
1129 HAVEKEY @var{keygrip}
1132 The Agent answers either with OK or @code{No_Secret_Key} (208). The
1133 caller may want to check for other error codes as well.
1137 @subsection Register a smartcard
1143 This command is used to register a smartcard. With the --send
1144 option given the certificates are send back.
1148 @subsection Change a Passphrase
1151 PASSWD @var{keygrip}
1154 This command is used to interactively change the passphrase of the key
1155 indentified by the hex string @var{keygrip}.
1158 @node Agent UPDATESTARTUPTTY
1159 @subsection Change the standard display
1165 Set the startup TTY and X-DISPLAY variables to the values of this
1166 session. This command is useful to direct future pinentry invocations
1167 to another screen. It is only required because there is no way in the
1168 ssh-agent protocol to convey this information.
1171 @node Agent GETEVENTCOUNTER
1172 @subsection Get the Event Counters
1178 This function return one status line with the current values of the
1179 event counters. The event counters are useful to avoid polling by
1180 delaying a poll until something has changed. The values are decimal
1181 numbers in the range @code{0} to @code{UINT_MAX} and wrapping around to
1182 0. The actual values should not be relied upon; they shall only be used
1185 The currently defined counters are are:
1188 Incremented with any change of any of the other counters.
1190 Incremented for added or removed private keys.
1192 Incremented for changes of the card readers stati.
1196 @subsection Return information about the process
1198 This is a multipurpose function to return a variety of information.
1204 The value of @var{what} specifies the kind of information returned:
1207 Return the version of the program.
1209 Return the process id of the process.
1211 Return the name of the socket used to connect the agent.
1212 @item ssh_socket_name
1213 Return the name of the socket used for SSH connections. If SSH support
1214 has not been enabled the error @code{GPG_ERR_NO_DATA} will be returned.
1222 @command{gpg-connect-agent}(1),
1223 @command{scdaemon}(1)
1225 @include see-also-note.texi