cryptal  latest
Cryptography Abstraction Layer
fpoirotte\Cryptal\Implementers\CryptoInterface Interface Reference
+ Inheritance diagram for fpoirotte\Cryptal\Implementers\CryptoInterface:

Public Member Functions

 __construct (CipherEnum $cipher, ModeEnum $mode, PaddingInterface $padding, $key, $tagLength=self::DEFAULT_TAG_LENGTH)
 
 decrypt ($iv, $data, $tag=null, $aad= '')
 
 encrypt ($iv, $data, &$tag=null, $aad= '')
 
 getBlockSize ()
 
 getCipher ()
 
 getIVSize ()
 
 getKey ()
 

Public Attributes

const DEFAULT_TAG_LENGTH = 16
 

Detailed Description

Interface for encryption/decryption primitives.

Definition at line 13 of file CryptoInterface.php.

Constructor & Destructor Documentation

fpoirotte\Cryptal\Implementers\CryptoInterface::__construct ( CipherEnum  $cipher,
ModeEnum  $mode,
PaddingInterface  $padding,
  $key,
  $tagLength = self::DEFAULT_TAG_LENGTH 
)

Construct a new encryption/decryption context.

Parameters
CipherEnum$cipherCipher algorithm to use.
ModeEnum$modeCryptography mode to apply to the cipher.
PaddingInterface$paddingPadding scheme to use.
string$keySecret key used for encryption/decryption.
int$tagLengthLength (in bytes) of the authentication tags to generate.
Note
The $tagLength parameter is unused unless the supplied mode supports Authenticated Encryption with Additional Data (AEAD).

Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Camellia, fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh, and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20.

Member Function Documentation

fpoirotte\Cryptal\Implementers\CryptoInterface::decrypt (   $iv,
  $data,
  $tag = null,
  $aad = '' 
)

Decrypt some data.

Parameters
string$ivInitialization Vector for the operation.
string$dataData to decrypt.
string$tagAuthentication tag.
string$aadAdditional authenticated data.
Return values
stringPlaintext (decrypted data).
Note
The $iv parameter is unused for some modes of operations (namely MODE_ECB). Still, this parameter is mandatory and an empty string may be passed for those modes.
An exception is thrown in case decryption fails, or the given authentication tag is incorrect (AEAD-only).
The $aad & $tag parameters are unused unless the required mode supports Authenticated Encryption with Additional Data (AEAD). MODE_GCM & MODE_EAX are known to support AEAD.

Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Camellia, fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20, and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh.

fpoirotte\Cryptal\Implementers\CryptoInterface::encrypt (   $iv,
  $data,
$tag = null,
  $aad = '' 
)

Encrypt some data.

Parameters
string$ivInitialization Vector for the operation.
string$dataData to encrypt.
string$tagVariable where the generated tag will be stored.
string$aadAdditional authenticated data.
Return values
stringCiphertext (encrypted data).
Note
The $iv parameter is unused for some modes of operations (namely MODE_ECB). Still, this parameter is mandatory and an empty string may be passed for those modes.
An exception is thrown in case encryption fails.
The $aad & $tag parameters are unused unless the required mode supports Authenticated Encryption with Additional Data (AEAD). MODE_GCM & MODE_EAX are known to support AEAD.

Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Camellia, fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20, and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh.

Referenced by fpoirotte\Cryptal\Modes\GCM\__construct().

fpoirotte\Cryptal\Implementers\CryptoInterface::getBlockSize ( )
fpoirotte\Cryptal\Implementers\CryptoInterface::getCipher ( )

Get the cipher used by this particular instance.

Return values
CipherEnumCipher in use by this instance.

Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Camellia, and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20.

Referenced by fpoirotte\Cryptal\Modes\EAX\__construct().

fpoirotte\Cryptal\Implementers\CryptoInterface::getIVSize ( )

Get the size of the Initialization Vector, in bytes.

Return values
intRequired size for the Initialization Vector. Might be zero in case the given cipher/mode combination does not require an initialization vector.

Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Camellia, fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20, and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20Openssh.

fpoirotte\Cryptal\Implementers\CryptoInterface::getKey ( )

Get the key used by this particular instance.

Return values
stringKey in use by this instance.

Implemented in fpoirotte\Cryptal\DefaultAlgorithms\Camellia, and fpoirotte\Cryptal\DefaultAlgorithms\ChaCha20.

Referenced by fpoirotte\Cryptal\Modes\EAX\__construct().


The documentation for this interface was generated from the following file: