add methods to decrypt return data from router
[GitHub/Stricted/speedport-hybrid-php-api.git] / CryptLib / Cipher / Block / Mode / CFB.php
1 <?php
2 /**
3 * The CFB (Cipher FeedBack) mode implementation
4 *
5 * PHP version 5.3
6 *
7 * @category PHPCryptLib
8 * @package Cipher
9 * @subpackage Block
10 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
11 * @copyright 2011 The Authors
12 * @license http://www.opensource.org/licenses/mit-license.html MIT License
13 * @version Build @@version@@
14 */
15
16 namespace CryptLib\Cipher\Block\Mode;
17
18 /**
19 * The CFB (Cipher FeedBack) mode implementation
20 *
21 * @category PHPCryptLib
22 * @package Cipher
23 * @subpackage Block
24 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
25 */
26 class CFB extends \CryptLib\Cipher\Block\AbstractMode {
27
28 /**
29 * Decrypt the data using the supplied key, cipher
30 *
31 * @param string $data The data to decrypt
32 *
33 * @return string The decrypted data
34 */
35 protected function decryptBlock($data) {
36 $stub = $this->cipher->encryptBlock($this->state);
37 $rawData = $stub ^ $data;
38 $this->state = $rawData;
39 return $rawData;
40 }
41
42 /**
43 * Encrypt the data using the supplied key, cipher
44 *
45 * @param string $data The data to encrypt
46 *
47 * @return string The encrypted data
48 */
49 protected function encryptBlock($data) {
50 $stub = $this->cipher->encryptBlock($this->state);
51 $this->state = $data;
52 return $stub ^ $data;
53 }
54
55 }