     [file defs.inc not included]

Invoking GPG-AGENT
******************

gpg-agent.1

synopsis

description
gpg-agent is a daemon to manage secret (private) keys independently from any protocol.  It is used as a backend for gpg and gpgsm as well as for a couple of other utilities.

The agent is automatically started on demand by gpg, gpgsm, gpgconf, or gpg-connect-agent. Thus there is no reason to start it manually.  In case you want to use the included Secure Shell Agent you may start the agent using:

     gpg-connect-agent /bye

You should always add the following lines to your .bashrc or whatever initialization file is used for all shell invocations:

     GPG_TTY=$(tty)
     export GPG_TTY

It is important that this environment variable always reflects the output of the tty command.  For W32 systems this option is not required.

Please make sure that a proper pinentry program has been installed under the default filename (which is system dependent) or use the option pinentry-program to specify the full name of that program. It is often useful to install a symbolic link from the actual used pinentry (e.g. BINDIR/pinentry-gtk) to the expected one (e.g. BINDIR/pinentry).

See Option Index,for an index to GPG-AGENT's commands and options.

commands

Commands
========

Commands are not distinguished from options except for the fact that only one command is allowed.

--version
     Print the program version and licensing information.  Note that you cannot abbreviate this command.

--help
-h
     Print a usage message summarizing the most useful command-line options. Note that you cannot abbreviate this command.

--dump-options
     Print a list of all available options and commands.  Note that you cannot abbreviate this command.

--server
     Run in server mode and wait for commands on the stdin.  The default mode is to create a socket and listen for commands there.

--daemon [COMMAND LINE]
     Start the gpg-agent as a daemon; that is, detach it from the console and run it in the background.

     As an alternative you may create a new process as a child of gpg-agent: gpg-agent --daemon /bin/sh.  This way you get a new shell with the environment setup properly; after you exit from this shell, gpg-agent terminates within a few seconds.

options

Option Summary
==============

--options FILE
     Reads configuration from FILE instead of from the default per-user configuration file.  The default configuration file is named gpg-agent.conf and expected in the .gnupg directory directly below the home directory of the user.

          [file opt-homedir.texi not included]

-v

--verbose
     Outputs additional information while running. You can increase the verbosity by giving several verbose commands to gpgsm, such as -vv.

-q

--quiet
     Try to be as quiet as possible.

--batch
     Don't invoke a pinentry or do any other thing requiring human interaction.

--faked-system-time EPOCH
     This option is only useful for testing; it sets the system time back or forth to EPOCH which is the number of seconds elapsed since the year 1970.

--debug-level LEVEL
     Select the debug level for investigating problems. LEVEL may be a numeric value or a keyword:

     none
          No debugging at all.  A value of less than 1 may be used instead of the keyword.

     basic
          Some basic debug messages.  A value between 1 and 2 may be used instead of the keyword.

     advanced
          More verbose debug messages.  A value between 3 and 5 may be used instead of the keyword.

     expert
          Even more detailed messages.  A value between 6 and 8 may be used instead of the keyword.

     guru
          All of the debug messages you can get. A value greater than 8 may be used instead of the keyword.  The creation of hash tracing files is only enabled if the keyword is used.

     How these messages are mapped to the actual debugging flags is not specified and may change with newer releases of this program. They are however carefully selected to best aid in debugging.

--debug FLAGS
     This option is only useful for debugging and the behaviour may change at any time without notice.  FLAGS are bit encoded and may be given in usual C-Syntax. The currently defined bits are:

     0  (1)
          X.509 or OpenPGP protocol related data

     1  (2)
          values of big number integers

     2  (4)
          low level crypto operations

     5  (32)
          memory allocation

     6  (64)
          caching

     7  (128)
          show memory statistics.

     9  (512)
          write hashed data to files named dbgmd-000*

     10 (1024)
          trace Assuan protocol

     12 (4096)
          bypass all certificate validation

--debug-all
     Same as --debug=0xffffffff

--debug-wait N
     When running in server mode, wait N seconds before entering the actual processing loop and print the pid.  This gives time to attach a debugger.

