\Horde_Crypt_Pgp_Backend

Abstract backend class to implement PGP functionality.

NOTE: This class is NOT intended to be accessed outside of this package. There is NO guarantees that the API of this class will not change across versions.

Summary

Methods
Properties
Constants
supported()
generateKey()
packetInfo()
packetInfoMultiple()
getSignersKeyId()
getFingerprintsFromKey()
isEncryptedSymmetrically()
encryptMessage()
encryptSignature()
decryptMessage()
decryptSignature()
getPublicKeyFromPrivateKey()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

supported()

supported() : boolean

Is this driver supported?

Returns

boolean —

True if supported.

generateKey()

generateKey(array  $opts) : mixed

Generates a personal public/private keypair combination.

Parameters

array $opts

Configuration:

  • comment: (string) The comment to use.
  • email: (string) The email to use.
  • expire: (integer) The expiration date (UNIX timestamp). No expiration if empty.
  • keylength: (integer) The keylength to use.
  • key_type: (string) Key type.
  • name: (string) The name to use.
  • passphrase: (string) The passphrase to use.
  • subkey_type: (string) Subkey type.

Returns

mixed —

False on error; an array on success consisting of the following keys/values:

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

packetInfo()

packetInfo(string  $pgpdata) : array

Returns information on a PGP data block.

Parameters

string $pgpdata

The PGP data block.

Returns

array —

An array with information on the PGP data block. {@see Horde_Crypt_Pgp::pgpPacketInformation()}

packetInfoMultiple()

packetInfoMultiple(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. {@see Horde_Crypt_Pgp::pgpPacketInformationMultiple()}

getSignersKeyId()

getSignersKeyId(string  $text) : mixed

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

Parameters

string $text

The PGP signed text block.

Returns

mixed —

The key ID of the key used to sign $text.

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.

isEncryptedSymmetrically()

isEncryptedSymmetrically(string  $text) : boolean

Returns whether a text has been encrypted symmetrically.

Parameters

string $text

The PGP encrypted text.

Returns

boolean —

True if the text is symmetrically encrypted.

encryptMessage()

encryptMessage(string  $text, array  $params) : string

Encrypts a message in PGP format using a public key.

Parameters

string $text

The text to be encrypted.

array $params

The parameters needed for encryption.

  • passphrase: The passphrase for the symmetric encryption (REQUIRED if 'symmetric' is true)
  • recips: An array with the e-mail address of the recipient as the key and that person's public key as the value. (REQUIRED if 'symmetric' is false)
  • symmetric: Whether to use symmetric instead of asymmetric encryption (defaults to false).
  • type: [REQUIRED] 'message'

Returns

string —

The encrypted message.

encryptSignature()

encryptSignature(string  $text, array  $params) : string

Signs a message in PGP format using a private key.

Parameters

string $text

The text to be signed.

array $params

The parameters needed for signing.

  • passphrase: [REQUIRED] Passphrase for PGP Key.
  • privkey: [REQUIRED] PGP private key.
  • pubkey: [REQUIRED] PGP public key.
  • sigtype: Determine the signature type to use.
    • 'cleartext': Make a clear text signature
    • 'detach': Make a detached signature (DEFAULT)
  • type: [REQUIRED] 'signature'

Returns

string —

The signed message.

decryptMessage()

decryptMessage(string  $text, array  $params) : object

Decrypts an PGP encrypted message using a private/public keypair and a passhprase.

Parameters

string $text

The text to be decrypted.

array $params

The parameters needed for decryption.

  • no_passphrase: Passphrase is not required.
  • passphrase: Passphrase for PGP Key. (REQUIRED, see no_passphrase)
  • privkey: PGP private key. (REQUIRED for asymmetric encryption)
  • pubkey: PGP public key. (REQUIRED for asymmetric encryption)
  • type: [REQUIRED] 'message'

Returns

object —

An object with the following properties:

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

decryptSignature()

decryptSignature(string  $text, array  $params) : object

Decrypts an PGP signed message using a public key.

Parameters

string $text

The text to be verified.

array $params

The parameters needed for verification.

  • charset: Charset of the message body.
  • pubkey: [REQUIRED] PGP public key.
  • signature: PGP signature block. (REQUIRED for detached signature)
  • type: [REQUIRED] 'signature' or 'detached-signature'

Returns

object —

An object with the following properties:

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

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.