cryptal
latest
Cryptography Abstraction Layer
Main Page
Classes
Files
File List
OFB.php
1
<?php
2
3
namespace
fpoirotte\Cryptal\Modes
;
4
5
use
fpoirotte\Cryptal\Implementers\CryptoInterface
;
6
use
fpoirotte\Cryptal\SymmetricModeInterface
;
7
11
class
OFB
implements
SymmetricModeInterface
12
{
14
protected
$cipher
;
15
17
protected
$iv
;
18
19
public
function
__construct
(
CryptoInterface
$cipher
,
$iv
, $tagLength)
20
{
21
$ivSize = strlen(
$iv
);
22
$blockSize = $cipher->
getBlockSize
();
23
if
($ivSize !== $blockSize) {
24
throw
new \Exception(
"Invalid IV size (got $ivSize bytes; should be $blockSize)"
);
25
}
26
27
$this->cipher =
$cipher
;
28
$this->iv =
$iv
;
29
}
30
31
public
function
encrypt
($data, $context)
32
{
33
$res = $this->cipher->encrypt(
''
, $this->iv);
34
$this->iv = $res;
35
return
$res ^ $data;
36
}
37
}
CryptoInterface
fpoirotte\Cryptal\Implementers\CryptoInterface\getBlockSize
getBlockSize()
fpoirotte\Cryptal\Modes\OFB\$cipher
$cipher
Cipher.
Definition:
OFB.php:14
fpoirotte\Cryptal\Implementers\CryptoInterface
Definition:
CryptoInterface.php:13
fpoirotte\Cryptal\Modes\OFB\$iv
$iv
Initialization Vector.
Definition:
OFB.php:17
fpoirotte\Cryptal\Modes\OFB
Definition:
OFB.php:11
fpoirotte\Cryptal\Modes\OFB\encrypt
encrypt($data, $context)
Definition:
OFB.php:31
fpoirotte\Cryptal\Modes
Definition:
CBC.php:3
fpoirotte\Cryptal\SymmetricModeInterface
Definition:
SymmetricModeInterface.php:11
SymmetricModeInterface
fpoirotte\Cryptal\Modes\OFB\__construct
__construct(CryptoInterface $cipher, $iv, $tagLength)
Definition:
OFB.php:19
src
Cryptal
Modes
OFB.php
Generated on Sat Sep 29 2018 22:22:05 for cryptal by
1.8.11