--debug-quick-random
     This option inhibits the use of the very secure random quality level (Libgcrypt’s GCRY_VERY_STRONG_RANDOM) and degrades all request down to standard random quality.  It is only used for testing and should not be used for any production quality keys.  This option is only effective when given on the command line.

     On GNU/Linux, another way to quickly generate insecure keys is to use rngd to fill the kernel's entropy pool with lower quality random data.  rngd is typically provided by the rng-tools package.  It can be run as follows: sudo rngd -f -r /dev/urandom.

--debug-pinentry
     This option enables extra debug information pertaining to the Pinentry.  As of now it is only useful when used along with --debug 1024.

--no-detach
     Don't detach the process from the console.  This is mainly useful for debugging.

-s
--sh
-c
--csh
     Format the info output in daemon mode for use with the standard Bourne shell or the C-shell respectively.  The default is to guess it based on the environment variable SHELL which is correct in almost all cases.

--no-grab
     Tell the pinentry not to grab the keyboard and mouse.  This option should in general not be used to avoid X-sniffing attacks.

--log-file FILE
     Append all logging output to FILE.  This is very helpful in seeing what the agent actually does.  If neither a log file nor a log file descriptor has been set on a Windows platform, the Registry entry HKCU\Software\GNU\GnuPG:DefaultLogFile, if set, is used to specify the logging output.

--no-allow-mark-trusted
     Do not allow clients to mark keys as trusted, i.e. put them into the trustlist.txt file.  This makes it harder for users to inadvertently accept Root-CA keys.

--allow-preset-passphrase
     This option allows the use of gpg-preset-passphrase to seed the internal cache of gpg-agent with passphrases.

--no-allow-loopback-pinentry

--allow-loopback-pinentry
     Disallow or allow clients to use the loopback pinentry features; see the option pinentry-mode for details.  Allow is the default.

     The --force option of the Assuan command DELETE_KEY is also controlled by this option: The option is ignored if a loopback pinentry is disallowed.

--no-allow-external-cache
     Tell Pinentry not to enable features which use an external cache for passphrases.

     Some desktop environments prefer to unlock all credentials with one master password and may have installed a Pinentry which employs an additional external cache to implement such a policy. By using this option the Pinentry is advised not to make use of such a cache and instead always ask the user for the requested passphrase.

--allow-emacs-pinentry
     Tell Pinentry to allow features to divert the passphrase entry to a running Emacs instance.  How this is exactly handled depends on the version of the used Pinentry.

--ignore-cache-for-signing
     This option will let gpg-agent bypass the passphrase cache for all signing operation.  Note that there is also a per-session option to control this behaviour but this command line option takes precedence.

--default-cache-ttl N
     Set the time a cache entry is valid to N seconds.  The default is 600 seconds.  Each time a cache entry is accessed, the entry's timer is reset.  To set an entry's maximum lifetime, use max-cache-ttl.

--default-cache-ttl-ssh N
     Set the time a cache entry used for SSH keys is valid to N seconds.  The default is 1800 seconds.  Each time a cache entry is accessed, the entry's timer is reset.  To set an entry's maximum lifetime, use max-cache-ttl-ssh.

--max-cache-ttl N
     Set the maximum time a cache entry is valid to N seconds.  After this time a cache entry will be expired even if it has been accessed recently or has been set using gpg-preset-passphrase.  The default is 2 hours (7200 seconds).

--max-cache-ttl-ssh N
     Set the maximum time a cache entry used for SSH keys is valid to N seconds.  After this time a cache entry will be expired even if it has been accessed recently or has been set using gpg-preset-passphrase.  The default is 2 hours (7200 seconds).

--enforce-passphrase-constraints
     Enforce the passphrase constraints by not allowing the user to bypass them using the ``Take it anyway'' button.

--min-passphrase-len N
     Set the minimal length of a passphrase.  When entering a new passphrase shorter than this value a warning will be displayed.  Defaults to 8.

--min-passphrase-nonalpha N
     Set the minimal number of digits or special characters required in a passphrase.  When entering a new passphrase with less than this number of digits or special characters a warning will be displayed.  Defaults to 1.

--check-passphrase-pattern FILE
     Check the passphrase against the pattern given in FILE.  When entering a new passphrase matching one of these pattern a warning will be displayed. FILE should be an absolute filename.  The default is not to use any pattern file.

     Security note: It is known that checking a passphrase against a list of pattern or even against a complete dictionary is not very effective to enforce good passphrases.  Users will soon figure up ways to bypass such a policy.  A better policy is to educate users on good security behavior and optionally to run a passphrase cracker regularly on all users passphrases to catch the very simple ones.

