mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-27 09:08:24 +00:00
SymmetricKey: add Eval engine implementation for 'cfb8' cipher mode of operation
This commit is contained in:
parent
8604e327a3
commit
7aa400745c
@ -2558,6 +2558,52 @@ abstract class SymmetricKey
|
||||
$_pos = $_len;
|
||||
}
|
||||
|
||||
return $_plaintext;
|
||||
';
|
||||
break;
|
||||
case self::MODE_CFB8:
|
||||
$encrypt = $init_encrypt . '
|
||||
$_ciphertext = "";
|
||||
$_len = strlen($_text);
|
||||
$_iv = $this->encryptIV;
|
||||
|
||||
for ($_i = 0; $_i < $_len; ++$_i) {
|
||||
$in = $_iv;
|
||||
'.$encrypt_block.'
|
||||
$_ciphertext .= ($_c = $_text[$_i] ^ $in);
|
||||
$_iv = substr($_iv, 1, '.$block_size.' - 1) . $_c;
|
||||
}
|
||||
|
||||
if ($this->continuousBuffer) {
|
||||
if ($_len >= '.$block_size.') {
|
||||
$this->encryptIV = substr($_ciphertext, -'.$block_size.');
|
||||
} else {
|
||||
$this->encryptIV = substr($this->encryptIV, $_len - '.$block_size.') . substr($_ciphertext, -$_len);
|
||||
}
|
||||
}
|
||||
|
||||
return $_ciphertext;
|
||||
';
|
||||
$decrypt = $init_encrypt . '
|
||||
$_plaintext = "";
|
||||
$_len = strlen($_text);
|
||||
$_iv = $this->decryptIV;
|
||||
|
||||
for ($_i = 0; $_i < $_len; ++$_i) {
|
||||
$in = $_iv;
|
||||
'.$encrypt_block.'
|
||||
$_plaintext .= $_text[$_i] ^ $in;
|
||||
$_iv = substr($_iv, 1, '.$block_size.' - 1) . $_text[$_i];
|
||||
}
|
||||
|
||||
if ($this->continuousBuffer) {
|
||||
if ($_len >= '.$block_size.') {
|
||||
$this->decryptIV = substr($_text, -'.$block_size.');
|
||||
} else {
|
||||
$this->decryptIV = substr($this->decryptIV, $_len - '.$block_size.') . substr($_text, -$_len);
|
||||
}
|
||||
}
|
||||
|
||||
return $_plaintext;
|
||||
';
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user