PHP 클래스 IMP_Pgp, horde

저자: Michael Slusarz ([email protected])
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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