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

Encrypt using a symmetric cipher then authenticate using HMAC (SHA-256) More...

Public Member Functions

 __construct (SymmetricInterface $cipher)
 Constructor.
 
 setCipher (SymmetricInterface $cipher)
 Set the symmetric cipher.
 
 getCipher ()
 Get symmetric cipher.
 
 setKeyIteration ($num)
 Set the number of iterations for Pbkdf2.
 
 getKeyIteration ()
 Get the number of iterations for Pbkdf2.
 
 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.
 
 setBinaryOutput ($value)
 Enable/disable the binary output.
 
 getBinaryOutput ()
 Get the value of binary output.
 
 setKey ($key)
 Set the encryption/decryption key.
 
 getKey ()
 Get the key.
 
 setCipherAlgorithm ($algo)
 Set algorithm of the symmetric cipher.
 
 getCipherAlgorithm ()
 Get the cipher algorithm.
 
 getCipherSupportedAlgorithms ()
 Get the supported algorithms of the symmetric cipher.
 
 setHashAlgorithm ($hash)
 Set the hash algorithm for HMAC authentication.
 
 getHashAlgorithm ()
 Get the hash algorithm for HMAC authentication.
 
 setPbkdf2HashAlgorithm ($hash)
 Set the hash algorithm for the Pbkdf2.
 
 getPbkdf2HashAlgorithm ()
 Get the Pbkdf2 hash algorithm.
 
 encrypt ($data)
 Encrypt then authenticate using HMAC.
 
 decrypt ($data)
 Decrypt.
 

Static Public Member Functions

static factory ($adapter, $options=[])
 Factory.
 
static getSymmetricPluginManager ()
 Returns the symmetric cipher plugin manager.
 
static setSymmetricPluginManager ($plugins)
 Set the symmetric cipher plugin manager.
 

Protected Attributes

 $pbkdf2Hash = 'sha256'
 
 $cipher
 
 $hash = 'sha256'
 
 $saltSetted = false
 
 $binaryOutput = false
 
 $keyIteration = 5000
 
 $key
 

Static Protected Attributes

static $symmetricPlugins = null
 

Detailed Description

Encrypt using a symmetric cipher then authenticate using HMAC (SHA-256)

Constructor & Destructor Documentation

__construct ( SymmetricInterface  $cipher)

Constructor.

Parameters
SymmetricInterface$cipher

Member Function Documentation

decrypt (   $data)

Decrypt.

Parameters
string$data
Returns
string|bool
Exceptions
Exception\InvalidArgumentException
encrypt (   $data)

Encrypt then authenticate using HMAC.

Parameters
string$data
Returns
string
Exceptions
Exception\InvalidArgumentException
static factory (   $adapter,
  $options = [] 
)
static

Factory.

Parameters
string$adapter
array$options
Returns
BlockCipher
getBinaryOutput ( )

Get the value of binary output.

Returns
bool
getCipher ( )

Get symmetric cipher.

Returns
SymmetricInterface
getCipherAlgorithm ( )

Get the cipher algorithm.

Returns
string|bool
getCipherSupportedAlgorithms ( )

Get the supported algorithms of the symmetric cipher.

Returns
array
getHashAlgorithm ( )

Get the hash algorithm for HMAC authentication.

Returns
string
getKey ( )

Get the key.

Returns
string
getKeyIteration ( )

Get the number of iterations for Pbkdf2.

Returns
int
getOriginalSalt ( )

Get the original salt value.

Returns
string
getPbkdf2HashAlgorithm ( )

Get the Pbkdf2 hash algorithm.

Returns
string
getSalt ( )

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

Returns
string
static getSymmetricPluginManager ( )
static

Returns the symmetric cipher plugin manager.

If it doesn't exist it's created.

Returns
ContainerInterface
setBinaryOutput (   $value)

Enable/disable the binary output.

Parameters
bool$value
Returns
BlockCipher
setCipher ( SymmetricInterface  $cipher)

Set the symmetric cipher.

Parameters
SymmetricInterface$cipher
Returns
BlockCipher
setCipherAlgorithm (   $algo)

Set algorithm of the symmetric cipher.

Parameters
string$algo
Returns
BlockCipher
Exceptions
Exception\InvalidArgumentException
setHashAlgorithm (   $hash)

Set the hash algorithm for HMAC authentication.

Parameters
string$hash
Returns
BlockCipher
Exceptions
Exception\InvalidArgumentException
setKey (   $key)

Set the encryption/decryption key.

Parameters
string$key
Returns
BlockCipher
Exceptions
Exception\InvalidArgumentException
setKeyIteration (   $num)

Set the number of iterations for Pbkdf2.

Parameters
int$num
Returns
BlockCipher
setPbkdf2HashAlgorithm (   $hash)

Set the hash algorithm for the Pbkdf2.

Parameters
string$hash
Returns
BlockCipher
Exceptions
Exception\InvalidArgumentException
setSalt (   $salt)

Set the salt (IV)

Parameters
string$salt
Returns
BlockCipher
Exceptions
Exception\InvalidArgumentException
static setSymmetricPluginManager (   $plugins)
static

Set the symmetric cipher plugin manager.

Parameters
string | SymmetricPluginManager$plugins
Exceptions
Exception\InvalidArgumentException

Member Data Documentation

$binaryOutput = false
protected
$cipher
protected
$hash = 'sha256'
protected
$key
protected
$keyIteration = 5000
protected
$pbkdf2Hash = 'sha256'
protected
$saltSetted = false
protected
$symmetricPlugins = null
staticprotected