Class Horde_Crypt_pgp

Description

Horde_Crypt_pgp:: provides a framework for Horde applications to interact with the GNU Privacy Guard program ("GnuPG"). GnuPG implements the OpenPGP standard (RFC 2440).

GnuPG Website: http://www.gnupg.org/

This class has been developed with, and is only guaranteed to work with, Version 1.21 or above of GnuPG.

$Horde: framework/Crypt/Crypt/pgp.php,v 1.85.2.30 2009/01/06 15:23:00 jan Exp $

Copyright 2002-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /Crypt/Crypt/pgp.php (line 79)

Horde_Crypt
   |
   --Horde_Crypt_pgp
Variable Summary
Method Summary
 Horde_Crypt_pgp Horde_Crypt_pgp ([array $params = array()])
 string decrypt (string $text, [array $params = array()])
 string encrypt (string $text, [array $params = array()])
 boolean encryptedSymmetrically (string $text)
 MIME_Part encryptMIMEPart (MIME_Part $mime_part, [array $params = array()])
 array generateKey (string $realname, string $email, string $passphrase, [string $comment = ''], [integer $keylength = 1024])
 string generateRevocation (string $key, string $email, string $passphrase)
 array getFingerprintsFromKey (string $pgpdata)
 string getKeyID (string $address, [string $server = PGP_KEYSERVER_PUBLIC], [float $timeout = PGP_KEYSERVER_TIMEOUT])
 string getPublicKeyserver (string $keyid, [string $server = PGP_KEYSERVER_PUBLIC], [float $timeout = PGP_KEYSERVER_TIMEOUT], [string $address = null])
 string getSignersFingerprint (string $text)
 string getSignersKeyID (string $text)
 array parsePGPData (string $text)
 array pgpPacketInformation (string $pgpdata)
 array pgpPacketSignature (string $pgpdata, string $email)
 array pgpPacketSignatureByUidIndex (string $pgpdata, string $uid_idx)
 string pgpPrettyKey (string $pgpdata)
 MIME_Part publicKeyMIMEPart (string $key)
 PEAR_Error putPublicKeyserver (string $pubkey, [string $server = PGP_KEYSERVER_PUBLIC], [float $timeout = PGP_KEYSERVER_TIMEOUT])
 MIME_Part signAndEncryptMIMEPart (MIME_Part $mime_part, [array $sign_params = array()], [array $encrypt_params = array()])
 MIME_Part signMIMEPart (MIME_Part $mime_part, [array $params = array()])
 boolean verifyPassphrase (string $public_key, string $private_key, string $passphrase)
 void _getKeyIDString ( $keyid)
 void _pgpPrettyKeyFormatter ( &$s,  $k,  $m)
Variables
boolean $multipleRecipientEncryption = true (line 144)

The existence of this property indicates that multiple recipient encryption is available.

  • deprecated:
  • since: Horde 3.1
array $_armor = array(
'MESSAGE' => PGP_ARMOR_MESSAGE,
'SIGNED MESSAGE' => PGP_ARMOR_SIGNED_MESSAGE,
'PUBLIC KEY BLOCK' => PGP_ARMOR_PUBLIC_KEY,
'PRIVATE KEY BLOCK' => PGP_ARMOR_PRIVATE_KEY,
'SIGNATURE' => PGP_ARMOR_SIGNATURE
)
(line 87)

Strings in armor header lines used to distinguish between the different types of PGP decryption/encryption.

array $_gnupg (line 118)

GnuPG program location/common options.

array $_hashAlg = array(
1 => 'pgp-md5',
2 => 'pgp-sha1',
3 => 'pgp-ripemd160',
5 => 'pgp-md2',
6 => 'pgp-tiger192',
7 => 'pgp-haval-5-160',
8 => 'pgp-sha256',
9 => 'pgp-sha384',
10 => 'pgp-sha512',
11 => 'pgp-sha224',
)
(line 100)

The list of PGP hash algorithms (from RFC 3156).

string $_privateKeyring (line 132)

Filename of the temporary private keyring.

string $_publicKeyring (line 125)

Filename of the temporary public keyring.

Inherited Variables

Inherited from Horde_Crypt

Horde_Crypt::$_tempdir
Methods
Constructor Horde_Crypt_pgp (line 153)

Constructor.

Horde_Crypt_pgp Horde_Crypt_pgp ([array $params = array()])
  • array $params: Parameter array containing the path to the GnuPG binary (key = 'program') and to a temporary directory.
decrypt (line 1037)

Decrypts text using PGP.

  • return: The decrypted message, or PEAR_Error on error.
