PHP Класс Horde_Crypt_Smime, horde

Copyright 2002-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Автор: Mike Cochrane ([email protected])
Автор: Michael Slusarz ([email protected])
Наследование: extends Horde_Crypt
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( array $params = [] ) Constructor.
certToHTML ( string $cert ) : string Convert a PEM format certificate to readable HTML version.
checkForOpenSSL ( ) Check for the presence of the OpenSSL extension to PHP.
decrypt ( string $text, array $params = [] ) : string Decrypt text via S/MIME.
encrypt ( string $text, array $params = [] ) : string Encrypt text using S/MIME.
encryptMIMEPart ( Horde_Mime_Part $mime_part, array $params = [] ) : Horde_Mime_Part Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2 compatible data (see RFC 5751 [3.3]).
extractSignedContents ( string $data, string $sslpath ) : string Extract the contents from signed S/MIME data.
getEmailFromKey ( string $key ) : mixed Extract the email address from a public key.
parseCert ( string $cert ) : array Extract the contents of a PEM format certificate to an array.
parsePKCS12Data ( string $pkcs12, array $params ) : stdClass Convert a PKCS 12 encrypted certificate package into a private key, public key, and any additional keys.
signAndEncryptMIMEPart ( Horde_Mime_Part $mime_part, array $sign_params = [], array $encrypt_params = [] ) : mixed Sign and Encrypt a MIME part using S/MIME.
signMIMEPart ( Horde_Mime_Part $mime_part, array $params ) : Horde_Mime_Part Sign a MIME part using S/MIME. This produces S/MIME Version 3.2 compatible data (see RFC 5751 [3.4]).
verify ( string $text, mixed $certs ) : stdClass Verify a signature using via S/MIME.
verifyPassphrase ( string $private_key, string $passphrase ) : boolean Verify a passphrase for a given private key.

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

Метод Описание
_createTempFile ( string $descrip = 'horde-crypt', boolean $delete = true ) : string Create a temporary file that will be deleted at the end of this process.
_decryptMessage ( string $text, array $params ) : string Decrypt an S/MIME encrypted message using a private/public keypair and a passhprase.
_decryptSignature ( string $text, array $params ) : string Decrypt an S/MIME signed message using a public key.
_encryptMessage ( string $text, array $params ) : string Encrypt a message in S/MIME format using a public key.
_encryptSignature ( string $text, array $params ) : string Sign a message in S/MIME format using a private key.
_fixContentType ( string $text, string $type ) : string The Content-Type parameters PHP's openssl_pkcs7_* functions return are deprecated. Fix these headers to the correct ones (see RFC 2311).
_implodeValues ( array | string $value, integer $indent = 4 ) : string Formats a multi-value cert field.

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

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

Constructor.
public __construct ( array $params = [] )
$params array Configuration parameters: - temp: (string) Location of temporary directory.

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

Create a temporary file that will be deleted at the end of this process.
protected _createTempFile ( string $descrip = 'horde-crypt', boolean $delete = true ) : string
$descrip string Description string to use in filename.
$delete boolean Delete the file automatically?
Результат string Filename of a temporary file.

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

Decrypt an S/MIME encrypted message using a private/public keypair and a passhprase.
protected _decryptMessage ( string $text, array $params ) : string
$text string The text to be decrypted.
$params array The parameters needed for decryption.
Parameters:
===========
'type'        =>  'message' (REQUIRED)
'pubkey'      =>  public key. (REQUIRED)
'privkey'     =>  private key. (REQUIRED)
'passphrase'  =>  Passphrase for Key. (REQUIRED)
Результат string The decrypted message.

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

Decrypt an S/MIME signed message using a public key.
protected _decryptSignature ( string $text, array $params ) : string
$text string The text to be verified.
$params array The parameters needed for verification.
Результат string The verification message.

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

Encrypt a message in S/MIME format using a public key.
protected _encryptMessage ( string $text, array $params ) : string
$text string The text to be encrypted.
$params array The parameters needed for encryption. - type: (string) [REQUIRED] 'message'. - pubkey: (mixed) [REQUIRED] Public key/cert or array of public keys/certs.
Результат string The encrypted message.

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

Sign a message in S/MIME format using a private key.
protected _encryptSignature ( string $text, array $params ) : string
$text string The text to be signed.
$params array The (string) parameters needed for signing: - 'certs': Additional signing certs (Optional) - 'passphrase': Passphrase for key (REQUIRED) - 'privkey': Private key (REQUIRED) - 'pubkey': Public key (REQUIRED) - 'sigtype': Determine the signature type to use. (Optional): - 'cleartext': Make a clear text signature - 'detach': Make a detached signature (DEFAULT) - 'type': 'signature' (REQUIRED)
Результат string The signed message.

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

