Implementation of the RSA public key encryption algorithm.

category Zend
package Zend_Crypt
subpackage PublicKey

 Methods

Class constructor

__construct(\Zend\Crypt\PublicKey\RsaOptions $options) 

Decrypt with private/public key

decrypt(string $data, \Zend\Crypt\PublicKey\Rsa\AbstractKey $key, int $mode) : string

$data can be encoded in base64 or not. $mode sets how the input must be processed: - MODE_AUTO: Check if the $signature is encoded in base64. Not recommended for performance. - MODE_BASE64: Decode $data using base64 algorithm. - MODE_RAW: $data is not encoded.

see \Zend\Crypt\PublicKey\Rsa::MODE_AUTO
see \Zend\Crypt\PublicKey\Rsa::MODE_BASE64
see \Zend\Crypt\PublicKey\Rsa::MODE_RAW

Parameters

$data

string

$mode

int

Input encoding

Exceptions

\Zend\Crypt\PublicKey\Rsa\Exception\InvalidArgumentException

Returns

string

Encrypt with private/public key

encrypt(string $data, \Zend\Crypt\PublicKey\Rsa\AbstractKey $key) : string

RSA instance factory

factory(array | \Traversable $options) : \Zend\Crypt\PublicKey\Rsa

Generate new private/public key pair

generateKeys(array $opensslConfig) : \Zend\Crypt\PublicKey\Rsa

see \Zend\Crypt\PublicKey\RsaOptions::generateKeys()

Parameters

$opensslConfig

array

Exceptions

\Zend\Crypt\PublicKey\Rsa\Exception\RuntimeException

Returns

Set options

setOptions(\Zend\Crypt\PublicKey\RsaOptions $options) : \Zend\Crypt\PublicKey\Rsa

Sign with private key

sign(string $data, \Zend\Crypt\PublicKey\Rsa\PrivateKey $privateKey) : string

Parameters

$data

string

Exceptions

\Zend\Crypt\PublicKey\Rsa\Exception\RuntimeException

Returns

string

Verify signature with public key

verify(string $data, string $signature, \Zend\Crypt\PublicKey\Rsa\PublicKey $publicKey, int $mode) : bool

$signature can be encoded in base64 or not. $mode sets how the input must be processed: - MODE_AUTO: Check if the $signature is encoded in base64. Not recommended for performance. - MODE_BASE64: Decode $signature using base64 algorithm. - MODE_RAW: $signature is not encoded.

see \Zend\Crypt\PublicKey\Rsa::MODE_AUTO
see \Zend\Crypt\PublicKey\Rsa::MODE_BASE64
see \Zend\Crypt\PublicKey\Rsa::MODE_RAW

Parameters

$data

string

$signature

string

$mode

int

Input encoding

Exceptions

\Zend\Crypt\PublicKey\Rsa\Exception\RuntimeException

Returns

bool

 Properties

 

$options

$options : \Zend\Crypt\PublicKey\RsaOptions

 Constants

 

MODE_AUTO

MODE_AUTO 

 

MODE_BASE64

MODE_BASE64 

 

MODE_RAW

MODE_RAW