Constants

PGP_ARMOR

PGP_ARMOR

PGP_CHARSET

PGP_CHARSET

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()}

signPart()

signPart(\Horde_Mime_Part  $part, mixed  $key, array  $opts = array()) : \Horde_Mime_Part

Signs a MIME part using PGP.

Parameters

\Horde_Mime_Part $part

The object to sign.

mixed $key

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

array $opts

Additional options:

  • compress: (string) Default compression algorithm.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Mime_Part —

A signed object.

encryptPart()

encryptPart(\Horde_Mime_Part  $part, array  $opts = array()) : \Horde_Mime_Part

Encrypts a MIME part using PGP.

Parameters

\Horde_Mime_Part $part

The object to encrypt.

array $opts

Additional options:

  • cipher: (string) Default symmetric cipher algorithm to use.
  • compress: (string) Default compression algorithm.
  • pubkeys: (mixed) The public key(s) to use for encryption.
  • symmetric: (string) If set, use as symmetric key.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Mime_Part —

An encrypted object.

signAndEncryptPart()

signAndEncryptPart(\Horde_Mime_Part  $part, mixed  $privkey, array  $opts = array()) : \Horde_Mime_Part

Signs and encrypts a MIME part using PGP.

Parameters

\Horde_Mime_Part $part

The part to sign and encrypt.

mixed $privkey

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

array $opts

Additional options:

  • cipher: (string) Default symmetric cipher algorithm to use.
  • compress: (string) Default compression algorithm.
  • pubkeys: (mixed) The public key(s) to use for encryption.
  • symmetric: (string) If set, use as symmetric key.

Throws

\Horde_Pgp_Exception

Returns

\Horde_Mime_Part —

A signed and encrypted part.

publicKeyPart()

publicKeyPart(mixed  $key) : \Horde_Mime_Part

Generate a Horde_Mime_Part object that contains a public key (RFC 3156 [7]).

Parameters

mixed $key

The public key.

Returns

\Horde_Mime_Part —

An object that contains the public key.

armorToPart()

armorToPart(mixed  $input, array  $opts = array()) : mixed

Converts armored input into a Horde_Mime_Part object.

Parameters

mixed $input

Armored input.

array $opts

Additional options:

  • charset: (string) Charset of the armored input.

Returns

mixed —

Either null if no PGP data was found, or a Horde_Mime_Part object.

_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

_signPart()

_signPart(  $part,   $detach_sig) 

Parameters

$part
$detach_sig

_encryptPart()

_encryptPart(  $data,   $opts) : \Horde_Mime_Part

Create the base MIME part used for encryption (RFC 3156 [4]).

Parameters

$data
$opts

Returns

\Horde_Mime_Part —

Base encrypted MIME part.

_encryptBase()

_encryptBase(\Horde_Pgp_Element_Message  $encrypted) : \Horde_Mime_Part

Create the base MIME part used for encryption (RFC 3156 [4]).

Parameters

\Horde_Pgp_Element_Message $encrypted

Encrypted data.

Returns

\Horde_Mime_Part —

Base encrypted MIME part.