PHP Class phpseclib\Crypt\Rijndael

Author: Jim Wigginton ([email protected])
Inheritance: extends phpseclib\Crypt\Base
Show file Open project: phpseclib/phpseclib Class Usage Examples

Public Properties

Property Type Description
$Nb integer The Block Length divided by 32
$Nk integer The Key Length divided by 32
$Nr integer The Number of Rounds
$c array Shift offsets
$cipher_name_mcrypt string Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not. \phpseclib\Crypt\Rijndael determines automatically whether mcrypt is useable or not for the current $block_size/$key_length. In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
$dw array The Inverse Key Schedule
$key_length integer The Key Length (in bytes)
$kl array Holds the last used key- and block_size information
$password_default_salt string The default salt used by setPassword()
$w array The Key Schedule

Public Methods

Method Description
__construct ( integer $mode ) Default Constructor.
_decryptBlock ( string $in ) : string Decrypts a block
_encryptBlock ( string $in ) : string Encrypts a block
_getInvTables ( ) : array Provides the inverse mixColumns and inverse sboxes tables
_getTables ( ) : array Provides the mixColumns and sboxes tables
_setupInlineCrypt ( ) Setup the performance-optimized function for de/encrypt()
_setupKey ( ) Setup the key (expansion)
_subWord ( integer $word ) Performs S-Box substitutions
isValidEngine ( integer $engine ) : boolean Test for engine validity
setBlockLength ( integer $length ) Sets the block length
setKey ( string $key ) Sets the key.
setKeyLength ( integer $length ) Sets the key length.

Method Details

__construct() public method

Default Constructor.
public __construct ( integer $mode )
$mode integer

_decryptBlock() public method

Decrypts a block
public _decryptBlock ( string $in ) : string
$in string
return string

_encryptBlock() public method

Encrypts a block
public _encryptBlock ( string $in ) : string
$in string
return string

_getInvTables() public method

Provides the inverse mixColumns and inverse sboxes tables
See also: self::_decryptBlock()
See also: self::_setupInlineCrypt()
See also: self::_setupKey()
public _getInvTables ( ) : array
return array &$tables

_getTables() public method

Provides the mixColumns and sboxes tables
See also: self::_encryptBlock()
See also: self::_setupInlineCrypt()
See also: self::_subWord()
public _getTables ( ) : array
return array &$tables

_setupInlineCrypt() public method

Setup the performance-optimized function for de/encrypt()
See also: phpseclib\Crypt\Common\SymmetricKey::_setupInlineCrypt()
public _setupInlineCrypt ( )

_setupKey() public method

Setup the key (expansion)
See also: phpseclib\Crypt\Common\SymmetricKey::_setupKey()
public _setupKey ( )

_subWord() public method

Performs S-Box substitutions
public _subWord ( integer $word )
$word integer

isValidEngine() public method

This is mainly just a wrapper to set things up for \phpseclib\Crypt\Common\SymmetricKey::isValidEngine()
See also: phpseclib\Crypt\Common\SymmetricKey::__construct()
public isValidEngine ( integer $engine ) : boolean
$engine integer
return boolean

setBlockLength() public method

Valid block lengths are 128, 160, 192, 224, and 256.
public setBlockLength ( integer $length )
$length integer

setKey() public method

Rijndael supports five different key lengths
See also: setKeyLength()
public setKey ( string $key )
$key string

setKeyLength() public method

Valid key lengths are 128, 160, 192, 224, and 256. Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to 192/256 bits as, for example, mcrypt will do. That said, if you want be compatible with other Rijndael and AES implementations, you should not setKeyLength(160) or setKeyLength(224). Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use the mcrypt php extension, even if available. This results then in slower encryption.
public setKeyLength ( integer $length )
$length integer

Property Details

$Nb public property

The Block Length divided by 32
See also: self::setBlockLength()
public int $Nb
return integer

$Nk public property

The Key Length divided by 32
See also: self::setKeyLength()
public int $Nk
return integer

$Nr public property

The Number of Rounds
public int $Nr
return integer

$c public property

Shift offsets
public array $c
return array

$cipher_name_mcrypt public property

Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not. \phpseclib\Crypt\Rijndael determines automatically whether mcrypt is useable or not for the current $block_size/$key_length. In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly.
See also: phpseclib\Crypt\Common\SymmetricKey::cipher_name_mcrypt
See also: phpseclib\Crypt\Common\SymmetricKey::engine
See also: self::isValidEngine()
public string $cipher_name_mcrypt
return string

$dw public property

The Inverse Key Schedule
See also: self::_setup()
public array $dw
return array

$key_length public property

The Key Length (in bytes)
See also: self::setKeyLength()
public int $key_length
return integer

$kl public property

Holds the last used key- and block_size information
public array $kl
return array

$password_default_salt public property

The default salt used by setPassword()
See also: phpseclib\Crypt\Common\SymmetricKey::password_default_salt
See also: phpseclib\Crypt\Common\SymmetricKey::setPassword()
public string $password_default_salt
return string

$w public property

The Key Schedule
See also: self::_setup()
public array $w
return array