string decrypt (string $text, [array $params = array()])
  • string $text: The text to be PGP decrypted.
  • array $params: The parameters needed for decryption. See the individual _decrypt*() functions for the parameter requirements.

Redefinition of:
Horde_Crypt::decrypt()
Decrypt the requested data.
encrypt (line 1016)

Encrypts text using PGP.

  • return: The encrypted message, or PEAR_Error on error.
string encrypt (string $text, [array $params = array()])
  • string $text: The text to be PGP encrypted.
  • array $params: The parameters needed for encryption. See the individual _encrypt*() functions for the parameter requirements.

Redefinition of:
Horde_Crypt::encrypt()
Encrypt the requested data.
encryptedSymmetrically (line 1058)

Returns whether a text has been encrypted symmetrically.

  • return: True if the text is symmetricallly encrypted.
  • since: Horde 3.2
boolean encryptedSymmetrically (string $text)
  • string $text: The PGP encrypted text.
encryptMIMEPart (line 1551)

Encrypts a MIME_Part using PGP.

  • return: A MIME_Part object that is encrypted according to RFC 2015/3156, or PEAR_Error on error.
  • see: _encryptMessage().
MIME_Part encryptMIMEPart (MIME_Part $mime_part, [array $params = array()])
  • MIME_Part $mime_part: The MIME_Part object to encrypt.
  • array $params: The parameters required for encryption.
generateKey (line 196)

Generates a personal Public/Private keypair combination.

  • return: An array consisting of the public key and the private key, or PEAR_Error on error.
     Return array:
     Key            Value
     --------------------------
     'public'   =>  Public Key
     'private'  =>  Private Key
array generateKey (string $realname, string $email, string $passphrase, [string $comment = ''], [integer $keylength = 1024])
  • 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.
generateRevocation (line 1726)

Generates a revocation certificate.

  • return: The revocation certificate, or PEAR_Error on error.
  • since: Horde 3.2
string generateRevocation (string $key, string $email, string $passphrase)
  • string $key: The private key.
  • string $email: The email to use for the key.
  • string $passphrase: The passphrase to use for the key.
getFingerprintsFromKey (line 908)

Get the fingerprints from a key block.

  • return: The fingerprints in $pgpdata indexed by key id.
array getFingerprintsFromKey (string $pgpdata)
  • string $pgpdata: The PGP data block.
getKeyID (line 858)

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

  • return: The PGP key ID, or PEAR_Error on error.
  • since: Horde 3.2
string getKeyID (string $address, [string $server = PGP_KEYSERVER_PUBLIC], [float $timeout = PGP_KEYSERVER_TIMEOUT])
  • string $address: The email address of the PGP key.
  • string $server: The keyserver to use.
  • float $timeout: The keyserver timeout.
getPublicKeyserver (line 779)

Returns a PGP public key from a public keyserver.

  • return: The PGP public key, or PEAR_Error on error.
string getPublicKeyserver (string $keyid, [string $server = PGP_KEYSERVER_PUBLIC], [float $timeout = PGP_KEYSERVER_TIMEOUT], [string $address = null])
  • string $keyid: The key ID of the PGP key.
  • string $server: The keyserver to use.
  • float $timeout: The keyserver timeout.
  • string $address: The email address of the PGP key. @since Horde 3.2.
getSignersFingerprint (line 645)

Returns the short fingerprint (Key ID) of the key used to sign a block of PGP data.

  • return: The short fingerprint of the key used to sign $text.
  • deprecated: Use getSignersKeyID() instead.
  • todo: Remove for Horde 4
string getSignersFingerprint (string $text)
  • string $text: The PGP signed text block.
getSignersKeyID (line 659)

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

  • return: The key ID of the key used to sign $text.
  • since: Horde 3.2
string getSignersKeyID (string $text)
  • string $text: The PGP signed text block.
parsePGPData (line 731)

Parses a message into text and PGP components.

  • return: An array with the parsed text, returned in blocks of text corresponding to their actual order.
     Return array:
     Key         Value
     -------------------------------------------------
     'type'  =>  The type of data contained in block.
                 Valid types are defined at the top of this class
                 (the PGP_ARMOR_* constants).
     'data'  =>  The actual data for each section.
array parsePGPData (string $text)
  • string $text: The text to parse.
pgpPacketInformation (line 301)

