PHP Класс IMP_Pgp, horde

Автор: Michael Slusarz ([email protected])
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_pgp Horde_Crypt_Pgp Pgp object.

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

Метод Описание
__construct ( Horde_Crypt_Pgp $pgp ) Constructor.
addPersonalPrivateKey ( mixed $private_key ) Add the personal private key to the prefs.
addPersonalPublicKey ( mixed $public_key ) Add the personal public key to the prefs.
addPublicKey ( string $public_key ) : array Add a public key to an address book.
decryptMessage ( string $text, string $type, array $opts = [] ) : stdClass Decrypt a message with user's public/private keypair or a passphrase.
deletePersonalKeys ( ) Deletes the specified personal keys from the prefs.
deletePublicKey ( string $email ) Deletes a public key from a user's address book(s) by e-mail.
enabled ( ) : boolean Return whether PGP support is current enabled in IMP.
encryptList ( ) : array Return the list of available encryption options for composing.
encryptMimePart ( Horde_Mime_Part $mime_part, Horde_Mail_Rfc822_List $addresses, string $symmetric = null ) : Horde_Mime_Part Encrypt a Horde_Mime_Part using PGP using IMP default parameters.
encryptedSymmetrically ( string $text ) : boolean Returns whether a text has been encrypted symmetrically.
generatePersonalKeys ( string $name, string $email, string $passphrase, string $comment = '', string $keylength = 1024, integer $expire = null ) Generate the personal Public/Private keypair and store in prefs.
getKeyIdString ( $keyid )
getKeys ( string $data ) : array Extracts public/private keys from armor data.
getPassphrase ( integer $type, string $id = null ) : mixed Gets a passphrase from the session cache.
getPersonalPrivateKey ( ) : string Get the personal private key from the prefs.
getPersonalPublicKey ( ) : string Get the personal public key from the prefs.
getPublicKey ( string $address, array $options = [] ) : string Retrieves a public key by e-mail.
getSymmetricId ( string $mailbox, integer $uid, string $id ) : string Generates a cache ID for symmetric message data.
listPublicKeys ( ) : array Retrieves all public keys from a user's address book(s).
pgpPacketInformation ( string $pgpdata ) : array Returns 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.
prettyKey ( string $pgpdata ) : string Returns human readable information on a PGP key.
publicKeyMimePart ( ) : Horde_Mime_Part Generate a Horde_Mime_Part object, in accordance with RFC 2015/3156, that contains the user's public key.
sendToPublicKeyserver ( string $pubkey ) Send a public key to a public PGP keyserver.
signAndEncryptMimePart ( Horde_Mime_Part $mime_part, Horde_Mail_Rfc822_List $addresses, string $symmetric = null ) : Horde_Mime_Part Sign and Encrypt a Horde_Mime_Part using PGP using IMP default parameters.
signMimePart ( Horde_Mime_Part $mime_part ) : Horde_Mime_Part Sign a Horde_Mime_Part using PGP using IMP default parameters.
storePassphrase ( integer $type, string $passphrase, string $id = null ) : boolean Store's the user's passphrase in the session cache.
unsetPassphrase ( integer $type, string $id = null ) Clear the passphrase from the session cache.
verifySignature ( string $text, string $address, string $signature = '', string $charset = null ) : stdClass Verifies a signed message with a given public key.

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

Метод Описание
_encryptParameters ( Horde_Mail_Rfc822_List $addresses, string $symmetric ) : array Provide the list of parameters needed for encrypting a message.
_keyserverList ( ) : array Return list of keyserver objects.
_signParameters ( ) : array Provide the list of parameters needed for signing a message.

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

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

Constructor.
public __construct ( Horde_Crypt_Pgp $pgp )
$pgp Horde_Crypt_Pgp PGP object.

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

Provide the list of parameters needed for encrypting a message.
protected _encryptParameters ( Horde_Mail_Rfc822_List $addresses, string $symmetric ) : array
$addresses Horde_Mail_Rfc822_List The e-mail address of the keys to use for encryption.
$symmetric string If true, the symmetric password to use for encrypting. If null, uses the personal key.
Результат array The list of parameters needed by encrypt().

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

Return list of keyserver objects.
protected _keyserverList ( ) : array
Результат array List of Horde_Crypt_Pgp_Keyserver objects.

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

Provide the list of parameters needed for signing a message.
protected _signParameters ( ) : array
Результат array The list of parameters needed by encrypt().

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

Add the personal private key to the prefs.
public addPersonalPrivateKey ( mixed $private_key )
$private_key mixed The private key to add (either string or array).

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

Add the personal public key to the prefs.
public addPersonalPublicKey ( mixed $public_key )
$public_key mixed The public key to add (either string or array).

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

Add a public key to an address book.
public addPublicKey ( string $public_key ) : array
$public_key string An PGP public key.
Результат array See Horde_Crypt_Pgp::pgpPacketInformationMultiple()

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

Decrypt a message with user's public/private keypair or a passphrase.
public decryptMessage ( string $text, string $type, array $opts = [] ) : stdClass
$text string The text to decrypt.
$type string Either 'literal', 'personal', or 'symmetric'.
$opts array Additional options: - passphrase: (boolean) If $type is 'personal' or 'symmetrical', the passphrase to use. - sender: (string) The sender of the message (used to check signature if message is both encrypted & signed).
Результат stdClass See Horde_Crypt_Pgp::decrypt().

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

Deletes the specified personal keys from the prefs.
public deletePersonalKeys ( )

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

Deletes a public key from a user's address book(s) by e-mail.
public deletePublicKey ( string $email )
$email string The e-mail address to delete.

enabled() публичный статический Метод