--max-passphrase-days N
     Ask the user to change the passphrase if N days have passed since the last change.  With --enforce-passphrase-constraints set the user may not bypass this check.

--enable-passphrase-history
     This option does nothing yet.

--pinentry-invisible-char CHAR
     This option asks the Pinentry to use CHAR for displaying hidden characters.  CHAR must be one character UTF-8 string.  A Pinentry may or may not honor this request.

--pinentry-timeout N
     This option asks the Pinentry to timeout after N seconds with no user input.  The default value of 0 does not ask the pinentry to timeout, however a Pinentry may use its own default timeout value in this case.  A Pinentry may or may not honor this request.

--pinentry-program FILENAME
     Use program FILENAME as the PIN entry.  The default is installation dependent.  With the default configuration the name of the default pinentry is pinentry; if that file does not exist but a pinentry-basic exist the latter is used.

     On a Windows platform the default is to use the first existing program from this list: bin\pinentry.exe, ..\Gpg4win\bin\pinentry.exe, ..\Gpg4win\pinentry.exe, ..\GNU\GnuPG\pinentry.exe, ..\GNU\bin\pinentry.exe, bin\pinentry-basic.exe where the file names are relative to the GnuPG installation directory.

--pinentry-touch-file FILENAME
     By default the filename of the socket gpg-agent is listening for requests is passed to Pinentry, so that it can touch that file before exiting (it does this only in curses mode).  This option changes the file passed to Pinentry to FILENAME.  The special name /dev/null may be used to completely disable this feature.  Note that Pinentry will not create that file, it will only change the modification and access time.

--scdaemon-program FILENAME
     Use program FILENAME as the Smartcard daemon.  The default is installation dependent and can be shown with the gpgconf command.

--disable-scdaemon
     Do not make use of the scdaemon tool.  This option has the effect of disabling the ability to do smartcard operations.  Note, that enabling this option at runtime does not kill an already forked scdaemon.

--disable-check-own-socket
     gpg-agent employs a periodic self-test to detect a stolen socket.  This usually means a second instance of gpg-agent has taken over the socket and gpg-agent will then terminate itself.  This option may be used to disable this self-test for debugging purposes.

--use-standard-socket
--no-use-standard-socket
--use-standard-socket-p
     Since GnuPG 2.1 the standard socket is always used.  These options have no more effect.  The command gpg-agent --use-standard-socket-p will thus always return success.

--display STRING
--ttyname STRING
--ttytype STRING
--lc-ctype STRING
--lc-messages STRING
--xauthority STRING
     These options are used with the server mode to pass localization information.

--keep-tty
--keep-display
     Ignore requests to change the current tty or X window system's DISPLAY variable respectively.  This is useful to lock the pinentry to pop up at the tty or display you started the agent.

--extra-socket NAME
     Also listen on native gpg-agent connections on the given socket.  The intended use for this extra socket is to setup a Unix domain socket forwarding from a remote machine to this socket on the local machine. A gpg running on the remote machine may then connect to the local gpg-agent and use its private keys.  This allows to decrypt or sign data on a remote machine without exposing the private keys to the remote machine.

--enable-ssh-support
--enable-putty-support

     Enable the OpenSSH Agent protocol.

     In this mode of operation, the agent does not only implement the gpg-agent protocol, but also the agent protocol used by OpenSSH (through a separate socket).  Consequently, it should be possible to use the gpg-agent as a drop-in replacement for the well known ssh-agent.

     SSH Keys, which are to be used through the agent, need to be added to the gpg-agent initially through the ssh-add utility.  When a key is added, ssh-add will ask for the password of the provided key file and send the unprotected key material to the agent; this causes the gpg-agent to ask for a passphrase, which is to be used for encrypting the newly received key and storing it in a gpg-agent specific directory.

     Once a key has been added to the gpg-agent this way, the gpg-agent will be ready to use the key.

     Note: in case the gpg-agent receives a signature request, the user might need to be prompted for a passphrase, which is necessary for decrypting the stored key.  Since the ssh-agent protocol does not contain a mechanism for telling the agent on which display/terminal it is running, gpg-agent's ssh-support will use the TTY or X display where gpg-agent has been started.  To switch this display to the current one, the following command may be used:

          gpg-connect-agent updatestartuptty /bye

     Although all GnuPG components try to start the gpg-agent as needed, this is not possible for the ssh support because ssh does not know about it. Thus if no GnuPG tool which accesses the agent has been run, there is no guarantee that ssh is able to use gpg-agent for authentication.  To fix this you may start gpg-agent if needed using this simple command:

          gpg-connect-agent /bye

     Adding the --verbose shows the progress of starting the agent.

     The --enable-putty-support is only available under Windows and allows the use of gpg-agent with the ssh implementation putty.  This is similar to the regular ssh-agent support but makes use of Windows message queue as required by putty.

