PHP Класс Horde_Crypt_Pgp, horde

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.
Автор: Michael Slusarz ([email protected])
Наследование: extends Horde_Crypt
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_armor
$_backends array List of initialized backends.

Открытые методы

Метод Описание
__construct ( array $params = [] ) Constructor.
decrypt ( string $text, array $params = [] ) : object Decrypts text using PGP.
encrypt ( string $text, array $params = [] ) : string Encrypts text using PGP.
encryptMIMEPart ( Horde_Mime_Part $mime_part, array $params = [] ) : mixed Encrypts a MIME part using PGP.
encryptedSymmetrically ( string $text ) : boolean Returns whether a text has been encrypted symmetrically.
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.
generateRevocation ( $key, $email, $passphrase )
getFingerprintsFromKey ( string $pgpdata ) : array Get the fingerprints from a key block.
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.
getKeyIDString ( $keyid ) TODO
getPublicKeyFromPrivateKey ( string $data ) : string Generates a public key from a private key.
getPublicKeyserver ( $keyid, $server = self::KEYSERVER_PUBLIC, $timeout = self::KEYSERVER_TIMEOUT, $address = null )
getSignersKeyID ( string $text ) : string Returns the key ID of the key used to sign a block of PGP data.
parsePGPData ( $text )
pgpPacketInformation ( string $pgpdata ) : array Returns information on a PGP data block.
pgpPacketInformationMultiple ( string $pgpdata ) : array Returns all information on a PGP data block.
pgpPacketSignature ( string $pgpdata, string $email ) : array Returns only information on the first ID that matches the email address input.
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).
pgpPrettyKey ( string $pgpdata ) : string Returns human readable information on a PGP key.
publicKeyMIMEPart ( string $key ) : Horde_Mime_Part Generates a Horde_Mime_Part object, in accordance with RFC 3156, that contains a public key.
putPublicKeyserver ( string $pubkey, string $server = self::KEYSERVER_PUBLIC, float $timeout = self::KEYSERVER_TIMEOUT ) Sends a PGP public key to a public keyserver.
signAndEncryptMIMEPart ( Horde_Mime_Part $mime_part, array $sign_params = [], array $encrypt_params = [] ) : mixed Signs and encrypts a MIME part using PGP.
signMIMEPart ( Horde_Mime_Part $mime_part, array $params = [] ) : mixed Signs a MIME part using PGP.
verifyPassphrase ( string $public_key, string $private_key, string $passphrase ) : boolean Verify a passphrase for a given public/private keypair.

Защищенные методы

Метод Описание
_getKeyserverOb ( $server )
_initDrivers ( ) Initialize the backend driver list.
_pgpPacketSignature ( array $data, array $out ) : array Adds some data to the pgpPacketSignature*() function array.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( array $params = [] )
$params array 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.

_getKeyserverOb() защищенный Метод

Устаревший:
protected _getKeyserverOb ( $server )

_initDrivers() защищенный Метод

Initialize the backend driver list.
protected _initDrivers ( )

_pgpPacketSignature() защищенный Метод

Adds some data to the pgpPacketSignature*() function array.
protected _pgpPacketSignature ( array $data, array $out ) : array
$data array See pgpPacketSignature().
$out array The return array.
Результат array The return array.

decrypt() публичный Метод

Decrypts text using PGP.
public decrypt ( string $text, array $params = [] ) : object
$text string The text to be PGP decrypted.
$params array The parameters needed for decryption. See the individual _decrypt*() functions for the parameter requirements.
Результат object An object with the following properties: - message: (string) The signature result text. - result: (boolean) The result of the signature test.

encrypt() публичный Метод

Encrypts text using PGP.
public encrypt ( string $text, array $params = [] ) : string
$text string The text to be PGP encrypted.
$params array The parameters needed for encryption. See the individual _encrypt*() functions for the parameter requirements.
Результат string The encrypted message.

encryptMIMEPart() публичный Метод

Encrypts a MIME part using PGP.
public encryptMIMEPart ( Horde_Mime_Part $mime_part, array $params = [] ) : mixed
$mime_part Horde_Mime_Part The object to encrypt.
$params array The parameters required for encryption ({@see \_encryptMessage()}).
Результат mixed A Horde_Mime_Part object that is encrypted according to RFC 3156.

encryptedSymmetrically() публичный Метод

Returns whether a text has been encrypted symmetrically.
public encryptedSymmetrically ( string $text ) : boolean
$text string The PGP encrypted text.
Результат boolean True if the text is symmetrically encrypted.

generateKey() публичный Метод

Generates a personal Public/Private keypair combination.
public generateKey ( string $realname, string $email, string $passphrase, string $comment = '', integer $keylength = 1024, integer $expire = null, string $key_type = 'RSA', string $subkey_type = 'RSA' ) : array
$realname string The name to use for the key.
$email string The email to use for the key.
$passphrase string The passphrase to use for the key.
$comment string The comment to use for the key.
$keylength integer The keylength to use for the key.
$expire integer The expiration date (UNIX timestamp). No expiration if empty.
$key_type string Key type (@since 2.2.0).
$subkey_type string Subkey type (@since 2.2.0).
Результат array An array consisting of the following keys/values: - private: (string) Private key. - public: (string) Public key.

generateRevocation() публичный Метод

