Documentation

IMP_Smime
in package

Contains code related to handling S/MIME messages within IMP.

Tags
author

Mike Cochrane mike@graftonhall.co.nz

author

Jan Schneider jan@horde.org

category

Horde

copyright

2002-2017 Horde LLC

license

http://www.horde.org/licenses/gpl GPL

Table of Contents

Constants

ENCRYPT  = 'smime_encrypt'
KEY_PRIMARY  = 0
KEY_SECONDARY  = 1
KEY_SECONDARY_OR_PRIMARY  = 2
PUBKEY_FIELD  = 'smimePublicKey'
SIGN  = 'smime_sign'
SIGNENC  = 'smime_signenc'

Properties

$_smime  : Horde_Crypt_Smime
S/MIME object.

Methods

__construct()  : mixed
Constructor.
addAdditionalCert()  : mixed
Adds a list of additional certs to the prefs.
addFromPKCS12()  : mixed
Stores the public/private/additional certificates in the preferences from a given PKCS 12 file.
addPersonalPrivateKey()  : mixed
Adds the personal private key to the prefs.
addPersonalPublicKey()  : mixed
Adds the personal public key to the prefs.
addPublicKey()  : mixed
Adds a public key to an address book.
certToHTML()  : string
Converts a PEM format certificate to readable HTML version.
checkForOpenSsl()  : mixed
Checks for the presence of the OpenSSL extension to PHP.
decryptMessage()  : string
Decrypts a message with user's public/private keypair.
deletePersonalKeys()  : mixed
Deletes the specified personal keys from the prefs.
deletePublicKey()  : mixed
Deletes a public key from a user's address book(s) by e-mail.
enabled()  : bool
Return whether PGP support is current enabled in IMP.
encryptList()  : array<string|int, mixed>
Returns the list of available encryption options for composing.
encryptMimePart()  : Horde_Mime_Part
Encrypts a MIME part using S/MIME using IMP defaults.
extractSignedContents()  : string
Extracts the contents from signed S/MIME data.
getAdditionalCert()  : string
Returns any additional certificates from the prefs.
getPassphrase()  : mixed
Returns the user's passphrase from the session cache.
getPersonalPrivateKey()  : string
Returns the personal private key from the prefs.
getPersonalPublicKey()  : string
Returns the personal public key from the prefs.
getPublicKey()  : string
Retrieves a public key by e-mail.
listPublicKeys()  : array<string|int, mixed>
Retrieves all public keys from a user's address book(s).
parseCert()  : array<string|int, mixed>
Extracts the contents of a PEM format certificate to an array.
publicKeyInfo()  : array<string|int, mixed>
Returns information about a public certificate.
signAndEncryptMimePart()  : Horde_Mime_Part
Signs and encrypts a MIME part using S/MIME using IMP defaults.
signMimePart()  : Horde_Mime_Part
Signs a MIME part using S/MIME using IMP defaults.
storePassphrase()  : bool
Stores the user's passphrase in the session cache.
unsetPassphrase()  : mixed
Clears the passphrase from the session cache.
verifySignature()  : stdClass
Verifies a signed message with a given public key.
_encryptParameters()  : array<string|int, mixed>
Returns the params needed to encrypt a message being sent to the specified email address(es).
_signParameters()  : array<string|int, mixed>
Returns the parameters needed for signing a message.

Constants

ENCRYPT

public mixed ENCRYPT = 'smime_encrypt'

KEY_PRIMARY

public mixed KEY_PRIMARY = 0

KEY_SECONDARY

public mixed KEY_SECONDARY = 1

KEY_SECONDARY_OR_PRIMARY

public mixed KEY_SECONDARY_OR_PRIMARY = 2

PUBKEY_FIELD

public mixed PUBKEY_FIELD = 'smimePublicKey'

SIGN

public mixed SIGN = 'smime_sign'

SIGNENC

public mixed SIGNENC = 'smime_signenc'

Properties

$_smime

S/MIME object.

protected Horde_Crypt_Smime $_smime

Methods

__construct()

Constructor.

public __construct(Horde_Crypt_Smime $smime) : mixed
Parameters
$smime : Horde_Crypt_Smime

addAdditionalCert()

Adds a list of additional certs to the prefs.

