[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/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: 348 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

RC4:: (10 methods):
  __construct()
  isValidEngine()
  setIV()
  setKeyLength()
  encrypt()
  decrypt()
  _encryptBlock()
  _decryptBlock()
  _setupKey()
  _crypt()


Class: RC4  - X-Ref

Pure-PHP implementation of RC4.

__construct()   X-Ref
Default Constructor.

Determines whether or not the mcrypt extension should be used.

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

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

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

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

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}

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

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.

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

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.

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

_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.

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