Constants

ARMOR_MESSAGE

ARMOR_MESSAGE

ARMOR_SIGNED_MESSAGE

ARMOR_SIGNED_MESSAGE

ARMOR_PUBLIC_KEY

ARMOR_PUBLIC_KEY

ARMOR_PRIVATE_KEY

ARMOR_PRIVATE_KEY

ARMOR_SIGNATURE

ARMOR_SIGNATURE

ARMOR_TEXT

ARMOR_TEXT

KEYSERVER_PUBLIC

KEYSERVER_PUBLIC

KEYSERVER_REFUSE

KEYSERVER_REFUSE

KEYSERVER_TIMEOUT

KEYSERVER_TIMEOUT

Properties

$_params

$_params : array

Configuration parameters.

Type

array

$_backends

$_backends : array

List of initialized backends.

Type

array

$_armor

$_armor : 

Type

Methods

factory()

factory(string  $driver, array  $params = array()) : \Horde_Crypt

Attempts to return a concrete Horde_Crypt instance based on $driver.

Parameters

string $driver

Either a driver name, or the full class name to use (class must extend Horde_Crypt).

array $params

A hash containing any additional configuration or parameters a subclass might need.

Throws

\Horde_Crypt_Exception

Returns

\Horde_Crypt

The newly created concrete instance.

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Configuration parameters:

  • backends: (array) The explicit list of backend drivers (Horde_Crypt_Pgp_Backend objects) to use.
  • program: (string) The path to the GnuPG binary.
  • temp: (string) Location of temporary directory.

encrypt()

encrypt(string  $text, array  $params = array()) : string

Encrypts text using PGP.

This method should be provided by all classes that extend Horde_Crypt.

Parameters

string $text

The text to be PGP encrypted.

array $params

The parameters needed for encryption. See the individual _encrypt*() functions for the parameter requirements.

Throws

\Horde_Crypt_Exception

Returns

string —

The encrypted message.

decrypt()

decrypt(string  $text, array  $params = array()) : object

Decrypts text using PGP.

This method should be provided by all classes that extend Horde_Crypt.

Parameters

string $text

The text to be PGP decrypted.

array $params

The parameters needed for decryption. See the individual _decrypt*() functions for the parameter requirements.

Throws

\Horde_Crypt_Exception

Returns

object —

An object with the following properties:

  • message: (string) The signature result text.
  • result: (boolean) The result of the signature test.

generateKey()

generateKey(string  $realname, string  $email, string  $passphrase, string  $comment = '', integer  $keylength = 1024, integer  $expire = null, string  $key_type = 'RSA', string  $subkey_type = 'RSA') : array

Generates a personal Public/Private keypair combination.

Parameters

string $realname

The name to use for the key.

string $email

The email to use for the key.

string $passphrase

The passphrase to use for the key.

string $comment

The comment to use for the key.

integer $keylength

The keylength to use for the key.

integer $expire

The expiration date (UNIX timestamp). No expiration if empty.

string $key_type

Key type (@since 2.2.0).

string $subkey_type

Subkey type (@since 2.2.0).

Throws

\Horde_Crypt_Exception

Returns

array —

An array consisting of the following keys/values:

  • private: (string) Private key.
  • public: (string) Public key.

pgpPacketInformation()

pgpPacketInformation(string  $pgpdata) : array

Returns information on a PGP data block.

If the data block contains multiple keys, only the first is returned. To return all keys of this block, use pgpPacketInformationMultiple() instead.

Parameters

string $pgpdata

The PGP data block.

Returns

array —

An array with information on the PGP data block. If an element is not present in the data block, it will likewise not be set in the array.

Array Format:
-------------
[public_key]/[secret_key] => Array
  (
    [created] => Key creation - UNIX timestamp
    [expires] => Key expiration - UNIX timestamp (0 = never expires)
    [size]    => Size of the key in bits
  )

