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

Class: Crypt_GPG_Engine

Source Location: /Crypt_GPG-1.6.4/Crypt/GPG/Engine.php

Class Overview


Native PHP Crypt_GPG I/O engine


Author(s):

Copyright:

  • 2005-2013 silverorange

Methods


Inherited Variables

Inherited Methods


Class Details

[line 92]
Native PHP Crypt_GPG I/O engine

This class is used internally by Crypt_GPG and does not need be used directly. See the Crypt_GPG class for end-user API.

This engine uses PHP's native process control functions to directly control the GPG process. The GPG executable is required to be on the system.

All data is passed to the GPG subprocess using file descriptors. This is the most secure method of passing data to the GPG subprocess.



[ Top ]


Method Detail

__construct (Constructor)   [line 473]

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

Creates a new GPG engine
  • 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

Parameters:

array   $options   —  An array of options used to create the engine object. All options are optional and are represented as key-value pairs. See Crypt_GPGAbstract::__construct() for more info.

[ Top ]

__destruct (Destructor)   [line 668]

void __destruct( )

Closes open GPG subprocesses when this object is destroyed

Subprocesses should never be left open by this class unless there is an unknown error and unexpected script termination occurs.

  • Access: public

[ Top ]

addErrorHandler   [line 690]

void addErrorHandler( callback $callback, [array $args = array()])

Adds an error handler method

The method is run every time a new error line is received from the GPG subprocess. The handler method must accept the error line to be handled as its first parameter.

  • Access: public

Parameters:

callback   $callback   —  the callback method to use.
array   $args   —  optional. Additional arguments to pass as parameters to the callback method.

[ Top ]

addStatusHandler   [line 714]

void addStatusHandler( callback $callback, [array $args = array()])

Adds a status handler method

The method is run every time a new status line is received from the GPG subprocess. The handler method must accept the status line to be handled as its first parameter.

  • Access: public

Parameters:

callback   $callback   —  the callback method to use.
array   $args   —  optional. Additional arguments to pass as parameters to the callback method.

[ Top ]

getProcessData   [line 1023]

mixed getProcessData( string $name)

Get data from the last process execution.

Parameters:

string   $name   —  Data element name (e.g. 'SignatureInfo')

[ Top ]

getVersion   [line 965]

string getVersion( )

Gets the version of the GnuPG binary
  • Return: a version number string containing the version of GnuPG being used. This value is suitable to use with PHP's version_compare() function.
  • Throws: Crypt_GPG_UnsupportedException if the provided binary is not GnuPG or if the GnuPG version is less than 1.0.2.
  • 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 ]

reset   [line 753]

void reset( )

Resets the GPG engine, preparing it for a new operation

[ Top ]

run   [line 796]

void run( )

Runs the current GPG operation.

This creates and manages the GPG subprocess. This will close input/output file handles.

The operation must be set with Crypt_GPG_Engine::setOperation() before this method is called.


[ Top ]

sendCommand   [line 735]

void sendCommand( string $command)

Sends a command to the GPG subprocess over the command file-descriptor pipe
  • Access: public

Parameters:

string   $command   —  the command to send.

[ Top ]

setInput   [line 823]

void setInput( string|resource &$input)

Sets the input source for the current GPG operation
  • Access: public

Parameters:

string|resource   &$input   —  either a reference to the string containing the input data or an open stream resource containing the input data.

[ Top ]

setMessage   [line 843]

void setMessage( string|resource &$message)

Sets the message source for the current GPG operation

Detached signature data should be specified here.

  • Access: public

Parameters:

string|resource   &$message   —  either a reference to the string containing the message data or an open stream resource containing the message data.

[ Top ]

setOperation   [line 885]

void setOperation( string $operation, [array $arguments = array()])

Sets the operation to perform

Parameters:

string   $operation   —  the operation to perform. This should be one of GPG's operations. For example, --encrypt, --decrypt, --sign, etc.
array   $arguments   —  optional. Additional arguments for the GPG subprocess. See the GPG manual for specific values.

[ Top ]

setOptions   [line 943]

void setOptions( 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 ]

setOutput   [line 861]

void setOutput( string|resource &$output)

Sets the output destination for the current GPG operation
  • Access: public

Parameters:

string|resource   &$output   —  either a reference to the string in which to store GPG output or an open stream resource to which the output data should be written.

[ Top ]

setPins   [line 916]

void setPins( array $keys)

Sets the PINENTRY_USER_DATA environment variable with the currently added keys and passphrases

Keys and passphrases are stored as an indexed array of passphrases in JSON encoded to a flat string.

For GnuPG 2.x this is how passphrases are passed. For GnuPG 1.x the environment variable is set but not used.

  • Access: public

Parameters:

array   $keys   —  the internal key array to use.

[ Top ]

setProcessData   [line 1054]

void setProcessData( string $name, mixed $value)

Set some data for the process execution.
  • Access: public

Parameters:

string   $name   —  Data element name (e.g. 'Handle')
mixed   $value   —  Data value

[ Top ]


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