public addAdditionalCert(string|array<string|int, mixed> $key[, bool $signkey = false ]) : mixed
Parameters
$key : string|array<string|int, mixed>

The additional certifcate(s) to add.

$signkey : bool = false

Is this the secondary key for signing?

addFromPKCS12()

Stores the public/private/additional certificates in the preferences from a given PKCS 12 file.

public addFromPKCS12(string $pkcs12, string $password[, string $pkpass = null ][, bool $signkey = false ]) : mixed
Parameters
$pkcs12 : string

The PKCS 12 data.

$password : string

The password of the PKCS 12 file.

$pkpass : string = null

The password to use to encrypt the private key.

$signkey : bool = false

Is this the secondary key for signing?

Tags
throws
Horde_Crypt_Exception

addPersonalPrivateKey()

Adds the personal private key to the prefs.

public addPersonalPrivateKey(string|array<string|int, mixed> $key[, bool $signkey = false ]) : mixed
Parameters
$key : string|array<string|int, mixed>

The private key to add.

$signkey : bool = false

Is this the secondary key for signing?

addPersonalPublicKey()

Adds the personal public key to the prefs.

public addPersonalPublicKey(string|array<string|int, mixed> $key[, bool $signkey = false ]) : mixed
Parameters
$key : string|array<string|int, mixed>

The public key to add.

$signkey : bool = false

Is this the secondary key for signing?

addPublicKey()

Adds a public key to an address book.

public addPublicKey(string $cert) : mixed
Parameters
$cert : string

A public certificate to add.

Tags
throws
Horde_Exception

certToHTML()

Converts a PEM format certificate to readable HTML version.

public certToHTML(string $cert) : string
Parameters
$cert : string

PEM format certificate.

Return values
string

HTML detailing the certificate.

checkForOpenSsl()

Checks for the presence of the OpenSSL extension to PHP.

public checkForOpenSsl() : mixed
Tags
throws
Horde_Crypt_Exception

decryptMessage()

Decrypts a message with user's public/private keypair.

public decryptMessage(string $text) : string
Parameters
$text : string

The text to decrypt.

Tags
throws
Horde_Crypt_Exception
Return values
string

See Horde_Crypt_Smime::decrypt().

deletePersonalKeys()

Deletes the specified personal keys from the prefs.

public deletePersonalKeys([bool $signkey = false ]) : mixed
Parameters
$signkey : bool = false

Return the secondary key for signing?

deletePublicKey()

Deletes a public key from a user's address book(s) by e-mail.

public deletePublicKey(string $email) : mixed
Parameters
$email : string

The e-mail address to delete.

Tags
throws
Horde_Crypt_Exception

enabled()

Return whether PGP support is current enabled in IMP.

public static enabled() : bool
Return values
bool

True if PGP support is enabled.

encryptList()

Returns the list of available encryption options for composing.

public encryptList() : array<string|int, mixed>
Return values
array<string|int, mixed>

Keys are encryption type constants, values are gettext strings describing the encryption type.

encryptMimePart()

Encrypts a MIME part using S/MIME using IMP defaults.

public encryptMimePart(Horde_Mime_Part $mime_part, Horde_Mail_Rfc822_List $recip) : Horde_Mime_Part
Parameters
$mime_part : Horde_Mime_Part

The object to encrypt.

$recip : Horde_Mail_Rfc822_List

The recipient address(es).

Tags
throws
Horde_Crypt_Exception
Return values
Horde_Mime_Part

See Horde_Crypt_Smime::encryptMIMEPart().

extractSignedContents()

Extracts the contents from signed S/MIME data.

public extractSignedContents(string $data) : string
Parameters
$data : string

The signed S/MIME data.

Tags
throws
Horde_Crypt_Exception
Return values
string

The contents embedded in the signed data.

getAdditionalCert()

Returns any additional certificates from the prefs.

public getAdditionalCert([int $signkey = self::KEY_PRIMARY ]) : string
Parameters
$signkey : int = self::KEY_PRIMARY

One of the IMP_Sime::KEY_* constants.

Return values
string

Additional signing certs for inclusion.

getPassphrase()

Returns the user's passphrase from the session cache.

public getPassphrase([int $signkey = self::KEY_PRIMARY ]) : mixed
Parameters
$signkey : int = self::KEY_PRIMARY

