Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Openssl Class Reference

Symmetric encryption using the OpenSSL extension. More...

Public Member Functions

 __construct ($options=[])
 Constructor.
 
 setOptions ($options)
 Set default options.
 
 getKeySize ()
 Get the key size for the selected cipher.
 
 setKey ($key)
 Set the encryption key If the key is longer than maximum supported, it will be truncated by getKey().
 
 getKey ()
 Get the encryption key.
 
 setAlgorithm ($algo)
 Set the encryption algorithm (cipher)
 
 getAlgorithm ()
 Get the encryption algorithm.
 
 setPadding (Padding\PaddingInterface $padding)
 Set the padding object.
 
 getPadding ()
 Get the padding object.
 
 encrypt ($data)
 Encrypt.
 
 decrypt ($data)
 Decrypt.
 
 getSaltSize ()
 Get the salt (IV) size.
 
 getSupportedAlgorithms ()
 Get the supported algorithms.
 
 setSalt ($salt)
 Set the salt (IV)
 
 getSalt ()
 Get the salt (IV) according to the size requested by the algorithm.
 
 getOriginalSalt ()
 Get the original salt value.
 
 setMode ($mode)
 Set the cipher mode.
 
 getMode ()
 Get the cipher mode.
 
 getSupportedModes ()
 Get all supported encryption modes for the selected algorithm.
 
 getBlockSize ()
 Get the block size.
 

Static Public Member Functions

static getPaddingPluginManager ()
 Returns the padding plugin manager.
 
static setPaddingPluginManager ($plugins)
 Set the padding plugin manager.
 

Public Attributes

const DEFAULT_PADDING = 'pkcs7'
 

Protected Member Functions

 setDefaultOptions ($options=[])
 Set default options.
 
 getOpensslAlgos ()
 Return the OpenSSL supported encryption algorithms.
 

Protected Attributes

 $key
 
 $iv
 
 $algo = 'aes'
 
 $mode = 'cbc'
 
 $padding
 
 $encryptionAlgos
 
 $encryptionModes
 
 $blockSizes
 
 $keySizes
 
 $opensslAlgos = []
 
 $supportedAlgos = []
 

Static Protected Attributes

static $paddingPlugins = null
 

Detailed Description

Symmetric encryption using the OpenSSL extension.

NOTE: DO NOT USE only this class to encrypt data. This class doesn't provide authentication and integrity check over the data. PLEASE USE Zend instead!

Constructor & Destructor Documentation

__construct (   $options = [])

Constructor.

Parameters
array | Traversable$options
Exceptions
Exception\RuntimeException
Exception\InvalidArgumentException

Member Function Documentation

decrypt (   $data)

Decrypt.

Parameters
string$data
Exceptions
Exception\InvalidArgumentException
Returns
string

Implements SymmetricInterface.

encrypt (   $data)

Encrypt.

Parameters
string$data
Exceptions
Exception\InvalidArgumentException
Returns
string

Implements SymmetricInterface.

getAlgorithm ( )

Get the encryption algorithm.

Returns
string

Implements SymmetricInterface.

getBlockSize ( )

Get the block size.

Returns
int

Implements SymmetricInterface.

getKey ( )

Get the encryption key.

Returns
string

Implements SymmetricInterface.

getKeySize ( )

Get the key size for the selected cipher.

Returns
int

Implements SymmetricInterface.

getMode ( )

Get the cipher mode.

Returns
string

Implements SymmetricInterface.

getOpensslAlgos ( )
protected

Return the OpenSSL supported encryption algorithms.

Returns
array
getOriginalSalt ( )

Get the original salt value.

Returns
string
getPadding ( )

Get the padding object.

Returns
Padding
static getPaddingPluginManager ( )
static

Returns the padding plugin manager.

Creates one if none is present.

Returns
ContainerInterface
getSalt ( )

Get the salt (IV) according to the size requested by the algorithm.

Returns
string

Implements SymmetricInterface.

getSaltSize ( )

Get the salt (IV) size.

Returns
int

Implements SymmetricInterface.

getSupportedAlgorithms ( )

Get the supported algorithms.

Returns
array

Implements SymmetricInterface.

getSupportedModes ( )

Get all supported encryption modes for the selected algorithm.

Returns
array

Implements SymmetricInterface.

setAlgorithm (   $algo)

Set the encryption algorithm (cipher)

Parameters
string$algo
Exceptions
Exception\InvalidArgumentException
Returns
self

Implements SymmetricInterface.

setDefaultOptions (   $options = [])
protected

Set default options.

Parameters
array$options
Returns
void
setKey (   $key)

Set the encryption key If the key is longer than maximum supported, it will be truncated by getKey().

Parameters
string$key
Exceptions
Exception\InvalidArgumentException
Returns
self

Implements SymmetricInterface.

setMode (   $mode)

Set the cipher mode.

Parameters
string$mode
Exceptions
Exception\InvalidArgumentException
Returns
self

Implements SymmetricInterface.

setOptions (   $options)

Set default options.

Parameters
array$options
Returns
void

Implements SymmetricInterface.

setPadding ( Padding\PaddingInterface  $padding)

Set the padding object.

Parameters
Padding\PaddingInterface$padding
Returns
self
static setPaddingPluginManager (   $plugins)
static

Set the padding plugin manager.

Parameters
string | ContainerInterface$plugins
Exceptions
Exception\InvalidArgumentException
Returns
void
setSalt (   $salt)

Set the salt (IV)

Parameters
string$salt
Exceptions
Exception\InvalidArgumentException
Returns
self

Implements SymmetricInterface.

Member Data Documentation

$algo = 'aes'
protected
$blockSizes
protected
Initial value:
= [
'aes' => 16
$encryptionAlgos
protected
Initial value:
= [
'aes' => 'AES-256'
$encryptionModes
protected
Initial value:
= [
'cbc',
'cfb',
'ofb',
'ecb',
]
$iv
protected
$key
protected
$keySizes
protected
Initial value:
= [
'aes' => 32
$mode = 'cbc'
protected
$opensslAlgos = []
protected
$padding
protected
$paddingPlugins = null
staticprotected
$supportedAlgos = []
protected
const DEFAULT_PADDING = 'pkcs7'