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

Encrypt/decrypt a file using a symmetric cipher in CBC mode then authenticate using HMAC. More...

Public Member Functions

 __construct (Symmetric\SymmetricInterface $cipher=null)
 Constructor.
 
 setCipher (Symmetric\SymmetricInterface $cipher)
 Set the cipher object.
 
 getCipher ()
 Get the cipher object.
 
 setKeyIteration ($num)
 Set the number of iterations for Pbkdf2.
 
 getKeyIteration ()
 Get the number of iterations for Pbkdf2.
 
 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 ($fileIn, $fileOut)
 Encrypt then authenticate a file using HMAC.
 
 decrypt ($fileIn, $fileOut)
 Decrypt a file.
 

Public Attributes

const BUFFER_SIZE = 1048576
 

Protected Member Functions

 checkFileInOut ($fileIn, $fileOut)
 Check that input file exists and output file dont.
 

Protected Attributes

 $pbkdf2Hash = 'sha256'
 
 $hash = 'sha256'
 
 $keyIteration = 10000
 
 $key
 
 $cipher
 

Detailed Description

Encrypt/decrypt a file using a symmetric cipher in CBC mode then authenticate using HMAC.

Constructor & Destructor Documentation

__construct ( Symmetric\SymmetricInterface  $cipher = null)

Constructor.

Parameters
SymmetricInterface$cipher

Member Function Documentation

checkFileInOut (   $fileIn,
  $fileOut 
)
protected

Check that input file exists and output file dont.

Parameters
string$fileIn
string$fileOut
Exceptions
Exception\InvalidArgumentException
decrypt (   $fileIn,
  $fileOut 
)

Decrypt a file.

Parameters
string$fileIn
string$fileOut
bool$compress
Returns
bool
Exceptions
Exception\InvalidArgumentException
encrypt (   $fileIn,
  $fileOut 
)

Encrypt then authenticate a file using HMAC.

Parameters
string$fileIn
string$fileOut
Returns
bool
Exceptions
Exception\InvalidArgumentException
getCipher ( )

Get the cipher object.

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|null
getKeyIteration ( )

Get the number of iterations for Pbkdf2.

Returns
int
getPbkdf2HashAlgorithm ( )

Get the Pbkdf2 hash algorithm.

Returns
string
setCipher ( Symmetric\SymmetricInterface  $cipher)

Set the cipher object.

Parameters
SymmetricInterface$cipher
setCipherAlgorithm (   $algo)

Set algorithm of the symmetric cipher.

Parameters
string$algo
setHashAlgorithm (   $hash)

Set the hash algorithm for HMAC authentication.

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

Set the encryption/decryption key.

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

Set the number of iterations for Pbkdf2.

Parameters
int$num
setPbkdf2HashAlgorithm (   $hash)

Set the hash algorithm for the Pbkdf2.

Parameters
string$hash
Exceptions
Exception\InvalidArgumentException

Member Data Documentation

$cipher
protected
$hash = 'sha256'
protected
$key
protected
$keyIteration = 10000
protected
$pbkdf2Hash = 'sha256'
protected
const BUFFER_SIZE = 1048576