[keyid] => Key ID of the PGP data (if available)
           16-bit hex value

[signature] => Array (
    [id{n}/'_SIGNATURE'] => Array (
        [name]        => Full Name
        [comment]     => Comment
        [email]       => E-mail Address
        [keyid]       => 16-bit hex value
        [created]     => Signature creation - UNIX timestamp
        [expires]     => Signature expiration - UNIX timestamp
        [micalg]      => The hash used to create the signature
        [sig_{hex}]   => Array [details of a sig verifying the ID] (
            [created]     => Signature creation - UNIX timestamp
            [expires]     => Signature expiration - UNIX timestamp
            [keyid]       => 16-bit hex value
            [micalg]      => The hash used to create the signature
        )
    )
)

Each user ID will be stored in the array 'signature' and have data associated with it, including an array for information on each signature that has signed that UID. Signatures not associated with a UID (e.g. revocation signatures and sub keys) will be stored under the special keyword '_SIGNATURE'.

pgpPacketInformationMultiple()

pgpPacketInformationMultiple(string  $pgpdata) : array

Returns all information on a PGP data block.

Parameters

string $pgpdata

The PGP data block.

Returns

array —

An array with information on the PGP data block. The array contains one or more entries as returned from pgpPacketInformation().

pgpPrettyKey()

pgpPrettyKey(string  $pgpdata) : string

Returns human readable information on a PGP key.

Parameters

string $pgpdata

The PGP data block.

Throws

\Horde_Crypt_Exception

Returns

string —

Tabular information on the PGP key.

getKeyIDString()

getKeyIDString(  $keyid) 

TODO

Parameters

$keyid

pgpPacketSignature()

pgpPacketSignature(string  $pgpdata, string  $email) : array

Returns only information on the first ID that matches the email address input.

Parameters

string $pgpdata

The PGP data block.

string $email

An e-mail address.

Returns

array —

An array with information on the PGP data block. If an element is not present in the data block, it will likewise not be set in the array. Array elements:

  • comment: Comment
  • created: Signature creation (UNIX timestamp)
  • email: E-mail Address
  • key_created: Key creation (UNIX timestamp)
  • key_expires: Key expiration (UNIX timestamp; 0 = never expires)
  • key_size: Size of the key in bits
  • key_type: The key type (public_key or secret_key)
  • keyid: 16-bit hex value
  • micalg: The hash used to create the signature
  • name: Full Name

pgpPacketSignatureByUidIndex()

pgpPacketSignatureByUidIndex(string  $pgpdata, string  $uid_idx) : array

Returns information on a PGP signature embedded in PGP data. Similar to pgpPacketSignature(), but returns information by unique User ID Index (format id{n} where n is an integer of 1 or greater).

Parameters

string $pgpdata

See pgpPacketSignature().

string $uid_idx

The UID index.

Returns

array —

See pgpPacketSignature().

getSignersKeyID()

getSignersKeyID(string  $text) : string

Returns the key ID of the key used to sign a block of PGP data.

Parameters

string $text

The PGP signed text block.

Returns

string —

The key ID of the key used to sign $text, or null if not found.

verifyPassphrase()

verifyPassphrase(string  $public_key, string  $private_key, string  $passphrase) : boolean

Verify a passphrase for a given public/private keypair.

Parameters

string $public_key

The user's PGP public key.

string $private_key

The user's PGP private key.

string $passphrase

The user's passphrase.

Throws

\Horde_Crypt_Exception

Returns

boolean —

Returns true on valid passphrase, false on invalid passphrase.

putPublicKeyserver()

putPublicKeyserver(string  $pubkey, string  $server = self::KEYSERVER_PUBLIC, float  $timeout = self::KEYSERVER_TIMEOUT) 

Sends a PGP public key to a public keyserver.

Parameters

string $pubkey

The PGP public key

string $server

The keyserver to use.

float $timeout

The keyserver timeout.

