Base
in package
Base Class for all \phpseclib\Crypt\* cipher classes
Tags
Table of Contents
- ENGINE_INTERNAL = 1
- Base value for the internal implementation $engine switch
- ENGINE_MCRYPT = 2
- Base value for the mcrypt implementation $engine switch
- ENGINE_OPENSSL = 3
- Base value for the mcrypt implementation $engine switch
- MODE_CBC = 2
- Encrypt / decrypt using the Code Book Chaining mode.
- MODE_CFB = 3
- Encrypt / decrypt using the Cipher Feedback mode.
- MODE_CFB8 = 38
- Encrypt / decrypt using the Cipher Feedback mode (8bit)
- MODE_CTR = -1
- Encrypt / decrypt using the Counter mode.
- MODE_ECB = 1
- Encrypt / decrypt using the Electronic Code Book mode.
- MODE_OFB = 4
- Encrypt / decrypt using the Output Feedback mode.
- MODE_STREAM = 5
- Encrypt / decrypt using streaming mode.
- $block_size : int
- The Block Length of the block cipher
- $cfb_init_len : int
- Optimizing value while CFB-encrypting
- $changed : bool
- Does internal cipher state need to be (re)initialized?
- $cipher_name_mcrypt : string
- The mcrypt specific name of the cipher
- $cipher_name_openssl : string
- The openssl specific name of the cipher
- $cipher_name_openssl_ecb : string
- The openssl specific name of the cipher in ECB mode
- $continuousBuffer : bool
- Continuous Buffer status
- $debuffer : array<string|int, mixed>
- Decryption buffer for CTR, OFB and CFB modes
- $dechanged : bool
- Does the demcrypt resource need to be (re)initialized?
- $decryptIV : string
- A "sliding" Initialization Vector
- $demcrypt : resource
- mcrypt resource for decryption
- $ecb : resource
- mcrypt resource for CFB mode
- $enbuffer : array<string|int, mixed>
- Encryption buffer for CTR, OFB and CFB modes
- $enchanged : bool
- Does the enmcrypt resource need to be (re)initialized?
- $encryptIV : string
- A "sliding" Initialization Vector
- $engine : int
- Holds which crypt engine internaly should be use, which will be determined automatically on __construct()
- $enmcrypt : resource
- mcrypt resource for encryption
- $explicit_key_length : bool
- Has the key length explicitly been set or should it be derived from the key, itself?
- $inline_crypt : callable
- The name of the performance-optimized callback function
- $iv : string
- The Initialization Vector
- $key : string
- The Key
- $mode : int
- The Encryption Mode
- $openssl_emulate_ctr : bool
- If OpenSSL can be used in ECB but not in CTR we can emulate CTR
- $openssl_options : mixed
- Determines what options are passed to openssl_encrypt/decrypt
- $paddable : bool
- Is the mode one that is paddable?
- $padding : bool
- Padding status
- $password_default_salt : string
- The default salt used by setPassword()
- $preferredEngine : int
- Holds the preferred crypt engine
- $skip_key_adjustment : bool
- Don't truncate / null pad key
- $use_inline_crypt : mixed
- Holds whether performance-optimized $inline_crypt() can/should be used.
- $WHIRLPOOL_AVAILABLE : bool
- Whirlpool available flag
- __construct() : mixed
- Default Constructor.
- _createInlineCryptFunction() : string
- Creates the performance-optimized function for en/decrypt()
- _decryptBlock() : string
- Decrypts a block
- _encryptBlock() : string
- Encrypts a block
- _getLambdaFunctions() : array<string|int, mixed>
- Holds the lambda_functions table (classwide)
- _hashInlineCryptFunction() : string
- Generates a digest from $bytes
- _increment_str() : mixed
- Increment the current string
- _openssl_ctr_process() : string
- OpenSSL CTR Processor
- _openssl_ofb_process() : string
- OpenSSL OFB Processor
- _openssl_translate_mode() : int
- phpseclib <-> OpenSSL Mode Mapper
- _pad() : string
- Pads a string
- _setEngine() : mixed
- Sets the engine as appropriate
- _setupKey() : mixed
- Setup the key (expansion)
- _string_pop() : string
- String Pop
- _string_shift() : string
- String Shift
- _unpad() : string
- Unpads a string.
- disablePadding() : mixed
- Do not pad packets.
- enablePadding() : mixed
- Pad "packets".
- getBlockLength() : int
- Returns the current block length in bits
- getEngine() : mixed
- Returns the engine currently being utilized
- getKeyLength() : int
- Returns the current key length in bits
- isValidEngine() : bool
- Test for engine validity
- safe_intval() : int
- Convert float to int
- safe_intval_inline() : string
- eval()'able string for in-line float to int
- setKeyLength() : mixed
- Sets the key length.
- setPreferredEngine() : mixed
- Sets the preferred crypt engine
Constants
ENGINE_INTERNAL
Base value for the internal implementation $engine switch
public
mixed
ENGINE_INTERNAL
= 1
ENGINE_MCRYPT
Base value for the mcrypt implementation $engine switch
public
mixed
ENGINE_MCRYPT
= 2
ENGINE_OPENSSL
Base value for the mcrypt implementation $engine switch
public
mixed
ENGINE_OPENSSL
= 3
MODE_CBC
Encrypt / decrypt using the Code Book Chaining mode.
public
mixed
MODE_CBC
= 2
Tags
MODE_CFB
Encrypt / decrypt using the Cipher Feedback mode.
public
mixed
MODE_CFB
= 3
Tags
MODE_CFB8
Encrypt / decrypt using the Cipher Feedback mode (8bit)
public
mixed
MODE_CFB8
= 38
MODE_CTR
Encrypt / decrypt using the Counter mode.
public
mixed
MODE_CTR
= -1
Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
Tags
MODE_ECB
Encrypt / decrypt using the Electronic Code Book mode.
public
mixed
MODE_ECB
= 1
Tags
MODE_OFB
Encrypt / decrypt using the Output Feedback mode.
public
mixed
MODE_OFB
= 4
Tags
MODE_STREAM
Encrypt / decrypt using streaming mode.
public
mixed
MODE_STREAM
= 5
Properties
$block_size
The Block Length of the block cipher
public
int
$block_size
= 16
Tags
$cfb_init_len
Optimizing value while CFB-encrypting
public
int
$cfb_init_len
= 600
Only relevant if $continuousBuffer enabled and $engine == self::ENGINE_MCRYPT
It's faster to re-init $enmcrypt if $buffer bytes > $cfb_init_len than using the $ecb resource furthermore.
This value depends of the chosen cipher and the time it would be needed for it's initialization [by mcrypt_generic_init()] which, typically, depends on the complexity on its internaly Key-expanding algorithm.
Tags
$changed
Does internal cipher state need to be (re)initialized?
public
bool
$changed
= true
Tags
$cipher_name_mcrypt
The mcrypt specific name of the cipher
public
string
$cipher_name_mcrypt
Only used if $engine == self::ENGINE_MCRYPT
Tags
$cipher_name_openssl
The openssl specific name of the cipher
public
string
$cipher_name_openssl
Only used if $engine == self::ENGINE_OPENSSL
Tags
$cipher_name_openssl_ecb
The openssl specific name of the cipher in ECB mode
public
string
$cipher_name_openssl_ecb
If OpenSSL does not support the mode we're trying to use (CTR) it can still be emulated with ECB mode.
Tags
$continuousBuffer
Continuous Buffer status
public
bool
$continuousBuffer
= false
Tags
$debuffer
Decryption buffer for CTR, OFB and CFB modes
public
array<string|int, mixed>
$debuffer
Tags
$dechanged
Does the demcrypt resource need to be (re)initialized?
public
bool
$dechanged
= true
Tags
$decryptIV
A "sliding" Initialization Vector
public
string
$decryptIV
Tags
$demcrypt
mcrypt resource for decryption
public
resource
$demcrypt
The mcrypt resource can be recreated every time something needs to be created or it can be created just once. Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
Tags
$ecb
mcrypt resource for CFB mode
public
resource
$ecb
mcrypt's CFB mode, in (and only in) buffered context, is broken, so phpseclib implements the CFB mode by it self, even when the mcrypt php extension is available.
In order to do the CFB-mode work (fast) phpseclib use a separate ECB-mode mcrypt resource.
Tags
$enbuffer
Encryption buffer for CTR, OFB and CFB modes
public
array<string|int, mixed>
$enbuffer
Tags
$enchanged
Does the enmcrypt resource need to be (re)initialized?
public
bool
$enchanged
= true
Tags
$encryptIV
A "sliding" Initialization Vector
public
string
$encryptIV
Tags
$engine
Holds which crypt engine internaly should be use, which will be determined automatically on __construct()
public
int
$engine
Currently available $engines are:
- self::ENGINE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required)
- self::ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
- self::ENGINE_INTERNAL (slower, pure php-engine, no php-extension required)
Tags
$enmcrypt
mcrypt resource for encryption
public
resource
$enmcrypt
The mcrypt resource can be recreated every time something needs to be created or it can be created just once. Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
Tags
$explicit_key_length
Has the key length explicitly been set or should it be derived from the key, itself?
public
bool
$explicit_key_length
= false
Tags
$inline_crypt
The name of the performance-optimized callback function
public
callable
$inline_crypt
Used by encrypt() / decrypt() only if $engine == self::ENGINE_INTERNAL
Tags
$iv
The Initialization Vector
public
string
$iv
Tags
$key
The Key
public
string
$key
= "