프로퍼티 | 타입 | 설명 | |
---|---|---|---|
$cfb_init_len | integer | Optimizing value while CFB-encrypting | |
$cipher_name_mcrypt | string | The mcrypt specific name of the cipher | |
$des | array | Used only if $mode_3cbc === true | |
$key_length | integer | Key Length (in bytes) | |
$key_length_max | string | max possible size of $key | |
$mode_3cbc | boolean | Internal flag whether using self::MODE_3CBC or not | |
$password_default_salt | string | The default salt used by setPassword() |
메소드 | 설명 | |
---|---|---|
__construct ( integer $mode ) | Default Constructor. | |
_setupKey ( ) | Creates the key schedule | |
decrypt ( string $ciphertext ) : string | Decrypts a message. | |
disableContinuousBuffer ( ) | Treat consecutive packets as if they are a discontinuous buffer. | |
enableContinuousBuffer ( ) | Treat consecutive "packets" as if they are a continuous buffer. | |
encrypt ( string $plaintext ) : string | Encrypts a message. | |
isValidEngine ( integer $engine ) : boolean | Test for engine validity | |
setIV ( string $iv ) | Sets the initialization vector. | |
setKey ( string $key ) | Sets the key. | |
setKeyLength ( integer $length ) | Sets the key length. | |
setPreferredEngine ( integer $engine ) : integer | Sets the internal crypt engine |
public __construct ( integer $mode ) | ||
$mode | integer |
echo $des->encrypt(substr($plaintext, 0, 8));
echo $des->encrypt(substr($plaintext, 8, 8));
echo $des->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:
$des->encrypt(substr($plaintext, 0, 8));
echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8)));
echo $des->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 \phpseclib\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. public enableContinuousBuffer ( ) |
public isValidEngine ( integer $engine ) : boolean | ||
$engine | integer | |
리턴 | boolean |
public setKeyLength ( integer $length ) | ||
$length | integer |
public setPreferredEngine ( integer $engine ) : integer | ||
$engine | integer | |
리턴 | integer |
public string $cipher_name_mcrypt | ||
리턴 | string |
public bool $mode_3cbc | ||
리턴 | boolean |
public string $password_default_salt | ||
리턴 | string |