All the long options may also be given in the configuration file after stripping off the two leading dashes.

files

Configuration
=============

There are a few configuration files needed for the operation of the agent. By default they may all be found in the current home directory (see option --homedir).

gpg-agent.conf
     This is the standard configuration file read by gpg-agent on startup.  It may contain any valid long option; the leading two dashes may not be entered and the option may not be abbreviated. This file is also read after a SIGHUP however only a few options will actually have an effect.  This default name may be changed on the command line (see option --options). You should backup this file.

trustlist.txt
     This is the list of trusted keys.  You should backup this file.

     Comment lines, indicated by a leading hash mark, as well as empty lines are ignored.  To mark a key as trusted you need to enter its fingerprint followed by a space and a capital letter S.  Colons may optionally be used to separate the bytes of a fingerprint; this allows to cut and paste the fingerprint from a key listing output.  If the line is prefixed with a ! the key is explicitly marked as not trusted.

     Here is an example where two keys are marked as ultimately trusted and one as not trusted:

            # CN=Wurzel ZS 3,O=Intevation GmbH,C=DE
            A6935DD34EF3087973C706FC311AA2CCF733765B S

            # CN=PCA-1-Verwaltung-02/O=PKI-1-Verwaltung/C=DE
            DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S

            # CN=Root-CA/O=Schlapphuete/L=Pullach/C=DE
            !14:56:98:D3:FE:9C:CA:5A:31:6E:BC:81:D3:11:4E:00:90:A3:44:C2 S

     Before entering a key into this file, you need to ensure its authenticity.  How to do this depends on your organisation; your administrator might have already entered those keys which are deemed trustworthy enough into this file.  Places where to look for the fingerprint of a root certificate are letters received from the CA or the website of the CA (after making 100% sure that this is indeed the website of that CA).  You may want to consider disallowing interactive updates of this file by using the see option --no-allow-mark-trusted. It might even be advisable to change the permissions to read-only so that this file can't be changed inadvertently.

     As a special feature a line include-default will include a global list of trusted certificates (e.g. SYSCONFDIR/trustlist.txt). This global list is also used if the local list is not available.

     It is possible to add further flags after the S for use by the caller:

     relax
          Relax checking of some root certificate requirements.  As of now this flag allows the use of root certificates with a missing basicConstraints attribute (despite that it is a MUST for CA certificates) and disables CRL checking for the root certificate.

     cm
          If validation of a certificate finally issued by a CA with this flag set fails, try again using the chain validation model.

sshcontrol
     This file is used when support for the secure shell agent protocol has been enabled (see option --enable-ssh-support). Only keys present in this file are used in the SSH protocol.  You should backup this file.

     The ssh-add tool may be used to add new entries to this file; you may also add them manually.  Comment lines, indicated by a leading hash mark, as well as empty lines are ignored.  An entry starts with optional whitespace, followed by the keygrip of the key given as 40 hex digits, optionally followed by the caching TTL in seconds and another optional field for arbitrary flags.  A non-zero TTL overrides the global default as set by --default-cache-ttl-ssh.

     The only flag support is confirm.  If this flag is found for a key, each use of the key will pop up a pinentry to confirm the use of that key.  The flag is automatically set if a new key was loaded into gpg-agent using the option -c of the ssh-add command.

     The keygrip may be prefixed with a ! to disable an entry entry.

     The following example lists exactly one key.  Note that keys available through a OpenPGP smartcard in the active smartcard reader are implicitly added to this list; i.e. there is no need to list them.

                 # Key added on: 2011-07-20 20:38:46
                 # Fingerprint:  5e:8d:c4:ad:e7:af:6e:27:8a:d6:13:e4:79:ad:0b:81
                 34B62F25E277CF13D3C6BCEBFD3F85D08F0A864B 0 confirm

