[ Index ]

PHP Cross Reference of DokuWiki




/vendor/phpseclib/phpseclib/phpseclib/Crypt/ -> Rijndael.php (summary)

Pure-PHP implementation of Rijndael. Uses mcrypt, if available/possible, and an internal implementation, otherwise.

Author: Jim Wigginton
Copyright: 2008 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 1036 lines (44 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Rijndael:: (15 methods):

Class: Rijndael  - X-Ref

Pure-PHP implementation of Rijndael.

__construct($mode)   X-Ref
Default Constructor.

param: string $mode

setKeyLength($length)   X-Ref
Sets the key length.

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.

param: int $length

setKey($key)   X-Ref
Sets the key.

Rijndael supports five different key lengths

see: setKeyLength()
param: string $key

setBlockLength($length)   X-Ref
Sets the block length

Valid block lengths are 128, 160, 192, 224, and 256.

param: int $length

isValidEngineHelper($engine)   X-Ref
Test for engine validity

This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()

see: \phpseclib3\Crypt\Common\SymmetricKey::__construct()
param: int $engine
return: bool

encryptBlock($in)   X-Ref
Encrypts a block

param: string $in
return: string

decryptBlock($in)   X-Ref
Decrypts a block

param: string $in
return: string

setup()   X-Ref
Setup the self::ENGINE_INTERNAL $engine

(re)init, if necessary, the internal cipher $engine and flush all $buffers
Used (only) if $engine == self::ENGINE_INTERNAL

_setup() will be called each time if $changed === true
typically this happens when using one or more of following public methods:

- setKey()

- setIV()

- disableContinuousBuffer()

- First run of encrypt() / decrypt() with no init-settings

{@internal setup() is always called before en/decryption.}

{@internal Could, but not must, extend by the child Crypt_* class}

see: self::setKey()
see: self::setIV()
see: self::disableContinuousBuffer()

setupKey()   X-Ref
Setup the key (expansion)

see: \phpseclib3\Crypt\Common\SymmetricKey::setupKey()

subWord($word)   X-Ref
Performs S-Box substitutions

param: int $word
return: array

getTables()   X-Ref
Provides the mixColumns and sboxes tables

see: self::encryptBlock()
see: self::setupInlineCrypt()
see: self::subWord()
return: array &$tables

getInvTables()   X-Ref
Provides the inverse mixColumns and inverse sboxes tables

see: self::decryptBlock()
see: self::setupInlineCrypt()
see: self::setupKey()
return: array &$tables

setupInlineCrypt()   X-Ref
Setup the performance-optimized function for de/encrypt()

see: \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt()

encrypt($plaintext)   X-Ref
Encrypts a message.

see: self::decrypt()
see: parent::encrypt()
param: string $plaintext
return: string

decrypt($ciphertext)   X-Ref
Decrypts a message.

see: self::encrypt()
see: parent::decrypt()
param: string $ciphertext
return: string