One of the IMP_Sime::KEY_* constants.

Return values
mixed

The passphrase, if set. Returns false if the passphrase has not been loaded yet. Returns null if no passphrase is needed.

getPersonalPrivateKey()

Returns the personal private key from the prefs.

public getPersonalPrivateKey([int $signkey = self::KEY_PRIMARY ]) : string
Parameters
$signkey : int = self::KEY_PRIMARY

One of the IMP_Sime::KEY_* constants.

Return values
string

The personal S/MIME private key.

getPersonalPublicKey()

Returns the personal public key from the prefs.

public getPersonalPublicKey([int $signkey = self::KEY_PRIMARY ]) : string
Parameters
$signkey : int = self::KEY_PRIMARY

One of the IMP_Sime::KEY_* constants.

Return values
string

The personal S/MIME public key.

getPublicKey()

Retrieves a public key by e-mail.

public getPublicKey(string $address) : string

The key will be retrieved from a user's address book(s).

Parameters
$address : string

The e-mail address to search for.

Tags
throws
Horde_Exception
Return values
string

The S/MIME public key requested.

listPublicKeys()

Retrieves all public keys from a user's address book(s).

public listPublicKeys() : array<string|int, mixed>
Tags
throws
Horde_Crypt_Exception
Return values
array<string|int, mixed>

All S/MIME public keys available.

parseCert()

Extracts the contents of a PEM format certificate to an array.

public parseCert(string $cert) : array<string|int, mixed>
Parameters
$cert : string

PEM format certificate.

Return values
array<string|int, mixed>

All extractable information about the certificate.

publicKeyInfo()

Returns information about a public certificate.

public publicKeyInfo(string $cert) : array<string|int, mixed>
Parameters
$cert : string

The public certificate.

Tags
throws
Horde_Crypt_Exception
Return values
array<string|int, mixed>

Two element array: the name and e-mail for the cert.

signAndEncryptMimePart()

Signs and encrypts a MIME part using S/MIME using IMP defaults.

public signAndEncryptMimePart(Horde_Mime_Part $mime_part, Horde_Mail_Rfc822_List $recip) : Horde_Mime_Part
Parameters
$mime_part : Horde_Mime_Part

The object to sign and encrypt.

$recip : Horde_Mail_Rfc822_List

The recipient address(es).

Tags
throws
Horde_Crypt_Exception
Return values
Horde_Mime_Part

See Horde_Crypt_Smime::signAndencryptMIMEPart().

signMimePart()

Signs a MIME part using S/MIME using IMP defaults.

public signMimePart(MIME_Part $mime_part) : Horde_Mime_Part
Parameters
$mime_part : MIME_Part

The MIME_Part object to sign.

Tags
throws
Horde_Crypt_Exception
Return values
Horde_Mime_Part

See Horde_Crypt_Smime::signMIMEPart().

storePassphrase()

Stores the user's passphrase in the session cache.

public storePassphrase(string $passphrase[, int $signkey = self::KEY_PRIMARY ]) : bool
Parameters
$passphrase : string

The user's passphrase.

$signkey : int = self::KEY_PRIMARY

One of the IMP_Sime::KEY_* constants.

Return values
bool

Returns true if correct passphrase, false if incorrect.

unsetPassphrase()

Clears the passphrase from the session cache.

public unsetPassphrase([bool $signkey = false ]) : mixed
Parameters
$signkey : bool = false

Is this the secondary key for signing?

verifySignature()

Verifies a signed message with a given public key.

public verifySignature(string $text) : stdClass
Parameters
$text : string

The text to verify.

Tags
throws
Horde_Crypt_Exception
Return values
stdClass

See Horde_Crypt_Smime::verify().

_encryptParameters()

Returns the params needed to encrypt a message being sent to the specified email address(es).

protected _encryptParameters(Horde_Mail_Rfc822_List $addr) : array<string|int, mixed>
Parameters
$addr : Horde_Mail_Rfc822_List

The recipient addresses.

Tags
throws
Horde_Crypt_Exception
Return values
array<string|int, mixed>

The list of parameters needed by encrypt().

_signParameters()

Returns the parameters needed for signing a message.

protected _signParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

The list of parameters needed by encrypt().


        
On this page

Search results