[ Index ]

PHP Cross Reference of DokuWiki




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

Pure-PHP implementation of RC4. Uses mcrypt, if available, and an internal implementation, otherwise.

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

Defines 1 class

RC4:: (10 methods):

Class: RC4  - X-Ref

Pure-PHP implementation of RC4.

__construct()   X-Ref
Default Constructor.

Determines whether or not the mcrypt extension should be used.

see: \phpseclib\Crypt\Base::__construct()
return: \phpseclib\Crypt\RC4

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

This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine()

see: \phpseclib\Crypt\Base::__construct()
param: int $engine
return: bool

setIV($iv)   X-Ref
Dummy function.

Some protocols, such as WEP, prepend an "initialization vector" to the key, effectively creating a new key [1].
If you need to use an initialization vector in this manner, feel free to prepend it to the key, yourself, before
calling setKey().

[1] WEP's initialization vectors (IV's) are used in a somewhat insecure way.  Since, in that protocol,
the IV's are relatively easy to predict, an attack described by
{@link http://www.drizzle.com/~aboba/IEEE/rc4_ksaproc.pdf Scott Fluhrer, Itsik Mantin, and Adi Shamir}
can be used to quickly guess at the rest of the key.  The following links elaborate:

{@link http://www.rsa.com/rsalabs/node.asp?id=2009 http://www.rsa.com/rsalabs/node.asp?id=2009}
{@link http://en.wikipedia.org/wiki/Related_key_attack http://en.wikipedia.org/wiki/Related_key_attack}

see: self::setKey()
param: string $iv

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

Keys can be between 1 and 256 bytes long.

param: int $length

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

see: \phpseclib\Crypt\Base::decrypt()
see: self::_crypt()
param: string $plaintext
return: string $ciphertext

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

$this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)).
At least if the continuous buffer is disabled.

see: \phpseclib\Crypt\Base::encrypt()
see: self::_crypt()
param: string $ciphertext
return: string $plaintext

_encryptBlock($in)   X-Ref
Encrypts a block

param: string $in

_decryptBlock($in)   X-Ref
Decrypts a block

param: string $in

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

see: \phpseclib\Crypt\Base::_setupKey()

_crypt($text, $mode)   X-Ref
Encrypts or decrypts a message.

see: self::encrypt()
see: self::decrypt()
param: string $text
param: int $mode
return: string $text