Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Crypt_RC4

Class Crypt_RC4

Pure-PHP implementation of RC4.

Package: Crypt\RC4
Copyright: MMVII Jim Wigginton
License: MIT License
Author: Jim Wigginton <terrafrost@php.net>
Version: 0.1.0
Located at vendors/phpseclib/Crypt/RC4.php

Methods summary

public Crypt_RC4
# Crypt_RC4( )

Default Constructor.

Default Constructor.

Determines whether or not the mcrypt extension should be used.

Returns

Crypt_RC4
public
# setKey( String $key )

Sets the key.

Sets the key.

Keys can be between 1 and 256 bytes long. If they are longer then 256 bytes, the first 256 bytes will be used. If no key is explicitly set, it'll be assumed to be a single null byte.

Parameters

$key
String
$key
public
# setPassword( String $password, optional $method = 'pbkdf2' )

Sets the password.

Sets the password.

Depending on what $method is set to, setPassword()'s (optional) parameters are as follows: pbkdf2: $hash, $salt, $count, $dkLen

Parameters

$password
String
$password
$method
optional
String $method
public
# setIV( String $iv )

Dummy function.

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 Scott Fluhrer, Itsik Mantin, and Adi Shamir can be used to quickly guess at the rest of the key. The following links elaborate:

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

Parameters

$iv
String
$iv

See

Crypt_RC4::setKey()
public
# encrypt( String $plaintext )

Encrypts a message.

Encrypts a message.

Parameters

$plaintext
String
$plaintext

See

Crypt_RC4::_crypt()
public
# decrypt( String $ciphertext )

Decrypts a message.

Decrypts a message.

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

Parameters

$ciphertext
String
$ciphertext

See

Crypt_RC4::_crypt()
public
# _crypt( String $text, Integer $mode )

Encrypts or decrypts a message.

Encrypts or decrypts a message.

Parameters

$text
String
$text
$mode
Integer
$mode

See

Crypt_RC4::encrypt()
Crypt_RC4::decrypt()
public
# enableContinuousBuffer( )

Treat consecutive "packets" as if they are a continuous buffer.

Treat consecutive "packets" as if they are a continuous buffer.

Say you have a 16-byte plaintext $plaintext. Using the default behavior, the two following code snippets will yield different outputs:

echo $rc4->encrypt(substr($plaintext, 0, 8));
echo $rc4->encrypt(substr($plaintext, 8, 8));
echo $rc4->encrypt($plaintext);

The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates another, as demonstrated with the following:

$rc4->encrypt(substr($plaintext, 0, 8));
echo $rc4->decrypt($des->encrypt(substr($plaintext, 8, 8)));
echo $rc4->decrypt($des->encrypt(substr($plaintext, 8, 8)));

With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different outputs. The reason is due to the fact that the initialization vector's change after every encryption / decryption round when the continuous buffer is enabled. When it's disabled, they remain constant.

Put another way, when the continuous buffer is enabled, the state of the Crypt_DES() object changes after each encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them), however, they are also less intuitive and more likely to cause you problems.

See

Crypt_RC4::disableContinuousBuffer()
public
# disableContinuousBuffer( )

Treat consecutive packets as if they are a discontinuous buffer.

Treat consecutive packets as if they are a discontinuous buffer.

The default behavior.

See

Crypt_RC4::enableContinuousBuffer()
public
# enablePadding( )

Dummy function.

Dummy function.

Since RC4 is a stream cipher and not a block cipher, no padding is necessary. The only reason this function is included is so that you can switch between a block cipher and a stream cipher transparently.

See

Crypt_RC4::disablePadding()
public
# disablePadding( )

Dummy function.

Dummy function.

See

Crypt_RC4::enablePadding()
public
# __destruct( )

Class destructor.

Class destructor.

Will be called, automatically, if you're using PHP5. If you're using PHP4, call it yourself. Only really needs to be called if mcrypt is being used.

public
# _closeMCrypt( )

Properly close the MCrypt objects.

Properly close the MCrypt objects.

Magic methods summary

Properties summary

public String $key
#

The Key

The Key

See

Crypt_RC4::setKey()
public Array $encryptStream
#

The Key Stream for encryption

The Key Stream for encryption

If CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT, this will be equal to the mcrypt object

See

Crypt_RC4::setKey()
public Array $decryptStream
#

The Key Stream for decryption

The Key Stream for decryption

If CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT, this will be equal to the mcrypt object

See

Crypt_RC4::setKey()
public Integer $encryptIndex
#

The $i and $j indexes for encryption

The $i and $j indexes for encryption

See

Crypt_RC4::_crypt()
public Integer $decryptIndex
#

The $i and $j indexes for decryption

The $i and $j indexes for decryption

See

Crypt_RC4::_crypt()
public Integer $mode
#

The Encryption Algorithm

The Encryption Algorithm

Only used if CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT. Only possible values are MCRYPT_RC4 or MCRYPT_ARCFOUR.

See

Crypt_RC4::Crypt_RC4()
public Boolean $continuousBuffer
#

Continuous Buffer status

Continuous Buffer status

See

Crypt_RC4::enableContinuousBuffer()
Blesta API documentation generated by ApiGen 2.8.0