private-keys-v1.d/

     This is the directory where gpg-agent stores the private keys.  Each key is stored in a file with the name made up of the keygrip and the suffix key.  You should backup all files in this directory and take great care to keep this backup closed away.

Note that on larger installations, it is useful to put predefined files into the directory SYSCONFSKELDIR so that newly created users start up with a working configuration.  For existing users the a small helper script is provided to create these files (see addgnupghome).

signals

Use of some signals.
====================

A running gpg-agent may be controlled by signals, i.e. using the kill command to send a signal to the process.

Here is a list of supported signals:

SIGHUP
     This signal flushes all cached passphrases and if the program has been started with a configuration file, the configuration file is read again.  Only certain options are honored: quiet, verbose, debug, debug-all, debug-level, debug-pinentry, no-grab, pinentry-program, pinentry-invisible-char, default-cache-ttl, max-cache-ttl, ignore-cache-for-signing, no-allow-external-cache, allow-emacs-pinentry, no-allow-mark-trusted, disable-scdaemon, and disable-check-own-socket.  scdaemon-program is also supported but due to the current implementation, which calls the scdaemon only once, it is not of much use unless you manually kill the scdaemon.

SIGTERM
     Shuts down the process but waits until all current requests are fulfilled.  If the process has received 3 of these signals and requests are still pending, a shutdown is forced.

SIGINT
     Shuts down the process immediately.

SIGUSR1
     Dump internal information to the log file.

SIGUSR2
     This signal is used for internal purposes.

examples

Examples
========

It is important to set the environment variable GPG_TTY in your login shell, for example in the ~/.bashrc init script:

       export GPG_TTY=$(tty)

If you enabled the Ssh Agent Support, you also need to tell ssh about it by adding this to your init script:

     unset SSH_AGENT_PID
     if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
       export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
     fi

Agent's Assuan Protocol
=======================

Note: this section does only document the protocol, which is used by GnuPG components; it does not deal with the ssh-agent protocol.  To see the full specification of each command, use

       gpg-connect-agent 'help COMMAND' /bye

or just 'help' to list all available commands.

The gpg-agent daemon is started on demand by the GnuPG components.

To identify a key we use a thing called keygrip which is the SHA-1 hash of an canonical encoded S-Expression of the public key as used in Libgcrypt.  For the purpose of this interface the keygrip is given as a hex string.  The advantage of using this and not the hash of a certificate is that it will be possible to use the same keypair for different protocols, thereby saving space on the token used to keep the secret keys.

The gpg-agent may send status messages during a command or when returning from a command to inform a client about the progress or result of an operation.  For example, the INQUIRE_MAXLEN status message may be sent during a server inquire to inform the client of the maximum usable length of the inquired data (which should not be exceeded).

Decrypting a session key
------------------------

The client asks the server to decrypt a session key.  The encrypted session key should have all information needed to select the appropriate secret key or to delegate it to a smartcard.

       SETKEY <keyGrip>

Tell the server about the key to be used for decryption.  If this is not used, gpg-agent may try to figure out the key by trying to decrypt the message with each key available.

       PKDECRYPT

The agent checks whether this command is allowed and then does an INQUIRY to get the ciphertext the client should then send the cipher text.

         S: INQUIRE CIPHERTEXT
         C: D (xxxxxx
         C: D xxxx)
         C: END

Please note that the server may send status info lines while reading the data lines from the client.  The data send is a SPKI like S-Exp with this structure:

          (enc-val
            (<algo>
              (<param_name1> <mpi>)
      	   ...
              (<param_namen> <mpi>)))

Where algo is a string with the name of the algorithm; see the libgcrypt documentation for a list of valid algorithms.  The number and names of the parameters depend on the algorithm.  The agent does return an error if there is an inconsistency.

If the decryption was successful the decrypted data is returned by means of "D" lines.

Here is an example session:

        C: PKDECRYPT
        S: INQUIRE CIPHERTEXT
        C: D (enc-val elg (a 349324324)
        C: D    (b 3F444677CA)))
        C: END
        S: # session key follows
        S: S PADDING 0
        S: D (value 1234567890ABCDEF0)
        S: OK descryption successful