Return whether PGP support is current enabled in IMP.
public static enabled ( ) : boolean
Результат boolean True if PGP support is enabled.

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

Return the list of available encryption options for composing.
public encryptList ( ) : array
Результат array Keys are encryption type constants, values are gettext strings describing the encryption type.

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

Encrypt a Horde_Mime_Part using PGP using IMP default parameters.
public encryptMimePart ( Horde_Mime_Part $mime_part, Horde_Mail_Rfc822_List $addresses, string $symmetric = null ) : Horde_Mime_Part
$mime_part Horde_Mime_Part The object to encrypt.
$addresses Horde_Mail_Rfc822_List The e-mail address of the keys to use for encryption.
$symmetric string If true, the symmetric password to use for encrypting. If null, uses the personal key.
Результат Horde_Mime_Part See Horde_Crypt_Pgp::encryptMimePart().

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.

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

Generate the personal Public/Private keypair and store in prefs.
public generatePersonalKeys ( string $name, string $email, string $passphrase, string $comment = '', string $keylength = 1024, integer $expire = null )
$name string See Horde_Crypt_Pgp::.
$email string See Horde_Crypt_Pgp::.
$passphrase string See Horde_Crypt_Pgp::.
$comment string See Horde_Crypt_Pgp::.
$keylength string See Horde_Crypt_Pgp::.
$expire integer See Horde_Crypt_Pgp::.

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

public getKeyIdString ( $keyid )

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

Extracts public/private keys from armor data.
public getKeys ( string $data ) : array
$data string Armor text.
Результат array Array with these keys: - public: (array) Array of public keys. - private: (array) Array of private keys.

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

Gets a passphrase from the session cache.
public getPassphrase ( integer $type, string $id = null ) : mixed
$type integer The type of passphrase. Either 'personal' or 'symmetric'.
$id string If $type is 'symmetric', the ID of the stored passphrase.
Результат mixed The passphrase, if set, or null.

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

Get the personal private key from the prefs.
public getPersonalPrivateKey ( ) : string
Результат string The personal PGP private key.

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

Get the personal public key from the prefs.
public getPersonalPublicKey ( ) : string
Результат string The personal PGP public key.

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

First, the key will be attempted to be retrieved from a user's address book(s). Second, if unsuccessful, the key is attempted to be retrieved via a public PGP keyserver.
public getPublicKey ( string $address, array $options = [] ) : string
$address string The e-mail address to search by.
$options array Additional options: - keyid: (string) The key ID of the user's key. DEFAULT: key ID not used - nocache: (boolean) Don't retrieve from cache? DEFAULT: false - nohooks: (boolean) Don't trigger hook when retrieving public key? DEFAULT: false - noserver: (boolean) Whether to check the public key servers for the key. DEFAULT: false
Результат string The PGP public key requested.

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

Generates a cache ID for symmetric message data.
public getSymmetricId ( string $mailbox, integer $uid, string $id ) : string
$mailbox string The mailbox of the message.
$uid integer The UID of the message.
$id string The MIME ID of the message.
Результат string A unique symmetric cache ID.

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

Retrieves all public keys from a user's address book(s).
public listPublicKeys ( ) : array
Результат array All PGP public keys available.

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

Returns information on a PGP data block.
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'.

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

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

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

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

Generate a Horde_Mime_Part object, in accordance with RFC 2015/3156, that contains the user's public key.
public publicKeyMimePart ( ) : Horde_Mime_Part
Результат Horde_Mime_Part See Horde_Crypt_Pgp::publicKeyMimePart().

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

Send a public key to a public PGP keyserver.
public sendToPublicKeyserver ( string $pubkey )
$pubkey string The PGP public key.

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

Sign and Encrypt a Horde_Mime_Part using PGP using IMP default parameters.
public signAndEncryptMimePart ( Horde_Mime_Part $mime_part, Horde_Mail_Rfc822_List $addresses, string $symmetric = null ) : Horde_Mime_Part
$mime_part Horde_Mime_Part The object to sign and encrypt.
$addresses Horde_Mail_Rfc822_List The e-mail address of the keys to use for encryption.
$symmetric string If true, the symmetric password to use for encrypting. If null, uses the personal key.
Результат Horde_Mime_Part See Horde_Crypt_Pgp::signAndencryptMimePart().

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

Sign a Horde_Mime_Part using PGP using IMP default parameters.
public signMimePart ( Horde_Mime_Part $mime_part ) : Horde_Mime_Part
$mime_part Horde_Mime_Part The object to sign.
Результат Horde_Mime_Part See Horde_Crypt_Pgp::signMIMEPart().

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

Store's the user's passphrase in the session cache.
public storePassphrase ( integer $type, string $passphrase, string $id = null ) : boolean
$type integer The type of passphrase. Either 'personal' or 'symmetric'.
$passphrase string The user's passphrase.
$id string If $type is 'symmetric', the ID of the stored passphrase.
Результат boolean Returns true if correct passphrase, false if incorrect.

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

Clear the passphrase from the session cache.
public unsetPassphrase ( integer $type, string $id = null )
$type integer The type of passphrase. Either 'personal' or 'symmetric'.
$id string If $type is 'symmetric', the ID of the stored passphrase. Else, all passphrases are deleted.

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

Verifies a signed message with a given public key.
public verifySignature ( string $text, string $address, string $signature = '', string $charset = null ) : stdClass
$text string The text to verify.
$address string E-mail address of public key.
$signature string A PGP signature block.
$charset string Charset to use.
Результат stdClass See Horde_Crypt_Pgp::decrypt().

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

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

Pgp object.
protected Horde_Crypt_Pgp $_pgp
Результат Horde_Crypt_Pgp