Throws

\Horde_Crypt_Exception

getKeyID()

getKeyID(string  $address, string  $server = self::KEYSERVER_PUBLIC, float  $timeout = self::KEYSERVER_TIMEOUT) : string

Returns the first matching key ID for an email address from a public keyserver.

Parameters

string $address

The email address of the PGP key.

string $server

The keyserver to use.

float $timeout

The keyserver timeout.

Throws

\Horde_Crypt_Exception

Returns

string —

The PGP key ID.

getFingerprintsFromKey()

getFingerprintsFromKey(string  $pgpdata) : array

Get the fingerprints from a key block.

Parameters

string $pgpdata

The PGP data block.

Returns

array —

The fingerprints in $pgpdata indexed by key id.

getPublicKeyFromPrivateKey()

getPublicKeyFromPrivateKey(string  $data) : string

Generates a public key from a private key.

Parameters

string $data

Armor text of private key.

Returns

string —

Armor text of public key, or null if it could not be generated.

encryptedSymmetrically()

encryptedSymmetrically(string  $text) : boolean

Returns whether a text has been encrypted symmetrically.

Parameters

string $text

The PGP encrypted text.

Throws

\Horde_Crypt_Exception

Returns

boolean —

True if the text is symmetrically encrypted.

signMIMEPart()

signMIMEPart(\Horde_Mime_Part  $mime_part, array  $params = array()) : mixed

Signs a MIME part using PGP.

Parameters

\Horde_Mime_Part $mime_part

The object to sign.

array $params

The parameters required for signing. ({@see _encryptSignature()}).

Throws

\Horde_Crypt_Exception

Returns

mixed —

A Horde_Mime_Part object that is signed according to RFC 3156.

encryptMIMEPart()

encryptMIMEPart(\Horde_Mime_Part  $mime_part, array  $params = array()) : mixed

Encrypts a MIME part using PGP.

Parameters

\Horde_Mime_Part $mime_part

The object to encrypt.

array $params

The parameters required for encryption ({@see _encryptMessage()}).

Throws

\Horde_Crypt_Exception

Returns

mixed —

A Horde_Mime_Part object that is encrypted according to RFC 3156.

signAndEncryptMIMEPart()

signAndEncryptMIMEPart(\Horde_Mime_Part  $mime_part, array  $sign_params = array(), array  $encrypt_params = array()) : mixed

Signs and encrypts a MIME part using PGP.

Parameters

\Horde_Mime_Part $mime_part

The object to sign and encrypt.

array $sign_params

The parameters required for signing ({@see _encryptSignature()}).

array $encrypt_params

The parameters required for encryption ({@see _encryptMessage()}).

Throws

\Horde_Crypt_Exception

Returns

mixed —

A Horde_Mime_Part object that is signed and encrypted according to RFC 3156.

publicKeyMIMEPart()

publicKeyMIMEPart(string  $key) : \Horde_Mime_Part

Generates a Horde_Mime_Part object, in accordance with RFC 3156, that contains a public key.

Parameters

string $key

The public key.

Returns

\Horde_Mime_Part —

An object that contains the public key.

parsePGPData()

parsePGPData(  $text) 

Parameters

$text

getPublicKeyserver()

getPublicKeyserver(  $keyid,   $server = self::KEYSERVER_PUBLIC,   $timeout = self::KEYSERVER_TIMEOUT,   $address = null) 

Parameters

$keyid
$server
$timeout
$address

generateRevocation()

generateRevocation(  $key,   $email,   $passphrase) 

Parameters

$key
$email
$passphrase

_pgpPacketSignature()

_pgpPacketSignature(array  $data, array  $out) : array

Adds some data to the pgpPacketSignature*() function array.

Parameters

array $data

See pgpPacketSignature().

array $out

The return array.

Returns

array —

The return array.

_initDrivers()

_initDrivers() 

Initialize the backend driver list.