Устаревший:
public generateRevocation ( $key, $email, $passphrase )

getFingerprintsFromKey() публичный Метод

Get the fingerprints from a key block.
public getFingerprintsFromKey ( string $pgpdata ) : array
$pgpdata string The PGP data block.
Результат array The fingerprints in $pgpdata indexed by key id.

getKeyID() публичный Метод

Returns the first matching key ID for an email address from a public keyserver.
public getKeyID ( string $address, string $server = self::KEYSERVER_PUBLIC, float $timeout = self::KEYSERVER_TIMEOUT ) : string
$address string The email address of the PGP key.
$server string The keyserver to use.
$timeout float The keyserver timeout.
Результат string The PGP key ID.

getKeyIDString() публичный Метод

TODO
С версии: 2.4.0
public getKeyIDString ( $keyid )

getPublicKeyFromPrivateKey() публичный Метод

Generates a public key from a private key.
public getPublicKeyFromPrivateKey ( string $data ) : string
$data string Armor text of private key.
Результат string Armor text of public key, or null if it could not be generated.

getPublicKeyserver() публичный Метод

Устаревший: Use Horde_Crypt_Pgp_Keyserver instead.
public getPublicKeyserver ( $keyid, $server = self::KEYSERVER_PUBLIC, $timeout = self::KEYSERVER_TIMEOUT, $address = null )

getSignersKeyID() публичный Метод

Returns the key ID of the key used to sign a block of PGP data.
public getSignersKeyID ( string $text ) : string
$text string The PGP signed text block.
Результат string The key ID of the key used to sign $text, or null if not found.

parsePGPData() публичный Метод

Устаревший: Use Horde_Crypt_Pgp_Parse instead.
public parsePGPData ( $text )

pgpPacketInformation() публичный Метод

If the data block contains multiple keys, only the first is returned. To return all keys of this block, use pgpPacketInformationMultiple() instead.
См. также: pgpPacketInformationMultiple()
public pgpPacketInformation ( string $pgpdata ) : array
$pgpdata string The PGP data block.
Результат 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() публичный Метод

Returns all information on a PGP data block.
См. также: pgpPacketInformation()
public pgpPacketInformationMultiple ( string $pgpdata ) : array
$pgpdata string The PGP data block.
Результат array An array with information on the PGP data block. The array contains one or more entries as returned from pgpPacketInformation().

pgpPacketSignature() публичный Метод

Returns only information on the first ID that matches the email address input.
public pgpPacketSignature ( string $pgpdata, string $email ) : array
$pgpdata string The PGP data block.
$email string An e-mail address.
Результат 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() публичный Метод

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).
См. также: pgpPacketSignature()
public pgpPacketSignatureByUidIndex ( string $pgpdata, string $uid_idx ) : array
$pgpdata string See pgpPacketSignature().
$uid_idx string The UID index.
Результат array See pgpPacketSignature().

pgpPrettyKey() публичный Метод

Returns human readable information on a PGP key.
public pgpPrettyKey ( string $pgpdata ) : string
$pgpdata string The PGP data block.
Результат string Tabular information on the PGP key.

publicKeyMIMEPart() публичный Метод

Generates a Horde_Mime_Part object, in accordance with RFC 3156, that contains a public key.
public publicKeyMIMEPart ( string $key ) : Horde_Mime_Part
$key string The public key.
Результат Horde_Mime_Part An object that contains the public key.

putPublicKeyserver() публичный Метод

Sends a PGP public key to a public keyserver.
public putPublicKeyserver ( string $pubkey, string $server = self::KEYSERVER_PUBLIC, float $timeout = self::KEYSERVER_TIMEOUT )
$pubkey string The PGP public key
$server string The keyserver to use.
$timeout float The keyserver timeout.

signAndEncryptMIMEPart() публичный Метод

Signs and encrypts a MIME part using PGP.
public signAndEncryptMIMEPart ( Horde_Mime_Part $mime_part, array $sign_params = [], array $encrypt_params = [] ) : mixed
$mime_part Horde_Mime_Part The object to sign and encrypt.
$sign_params array The parameters required for signing ({@see \_encryptSignature()}).
$encrypt_params array The parameters required for encryption ({@see \_encryptMessage()}).
Результат mixed A Horde_Mime_Part object that is signed and encrypted according to RFC 3156.

signMIMEPart() публичный Метод

Signs a MIME part using PGP.
public signMIMEPart ( Horde_Mime_Part $mime_part, array $params = [] ) : mixed
$mime_part Horde_Mime_Part The object to sign.
$params array The parameters required for signing. ({@see \_encryptSignature()}).
Результат mixed A Horde_Mime_Part object that is signed according to RFC 3156.

verifyPassphrase() публичный Метод

Verify a passphrase for a given public/private keypair.
public verifyPassphrase ( string $public_key, string $private_key, string $passphrase ) : boolean
$public_key string The user's PGP public key.
$private_key string The user's PGP private key.
$passphrase string The user's passphrase.
Результат boolean Returns true on valid passphrase, false on invalid passphrase.

Описание свойств

$_armor защищенное свойство

Устаревший: Use Horde_Crypt_Pgp_Parse instead.
protected $_armor

$_backends защищенное свойство

List of initialized backends.
protected array $_backends
Результат array