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

Public Member Functions

 getPaddingData ($blockSize, $expectedSize)
 
 getPaddingSize ($paddedData, $blockSize)
 

Detailed Description

Interface for a padding scheme.

Definition at line 8 of file PaddingInterface.php.

Member Function Documentation

fpoirotte\Cryptal\PaddingInterface::getPaddingData (   $blockSize,
  $expectedSize 
)

Return padding data to form a complete block.

Parameters
int$blockSizeThe cipher's block size, in bytes.
int$expectedSizeThe padding's expected size (in bytes) to form a (possibly new) complete block. This value is always such that: $ 0 < \$expectedSize <= \$blockSize $
Return values
stringPadding data.

Implemented in fpoirotte\Cryptal\Padding\Iso10126, fpoirotte\Cryptal\Padding\None, fpoirotte\Cryptal\Padding\NonEmptyZero, fpoirotte\Cryptal\Padding\AnsiX923, fpoirotte\Cryptal\Padding\IsoIec7816, fpoirotte\Cryptal\Padding\Pkcs7, and fpoirotte\Cryptal\Padding\Zero.

fpoirotte\Cryptal\PaddingInterface::getPaddingSize (   $paddedData,
  $blockSize 
)

Return the size (in bytes) of the padding in some already-padded data.

Parameters
string$paddedDataThe padded data to analyze.
int$blockSizeThe cipher's block size, in bytes.
Exceptions
ExceptionAn exception is thrown when the supplied data is invalid (was not padded using the currently-selected scheme).
Warning
Some padding schemes can generate ambiguous data, resulting in possible data loss while removing the padding. This method suffers from the same shortcomings. If possible, you should not rely on this method to determine the plaintext's length. Instead, you should retrieve it using other means (eg. out-of-band communications).

Implemented in fpoirotte\Cryptal\Padding\Iso10126, fpoirotte\Cryptal\Padding\None, fpoirotte\Cryptal\Padding\NonEmptyZero, fpoirotte\Cryptal\Padding\AnsiX923, fpoirotte\Cryptal\Padding\IsoIec7816, fpoirotte\Cryptal\Padding\Pkcs7, and fpoirotte\Cryptal\Padding\Zero.


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