The “PADDING” status line is only send if gpg-agent can tell what kind of padding is used.  As of now only the value 0 is used to indicate that the padding has been removed.

Signing a Hash
--------------

The client ask the agent to sign a given hash value.  A default key will be chosen if no key has been set.  To set a key a client first uses:

        SIGKEY <keyGrip>

This can be used multiple times to create multiple signature, the list of keys is reset with the next PKSIGN command or a RESET.  The server test whether the key is a valid key to sign something and responds with okay.

        SETHASH --hash=<name>|<algo> <hexstring>

The client can use this command to tell the server about the data <hexstring> (which usually is a hash) to be signed. <algo> is the decimal encoded hash algorithm number as used by Libgcrypt.  Either <algo> or --hash=<name> must be given.  Valid names for <name> are:

sha1
     The SHA-1 hash algorithm

sha256
     The SHA-256 hash algorithm

rmd160
     The RIPE-MD160 hash algorithm

md5
     The old and broken MD5 hash algorithm

tls-md5sha1
     A combined hash algorithm as used by the TLS protocol.

The actual signing is done using

        PKSIGN <options>

Options are not yet defined, but my later be used to choose among different algorithms.  The agent does then some checks, asks for the passphrase and as a result the server returns the signature as an SPKI like S-expression in "D" lines:

          (sig-val
            (<algo>
              (<param_name1> <mpi>)
      	   ...
              (<param_namen> <mpi>)))

The operation is affected by the option

        OPTION use-cache-for-signing=0|1

The default of 1 uses the cache.  Setting this option to 0 will lead gpg-agent to ignore the passphrase cache.  Note, that there is also a global command line option for gpg-agent to globally disable the caching.

Here is an example session:

        C: SIGKEY <keyGrip>
        S: OK key available
        C: SIGKEY <keyGrip>
        S: OK key available
        C: PKSIGN
        S: # I did ask the user whether he really wants to sign
        S: # I did ask the user for the passphrase
        S: INQUIRE HASHVAL
        C: D ABCDEF012345678901234
        C: END
        S: # signature follows
        S: D (sig-val rsa (s 45435453654612121212))
        S: OK

Generating a Key
----------------

This is used to create a new keypair and store the secret key inside the active PSE --- which is in most cases a Soft-PSE.  An not yet defined option allows to choose the storage location.  To get the secret key out of the PSE, a special export tool has to be used.

        GENKEY [--no-protection] [--preset] [<cache_nonce>]

Invokes the key generation process and the server will then inquire on the generation parameters, like:

        S: INQUIRE KEYPARM
        C: D (genkey (rsa (nbits  1024)))
        C: END

The format of the key parameters which depends on the algorithm is of the form:

         (genkey
           (algo
             (parameter_name_1 ....)
               ....
             (parameter_name_n ....)))

If everything succeeds, the server returns the *public key* in a SPKI like S-Expression like this:

          (public-key
            (rsa
      	 (n <mpi>)
      	 (e <mpi>)))

Here is an example session:

        C: GENKEY
        S: INQUIRE KEYPARM
        C: D (genkey (rsa (nbits  1024)))
        C: END
        S: D (public-key
        S: D   (rsa (n 326487324683264) (e 10001)))
        S  OK key created

The --no-protection option may be used to prevent prompting for a passphrase to protect the secret key while leaving the secret key unprotected. The --preset option may be used to add the passphrase to the cache using the default cache parameters.

The --inq-passwd option may be used to create the key with a supplied passphrase.  When used the agent does an inquiry with the keyword NEWPASSWD to retrieve that passphrase.  This option takes precedence over --no-protection; however if the client sends a empty (zero-length) passphrase, this is identical to --no-protection.

Importing a Secret Key
----------------------

This operation is not yet supported by GpgAgent.  Specialized tools are to be used for this.

There is no actual need because we can expect that secret keys created by a 3rd party are stored on a smartcard.  If we have generated the key ourself, we do not need to import it.

Export a Secret Key
-------------------

Not implemented.

Should be done by an extra tool.

Importing a Root Certificate
----------------------------

Actually we do not import a Root Cert but provide a way to validate any piece of data by storing its Hash along with a description and an identifier in the PSE.  Here is the interface description:

         ISTRUSTED <fingerprint>