The Content-Type parameters PHP's openssl_pkcs7_* functions return are deprecated. Fix these headers to the correct ones (see RFC 2311).
protected _fixContentType ( string $text, string $type ) : string
$text string The PKCS7 data.
$type string Is this 'message' or 'signature' data?
Результат string The PKCS7 data with the correct Content-Type parameter.

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

Formats a multi-value cert field.
protected _implodeValues ( array | string $value, integer $indent = 4 ) : string
$value array | string A cert field value.
$indent integer The indention level.
Результат string The formatted cert field value(s).

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

Convert a PEM format certificate to readable HTML version.
public certToHTML ( string $cert ) : string
$cert string PEM format certificate.
Результат string HTML detailing the certificate.

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

Check for the presence of the OpenSSL extension to PHP.
public checkForOpenSSL ( )

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

Decrypt text via S/MIME.
public decrypt ( string $text, array $params = [] ) : string
$text string The text to be smime decrypted.
$params array The parameters needed for decryption. See the individual _decrypt*() functions for the parameter requirements.
Результат string The decrypted message.

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

Encrypt text using S/MIME.
public encrypt ( string $text, array $params = [] ) : string
$text string The text to be encrypted.
$params array The parameters needed for encryption. See the individual _encrypt*() functions for the parameter requirements.
Результат string The encrypted message.

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

Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2 compatible data (see RFC 5751 [3.3]).
public encryptMIMEPart ( Horde_Mime_Part $mime_part, array $params = [] ) : Horde_Mime_Part
$mime_part Horde_Mime_Part The object to encrypt.
$params array The parameters required for encryption.
Результат Horde_Mime_Part An encrypted MIME part object.

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

Extract the contents from signed S/MIME data.
public extractSignedContents ( string $data, string $sslpath ) : string
$data string The signed S/MIME data.
$sslpath string The path to the OpenSSL binary.
Результат string The contents embedded in the signed data.

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

Extract the email address from a public key.
public getEmailFromKey ( string $key ) : mixed
$key string The public key.
Результат mixed Returns the first email address found, or null if there are none.

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

Extract the contents of a PEM format certificate to an array.
public parseCert ( string $cert ) : array
$cert string PEM format certificate.
Результат array All extractable information about the certificate.

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

Convert a PKCS 12 encrypted certificate package into a private key, public key, and any additional keys.
public parsePKCS12Data ( string $pkcs12, array $params ) : stdClass
$pkcs12 string The PKCS 12 data.
$params array The parameters needed for parsing.
Parameters:
===========
'sslpath' => The path to the OpenSSL binary. (REQUIRED)
'password' => The password to use to decrypt the data. (Optional)
'newpassword' => The password to use to encrypt the private key.
                 (Optional)
Результат stdClass An object. 'private' - The private key in PEM format. 'public' - The public key in PEM format. 'certs' - An array of additional certs.

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

Sign and Encrypt a MIME part using S/MIME.
public signAndEncryptMIMEPart ( Horde_Mime_Part $mime_part, array $sign_params = [], array $encrypt_params = [] ) : mixed
$mime_part Horde_Mime_Part The object to sign and encrypt.
$sign_params array The parameters required for signing. @see _encryptSignature().
$encrypt_params array The parameters required for encryption. @see _encryptMessage().
Результат mixed A Horde_Mime_Part object that is signed and encrypted.

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

Sign a MIME part using S/MIME. This produces S/MIME Version 3.2 compatible data (see RFC 5751 [3.4]).
public signMIMEPart ( Horde_Mime_Part $mime_part, array $params ) : Horde_Mime_Part
$mime_part Horde_Mime_Part The object to sign.
$params array The parameters required for signing.
Результат Horde_Mime_Part A signed MIME part object.

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

Verify a signature using via S/MIME.
public verify ( string $text, mixed $certs ) : stdClass
$text string The multipart/signed data to be verified.
$certs mixed Either a single or array of root certificates.
Результат stdClass Object with the following elements:
cert - (string) The certificate of the signer stored in the message (in
       PEM format).
email - (string) The email of the signing person.
msg - (string) Status string.
verify - (boolean) True if certificate was verified.

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

Verify a passphrase for a given private key.
public verifyPassphrase ( string $private_key, string $passphrase ) : boolean
$private_key string The user's private key.
$passphrase string The user's passphrase.
Результат boolean Returns true on valid passphrase, false on invalid passphrase.