Crypt_GPG
[ class tree: Crypt_GPG ] [ index: Crypt_GPG ] [ all elements ]

Class: Crypt_GPGAbstract

Source Location: /Crypt_GPG-1.6.4/Crypt/GPGAbstract.php

Class Overview


Base class for implementing a user of Crypt_GPG_Engine


Author(s):

Copyright:

  • 2005-2013 silverorange

Variables

Methods


Child classes:

Crypt_GPG
A class to use GPG from PHP
Crypt_GPG_KeyGenerator
GnuPG key generator

Inherited Variables

Inherited Methods


Class Details

[line 80]
Base class for implementing a user of Crypt_GPG_Engine


[ Top ]


Class Variables

$engine =  null

[line 179]

Engine used to control the GPG subprocess

Type:   Crypt_GPG_Engine


[ Top ]



Method Detail

__construct (Constructor)   [line 269]

Crypt_GPGAbstract __construct( [array $options = array()])

Creates a new GPG object

Available options are:

  • string homedir - the directory where the GPG keyring files are stored. If not specified, Crypt_GPG uses the default of ~/.gnupg.
  • string publicKeyring - the file path of the public keyring. Use this if the public keyring is not in the homedir, or if the keyring is in a directory not writable by the process invoking GPG (like Apache). Then you can specify the path to the keyring with this option (/foo/bar/pubring.gpg), and specify a writable directory (like /tmp) using the homedir option.
  • string privateKeyring - the file path of the private keyring. Use this if the private keyring is not in the homedir, or if the keyring is in a directory not writable by the process invoking GPG (like Apache). Then you can specify the path to the keyring with this option (/foo/bar/secring.gpg), and specify a writable directory (like /tmp) using the homedir option.
  • string trustDb - the file path of the web-of-trust database. Use this if the trust database is not in the homedir, or if the database is in a directory not writable by the process invoking GPG (like Apache). Then you can specify the path to the trust database with this option (/foo/bar/trustdb.gpg), and specify a writable directory (like /tmp) using the homedir option.
  • string binary - the location of the GPG binary. If not specified, the driver attempts to auto-detect the GPG binary location using a list of known default locations for the current operating system. The option gpgBinary is a deprecated alias.
  • string agent - the location of the GnuPG agent binary. The gpg-agent is only used for GnuPG 2.x. If not specified, the engine attempts to auto-detect the gpg-agent binary location using a list of know default locations for the current operating system.
  • string|false gpgconf - the location of the GnuPG conf binary. The gpgconf is only used for GnuPG >= 2.1. If not specified, the engine attempts to auto-detect the location using a list of know default locations. When set to FALSE `gpgconf --kill` will not be executed via destructor.
  • string digest-algo - Sets the message digest algorithm.
  • string cipher-algo - Sets the symmetric cipher.
  • string compress-algo - Sets the compression algorithm.
  • boolean strict - In strict mode clock problems on subkeys and signatures are not ignored (--ignore-time-conflict and --ignore-valid-from options).
  • mixed debug - whether or not to use debug mode. When debug mode is on, all communication to and from the GPG subprocess is logged. This can be useful to diagnose errors when using Crypt_GPG.
  • array options - additional per-command options to the GPG command. Key of the array is a command (e.g. gen-key, import, sign, encrypt, list-keys). Value is a string containing command line arguments to be added to the related command. For example: array('sign' => '--emit-version').

  • Throws: Crypt_GPG_FileException if the homedir does not exist and cannot be created. This can happen if homedir is not specified, Crypt_GPG is run as the web user, and the web user has no home directory. This exception is also thrown if any of the options publicKeyring, privateKeyring or trustDb options are specified but the files do not exist or are are not readable. This can happen if the user running the Crypt_GPG process (for example, the Apache user) does not have permission to read the files.
  • Throws: PEAR_Exception if the provided binary is invalid, or if no binary is provided and no suitable binary could be found.
  • Throws: PEAR_Exception if the provided agent is invalid, or if no agent is provided and no suitable gpg-agent could be found.
  • Access: public

Overridden in child classes as:

Crypt_GPG_KeyGenerator::__construct()
Creates a new GnuPG key generator

Parameters:

array   $options   —  optional. An array of options used to create the GPG object. All options are optional and are represented as key-value pairs.

[ Top ]

getVersion   [line 326]

string getVersion( )

Returns version of the engine (GnuPG) used for operation.
  • Return: GnuPG version.
  • Throws: Crypt_GPG_Exception if an unknown or unexpected error occurs. Use the debug option and file a bug report if these exceptions occur.
  • Access: public

[ Top ]

setEngine   [line 287]

Crypt_GPGAbstract setEngine( Crypt_GPG_Engine $engine)

Sets the I/O engine to use for GnuPG operations

Normally this method does not need to be used. It provides a means for dependency injection.

  • Return: the current object, for fluent interface.
  • Access: public

Parameters:

Crypt_GPG_Engine   $engine   —  the engine to use.

[ Top ]

setEngineOptions   [line 308]

void setEngineOptions( array $options)

Sets per-command additional arguments
  • Access: public

Parameters:

array   $options   —  Additional per-command options for GPG command. Note: This will unset options set previously. Key of the array is a command (e.g. gen-key, import, sign, encrypt, list-keys). Value is a string containing command line arguments to be added to the related command. For example: array('sign' => '--emit-version').

[ Top ]

_getKeys   [line 357]

array _getKeys( [string $keyId = ''])

Gets the available keys in the keyring

Calls GPG with the --list-keys command and grabs keys. See the first section of doc/DETAILS in the GPG package for a detailed description of how the GPG command output is parsed.

  • Return: an array of Crypt_GPG_Key objects. If no keys match the specified $keyId an empty array is returned.
  • See: Crypt_GPG_Key
  • Throws: Crypt_GPG_Exception if an unknown or unexpected error occurs. Use the debug option and file a bug report if these exceptions occur.
  • Access: protected

Parameters:

string   $keyId   —  optional. Only keys with that match the specified pattern are returned. The pattern may be part of a user id, a key id or a key fingerprint. If not specified, all keys are returned.

[ Top ]


Documentation generated on Sun, 22 Mar 2020 08:01:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.