Check whether the OpenPGP primary key or the X.509 certificate with the given fingerprint is an ultimately trusted key or a trusted Root CA certificate.  The fingerprint should be given as a hexstring (without any blanks or colons or whatever in between) and may be left padded with 00 in case of an MD5 fingerprint.  GPGAgent will answer with:

         OK

The key is in the table of trusted keys.

         ERR 304 (Not Trusted)

The key is not in this table.

Gpg needs the entire list of trusted keys to maintain the web of trust; the following command is therefore quite helpful:

         LISTTRUSTED

GpgAgent returns a list of trusted keys line by line:

         S: D 000000001234454556565656677878AF2F1ECCFF P
         S: D 340387563485634856435645634856438576457A P
         S: D FEDC6532453745367FD83474357495743757435D S
         S: OK

The first item on a line is the hexified fingerprint where MD5 fingerprints are 00 padded to the left and the second item is a flag to indicate the type of key (so that gpg is able to only take care of PGP keys).  P = OpenPGP, S = S/MIME.  A client should ignore the rest of the line, so that we can extend the format in the future.

Finally a client should be able to mark a key as trusted:

        MARKTRUSTED FINGERPRINT "P"|"S"

The server will then pop up a window to ask the user whether she really trusts this key. For this it will probably ask for a text to be displayed like this:

        S: INQUIRE TRUSTDESC
        C: D Do you trust the key with the fingerprint @FPR@
        C: D bla fasel blurb.
        C: END
        S: OK

Known sequences with the pattern @foo@ are replaced according to this table:

@FPR16@
     Format the fingerprint according to gpg rules for a v3 keys.

@FPR20@
     Format the fingerprint according to gpg rules for a v4 keys.

@FPR@
     Choose an appropriate format to format the fingerprint.

@@
     Replaced by a single @

Ask for a passphrase
--------------------

This function is usually used to ask for a passphrase to be used for symmetric encryption, but may also be used by programs which need special handling of passphrases.  This command uses a syntax which helps clients to use the agent with minimum effort.

       GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]] \
                      [--qualitybar] CACHE_ID                \
                      [ERROR_MESSAGE PROMPT DESCRIPTION]

CACHE_ID is expected to be a string used to identify a cached passphrase.  Use a X to bypass the cache.  With no other arguments the agent returns a cached passphrase or an error.  By convention either the hexified fingerprint of the key shall be used for CACHE_ID or an arbitrary string prefixed with the name of the calling application and a colon: Like gpg:somestring.

ERROR_MESSAGE is either a single X for no error message or a string to be shown as an error message like (e.g. "invalid passphrase").  Blanks must be percent escaped or replaced by +'.

PROMPT is either a single X for a default prompt or the text to be shown as the prompt.  Blanks must be percent escaped or replaced by +.

DESCRIPTION is a text shown above the entry field.  Blanks must be percent escaped or replaced by +.

The agent either returns with an error or with a OK followed by the hex encoded passphrase.  Note that the length of the strings is implicitly limited by the maximum length of a command.  If the option --data is used, the passphrase is not returned on the OK line but by regular data lines; this is the preferred method.

If the option --check is used, the standard passphrase constraints checks are applied.  A check is not done if the passphrase has been found in the cache.

If the option --no-ask is used and the passphrase is not in the cache the user will not be asked to enter a passphrase but the error code GPG_ERR_NO_DATA is returned.

If the option --qualitybar is used and a minimum passphrase length has been configured, a visual indication of the entered passphrase quality is shown.

       CLEAR_PASSPHRASE CACHE_ID

may be used to invalidate the cache entry for a passphrase.  The function returns with OK even when there is no cached passphrase.

Remove a cached passphrase
--------------------------

Use this command to remove a cached passphrase.

       CLEAR_PASSPHRASE [--mode=normal] <cache_id>

The --mode=normal option can be used to clear a CACHE_ID that was set by gpg-agent.

Set a passphrase for a keygrip
------------------------------

This command adds a passphrase to the cache for the specified KEYGRIP.

       PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]

The passphrase is a hexidecimal string when specified. When not specified, the passphrase will be retrieved from the pinentry module unless the --inquire option was specified in which case the passphrase will be retrieved from the client.

The TIMEOUT parameter keeps the passphrase cached for the specified number of seconds. A value of -1 means infinate while 0 means the default (currently only a timeout of -1 is allowed, which means to never expire it).

