\Horde_Pgp

A framework to interact with the OpenPGP standard (RFC 4880).

Summary

Methods
Properties
Constants
__construct()
generateKey()
encrypt()
encryptSymmetric()
sign()
signCleartext()
signDetached()
decrypt()
decryptSymmetric()
verify()
verifyDetached()
No public properties found
No constants found
_initDrivers()
_runInBackend()
_getPrivateKey()
_getCipher()
_getCompression()
_getOption()
$_backends
$_params
N/A
No private methods found
No private properties found
N/A

Properties

$_backends

$_backends : array

List of initialized backends.

Type

array

$_params

$_params : array

Configuration parameters.

Type

array

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Configuration parameters:

  • backends: (array) The explicit list of backend drivers (Horde_Pgp_Backend objects) to use.

generateKey()

generateKey(string  $name, string  $email, array  $opts = array()) : \Horde_Pgp_Key_Private

Generates a private key.

Parameters

string $name

Full name.

string $email

E-mail.

array $opts

Additional options:

  • comment: (string) Comment.
  • hash: (string) Hash function.
  • expire: (integer) Expiration date (UNIX timestamp).
  • keylength: (integer) Key length.
  • passphrase: (string) Passphrase.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Key_Private —

The generated private key.

encrypt()

encrypt(string  $text, mixed  $keys, array  $opts = array()) : \Horde_Pgp_Element_Message

Encrypts text using PGP public keys.

Parameters

string $text

The text to be encrypted.

mixed $keys

The list of public keys to encrypt.

array $opts

Additional options:

  • cipher: (string) Default symmetric cipher algorithm to use. One of: 3DES, CAST5, AES128, AES192, AES256, Twofish.
  • compress: (string) Default compression to use. One of: NONE, ZIP, ZLIB

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Element_Message

The encrypted data.

encryptSymmetric()

encryptSymmetric(string  $text, mixed  $passphrase, array  $opts = array()) : \Horde_Pgp_Element_Message

Encrypts text using a PGP symmetric passphrase.

Parameters

string $text

The text to be encrypted.

mixed $passphrase

The symmetric passphrase(s).

array $opts

Additional options:

  • cipher: (string) Default symmetric cipher algorithm to use. One of: 3DES, CAST5, AES128, AES192, AES256, Twofish.
  • compress: (string) Default compression to use. One of: NONE, ZIP, ZLIB

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Element_Message

The encrypted data.

sign()

sign(string  $text, mixed  $key, array  $opts = array()) : \Horde_Pgp_Element_Message

Sign data using a PGP private key.

Returns message object that contains both the signed data and the signature packet.

Parameters

string $text

The text to be signed.

mixed $key

The private key to use for signing (must be decrypted).

array $opts

Additional options:

  • compress: (string) Default compression to use. One of: NONE, ZIP, ZLIB
  • sign_hash: (string) The hash method to use.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Element_Message

The signed data.

signCleartext()

signCleartext(string  $text, mixed  $key, array  $opts = array()) : \Horde_Pgp_Element_SignedMessage

Sign data using a PGP private key, creating cleartext output.

Parameters

string $text

The text to be signed.

mixed $key

The private key to use for signing (must be decrypted).

array $opts

Additional options:

  • sign_hash: (string) The hash method to use.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Element_SignedMessage

The signed data.

signDetached()

signDetached(string  $text, mixed  $key, array  $opts = array()) : \Horde_Pgp_Element_Signature

Sign data using a PGP private key, returning a detached signature.

Parameters

string $text

The text to be signed.

mixed $key

The private key to use for signing (must be decrypted).

array $opts

Additional options:

  • sign_hash: (string) The hash method to use.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Element_Signature

The detached signature.

decrypt()

decrypt(mixed  $text, mixed  $key) : \Horde_Pgp_Element_Message

Decrypts text using a PGP private key.

Parameters

mixed $text

The text to be decrypted.

mixed $key

The private key to use for decryption (must be decrypted).

Throws

\Horde_Pgp_Exception

Returns

\Horde_Pgp_Element_Message

$msg The decrypted message.

decryptSymmetric()

decryptSymmetric(mixed  $text, string  $passphrase) : array

Decrypts text using a PGP symmetric passphrase.

Parameters

mixed $text

The text to be decrypted.

string $passphrase

The symmetric passphrase used to encrypt the data.

Throws

\Horde_Pgp_Exception

Returns

array —

$data Array of decrypted data. Outer array indicates a message block. Each entry is an array with two array elements: a list of data packets contained in that message block and a list of signature data associated with that block.

verify()

verify(mixed  $text, mixed  $key) : array

Verifies text using a PGP public key.

Parameters

mixed $text

The text to be verified

mixed $key

The public key used for signing.

Throws

\Horde_Pgp_Exception

Returns

array —

List of verified packets. Each sub array contains two values: the list of packets verfied by signing and the list of signature packets used to verify.

verifyDetached()

verifyDetached(mixed  $text, mixed  $sig, mixed  $key) : \{@see

Verifies text using a PGP public key and a detached signature.

Parameters

mixed $text

The text to be verified

mixed $sig

The detached signature.

mixed $key

The public key used for signing.

Throws

\Horde_Pgp_Exception

Returns

\{@see —

detach()}

_initDrivers()

_initDrivers() 

Initialize the backend driver list.

_runInBackend()

_runInBackend(  $cmd,   $args,   $error) 

TODO

Parameters

$cmd
$args
$error

_getPrivateKey()

_getPrivateKey(  $key) 

TODO

Parameters

$key

_getCipher()

_getCipher(  $opts,   $default) 

TODO

Parameters

$opts
$default

_getCompression()

_getCompression(  $opts,   $default) 

TODO

Parameters

$opts
$default

_getOption()

_getOption(  $opts,   $default,   $name,   $map) 

TODO

Parameters

$opts
$default
$name
$map