\Horde_Pgp_Backend_Openpgp

PGP backend that uses the openpgp-php library.

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()
encrypt()
encryptSymmetric()
sign()
decrypt()
decryptSymmetric()
verify()
autoload()
__construct()
No public properties found
No constants found
_generateSecretKeyPacket()
_encryptPrivateKey()
_encrypt()
_getMessageOb()
_compressMessageOb()
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) : \Horde_Pgp_Key_Private

Generates a private key.

Parameters

array $opts

Configuration:

  • comment: (string) The comment to use.
  • email: (string) The email to use.
  • expire: (integer) Expiration date (UNIX timestamp).
  • hash: (string) Hash function (DEFAULT: SHA256).
  • keylength: (integer) The keylength to use.
  • name: (string) The name to use.
  • passphrase: (string) The passphrase to use.

Returns

\Horde_Pgp_Key_Private —

The generated private key.

encrypt()

encrypt(string  $text, array  $keys, array  $opts) : \Horde_Pgp_Element_Message

Encrypts text using PGP public keys.

Parameters

string $text

The text to be PGP encrypted.

array $keys

The list of public keys to encrypt (Horde_Pgp_Element_PublicKey objects).

array $opts

Additional options:

  • cipher: (integer) Symmetric cipher algorithm.
  • compress: (boolean) Compression algorithm.

Returns

\Horde_Pgp_Element_Message

The encrypted message.

encryptSymmetric()

encryptSymmetric(string  $text, array  $passphrase, array  $opts) : \Horde_Pgp_Element_Message

Encrypts text using a PGP symmetric passphrase.

Parameters

string $text

The text to be PGP encrypted.

array $passphrase

The symmetric passphrase(s).

array $opts

Additional options:

  • cipher: (integer) Symmetric cipher algorithm.
  • compress: (boolean) Compression algorithm.

Returns

\Horde_Pgp_Element_Message

The encrypted message.

sign()

sign(string  $text, \Horde_Pgp_Element_PrivateKey  $key, integer  $mode, array  $opts = array()) : mixed

Sign a message using a PGP private key.

Parameters

string $text

The text to be PGP signed.

\Horde_Pgp_Element_PrivateKey $key

The private key to use for signing.

integer $mode

The signing mode. Either 'clear', 'detach', or 'message'.

array $opts

Additional options:

  • compress: (boolean) Compression algorithm.
  • sign_hash: (string) The hash method to use.

Returns

mixed —

The signed message.

decryptSymmetric()

decryptSymmetric(\Horde_Pgp_Element_Message  $msg, string  $passphrase) : \Horde_Pgp_Element_Message

Decrypts text using a PGP symmetric passphrase.

Parameters

\Horde_Pgp_Element_Message $msg

The message to be decrypted.

string $passphrase

The symmetric passphrase used to encrypt the data.

Returns

\Horde_Pgp_Element_Message

The decrypted message.

verify()

verify(\Horde_Pgp_Element  $msg, \Horde_Pgp_Element_PublicKey  $key) : array

Verifies data using a PGP public key.

Parameters

\Horde_Pgp_Element $msg

The text to be verified.

\Horde_Pgp_Element_PublicKey $key

Public key used for signing.

Returns

array —

{@see Horde_Pgp#verify()}.

autoload()

autoload() 

Autoload necessary libraries.

__construct()

__construct() 

Constructor.

_generateSecretKeyPacket()

_generateSecretKeyPacket(integer  $keylength, string  $packet_type) : \OpenPGP_SecretKeyPacket

Generate a RSA secret key (sub)packet.

Parameters

integer $keylength

RSA keylength.

string $packet_type

Secret key packet to create.

Returns

\OpenPGP_SecretKeyPacket —

Secret key packet object.

_encryptPrivateKey()

_encryptPrivateKey(\OpenPGP_SecretKeyPacket  $p, \phpseclib\Crypt\RSA  $cipher, \OpenPGP_S2K  $s2k, string  $iv) 

Encrypt a secret key packet.

Parameters

\OpenPGP_SecretKeyPacket $p

Secret key packet.

\phpseclib\Crypt\RSA $cipher

RSA cipher object.

\OpenPGP_S2K $s2k

OpenPGP String-to-key object.

string $iv

Initial vector.

_encrypt()

_encrypt(mixed  $key, mixed  $data, array  $opts) 

Encrypt data.

Parameters

mixed $key

The list of public keys used to encrypt or a list of passphrases.

mixed $data

The data to be PGP encrypted.

array $opts

Additional options:

  • cipher: (integer) Cipher algorithm.
  • compress: (integer) Compression algorithm.

_getMessageOb()

_getMessageOb(mixed  $data) : \OpenPGP_Message

Create a OpenPGP message object, inserting text data into a literal data packet.

Parameters

mixed $data

Data.

Returns

\OpenPGP_Message —

Message object.

_compressMessageOb()

_compressMessageOb(\OpenPGP_Message  $msg, integer  $algo) : \OpenPGP_Message

Compress PGP data, if compression is available.

Parameters

\OpenPGP_Message $msg

PGP message.

integer $algo

Compression algorithm.

Returns

\OpenPGP_Message —

(Possibly compressed) message.