Returns information on a PGP data block.

  • return:

    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
       )
    
     [fingerprint] => Fingerprint of the PGP data (if available)
                      16-bit hex value (DEPRECATED)
     [keyid] => Key ID of the PGP data (if available)
                16-bit hex value (as of Horde 3.2)
    
     [signature] => Array (
         [id{n}/'_SIGNATURE'] => Array (
             [name]        => Full Name
             [comment]     => Comment
             [email]       => E-mail Address
             [fingerprint] => 16-bit hex value (DEPRECATED)
             [keyid]       => 16-bit hex value (as of Horde 3.2)
             [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
                 [fingerprint] => 16-bit hex value (DEPRECATED)
                 [keyid]       => 16-bit hex value (as of Horde 3.2)
                 [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'.

array pgpPacketInformation (string $pgpdata)
  • string $pgpdata: The PGP data block.
pgpPacketSignature (line 528)

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

  • return: 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 Fields:
     -------------
     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)
     name         =>  Full Name
     comment      =>  Comment
     email        =>  E-mail Address
     fingerprint  =>  16-bit hex value (DEPRECATED)
     keyid        =>  16-bit hex value
     created      =>  Signature creation - UNIX timestamp
     micalg       =>  The hash used to create the signature
array pgpPacketSignature (string $pgpdata, string $email)
  • string $pgpdata: The PGP data block.
  • string $email: An e-mail address.
pgpPacketSignatureByUidIndex (line 572)

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).

  • return: See pgpPacketSignature().
array pgpPacketSignatureByUidIndex (string $pgpdata, string $uid_idx)
  • string $pgpdata: See pgpPacketSignature().
  • string $uid_idx: The UID index.
pgpPrettyKey (line 438)

Returns human readable information on a PGP key.

  • return: Tabular information on the PGP key.
string pgpPrettyKey (string $pgpdata)
  • string $pgpdata: The PGP data block.
publicKeyMIMEPart (line 1620)

Generates a MIME_Part object, in accordance with RFC 2015/3156, that contains a public key.

  • return: A MIME_Part object that contains the public key.
MIME_Part publicKeyMIMEPart (string $key)
  • string $key: The public key.
putPublicKeyserver (line 815)

Sends a PGP public key to a public keyserver.

  • return: PEAR_Error on error/failure.
PEAR_Error putPublicKeyserver (string $pubkey, [string $server = PGP_KEYSERVER_PUBLIC], [float $timeout = PGP_KEYSERVER_TIMEOUT])
  • string $pubkey: The PGP public key
  • string $server: The keyserver to use.
  • float $timeout: The keyserver timeout.
signAndEncryptMIMEPart (line 1587)

Signs and encrypts a MIME_Part using PGP.

  • return: A MIME_Part object that is signed and encrypted according to RFC 2015/3156, or PEAR_Error on error.
  • see: _encryptMessage().
  • see: _encryptSignature().
MIME_Part signAndEncryptMIMEPart (MIME_Part $mime_part, [array $sign_params = array()], [array $encrypt_params = array()])
  • MIME_Part $mime_part: The MIME_Part object to sign and encrypt.
  • array $sign_params: The parameters required for signing.
  • array $encrypt_params: The parameters required for encryption.
signMIMEPart (line 1503)

Signs a MIME_Part using PGP.

  • return: A MIME_Part object that is signed according to RFC 2015/3156, or PEAR_Error on error.
  • see: _encryptSignature().
MIME_Part signMIMEPart (MIME_Part $mime_part, [array $params = array()])
  • MIME_Part $mime_part: The MIME_Part object to sign.
  • array $params: The parameters required for signing.
verifyPassphrase (line 691)

Verify a passphrase for a given public/private keypair.

  • return: Returns true on valid passphrase, false on invalid passphrase, and PEAR_Error on error.
boolean verifyPassphrase (string $public_key, string $private_key, string $passphrase)
  • string $public_key: The user's PGP public key.
  • string $private_key: The user's PGP private key.
  • string $passphrase: The user's passphrase.
_getKeyIDString (line 490)
void _getKeyIDString ( $keyid)
  • $keyid
_pgpPacketInformationHelper (line 426)
void _pgpPacketInformationHelper ( $a)
  • $a
_pgpPrettyKeyFormatter (line 485)
void _pgpPrettyKeyFormatter ( &$s,  $k,  $m)
  • &$s
  • $k
  • $m

Inherited Methods

Inherited From Horde_Crypt

 Horde_Crypt::decrypt()
 Horde_Crypt::encrypt()
 Horde_Crypt::factory()
 Horde_Crypt::requireSecureConnection()
 Horde_Crypt::singleton()

Documentation generated on Sun, 30 Jan 2011 05:20:33 +0000 by phpDocumentor 1.4.3