Ask for confirmation
--------------------

This command may be used to ask for a simple confirmation by presenting a text and 2 buttons: Okay and Cancel.

       GET_CONFIRMATION DESCRIPTION

DESCRIPTIONis displayed along with a Okay and Cancel button. Blanks must be percent escaped or replaced by +.  A X may be used to display confirmation dialog with a default text.

The agent either returns with an error or with a OK.  Note, that the length of DESCRIPTION is implicitly limited by the maximum length of a command.

Check whether a key is available
--------------------------------

This can be used to see whether a secret key is available.  It does not return any information on whether the key is somehow protected.

       HAVEKEY KEYGRIPS

The agent answers either with OK or No_Secret_Key (208).  The caller may want to check for other error codes as well.  More than one keygrip may be given.  In this case the command returns success if at least one of the keygrips corresponds to an available secret key.

Register a smartcard
--------------------

       LEARN [--send]

This command is used to register a smartcard.  With the --send option given the certificates are send back.

Change a Passphrase
-------------------

       PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset] KEYGRIP

This command is used to interactively change the passphrase of the key identified by the hex string KEYGRIP.  The --preset option may be used to add the new passphrase to the cache using the default cache parameters.

Change the standard display
---------------------------

       UPDATESTARTUPTTY

Set the startup TTY and X-DISPLAY variables to the values of this session.  This command is useful to direct future pinentry invocations to another screen.  It is only required because there is no way in the ssh-agent protocol to convey this information.

Get the Event Counters
----------------------

       GETEVENTCOUNTER

This function return one status line with the current values of the event counters.  The event counters are useful to avoid polling by delaying a poll until something has changed.  The values are decimal numbers in the range 0 to UINT_MAX and wrapping around to 0.  The actual values should not be relied upon; they shall only be used to detect a change.

The currently defined counters are are:

ANY
     Incremented with any change of any of the other counters.

KEY
     Incremented for added or removed private keys.

CARD
     Incremented for changes of the card readers stati.

Return information about the process
------------------------------------

This is a multipurpose function to return a variety of information.

     GETINFO WHAT

The value of WHAT specifies the kind of information returned:

version
     Return the version of the program.

pid
     Return the process id of the process.

socket_name
     Return the name of the socket used to connect the agent.

ssh_socket_name
     Return the name of the socket used for SSH connections.  If SSH support has not been enabled the error GPG_ERR_NO_DATA will be returned.

Set options for the session
---------------------------

Here is a list of session options which are not yet described with other commands.  The general syntax for an Assuan option is:

     OPTION  KEY=VALUE

Supported KEYs are:

agent-awareness
     This may be used to tell gpg-agent of which gpg-agent version the client is aware of.  gpg-agent uses this information to enable features which might break older clients.

putenv
     Change the session's environment to be used for the Pinentry.  Valid values are:

     NAME
          Delete envvar NAME

     NAME=
          Set envvar NAME to the empty string

     NAME=VALUE
          Set envvar NAME to the string VALUE.

use-cache-for-signing
     See Assuan command PKSIGN.

allow-pinentry-notify
     This does not need any value.  It is used to enable the PINENTRY_LAUNCHED inquiry.

pinentry-mode
     This option is used to change the operation mode of the pinentry.  The following values are defined:

     ask
          This is the default mode which pops up a pinentry as needed.

     cancel
          Instead of popping up a pinentry, return the error code GPG_ERR_CANCELED.

     error
          Instead of popping up a pinentry, return the error code GPG_ERR_NO_PIN_ENTRY.

     loopback
          Use a loopback pinentry.  This fakes a pinentry by using inquiries back to the caller to ask for a passphrase.  This option may only be set if the agent has been configured for that. To disable this feature use see option --no-allow-loopback-pinentry.

cache-ttl-opt-preset
     This option sets the cache TTL for new entries created by GENKEY and PASSWD commands when using the --preset option.  It it is not used a default value is used.

s2k-count
     Instead of using the standard S2K count (which is computed on the fly), the given S2K count is used for new keys or when changing the passphrase of a key.  Values below 65536 are considered to be 0.  This option is valid for the entire session or until reset to 0.  This option is useful if the key is later used on boxes which are either much slower or faster than the actual box.

see also
     [file see-also-note.texi not included]