18 \fpoirotte\Pssht\Algorithms\AEAD\AEADInterface,
19 \fpoirotte\Pssht\Algorithms\AvailabilityInterface
29 $this->iv = gmp_init(bin2hex(
$iv), 16);
30 $this->gcm = new \fpoirotte\Pssht\Algorithms\AEAD\GCM(
39 return 'aes128-gcm@openssh.com';
64 $len = substr($data, 0, 4);
65 $plain = (string) substr($data, 4);
66 $iv = str_pad(gmp_strval($this->iv, 16), 24,
'0', STR_PAD_LEFT);
67 $res = $this->gcm->ae(pack(
'H*',
$iv), $plain, $len);
68 $this->iv = \fpoirotte\Pssht\Algorithms\AEAD\GCM::inc($this->iv, 64);
69 return $len . $res[0] . $res[1];
74 if (strlen($data) === 4) {
78 $len = substr($data, 0, 4);
79 $cipher = (string) substr($data, 4, -static::getSize());
80 $tag = substr($data, -static::getSize());
81 $iv = str_pad(gmp_strval($this->iv, 16), 24,
'0', STR_PAD_LEFT);
82 $res = $this->gcm->ad(pack(
'H*',
$iv), $cipher, $len, $tag);
83 $this->iv = \fpoirotte\Pssht\Algorithms\AEAD\GCM::inc($this->iv, 64);
89 if (!extension_loaded(
'mcrypt')) {
93 if (!defined(
'MCRYPT_RIJNDAEL_128')) {
96 $res = @mcrypt_module_open(
102 if ($res !==
false) {
103 mcrypt_module_close($res);
$gcm
Underlying GCM implementation.
static getName()
Return the name of the algorithm.
$iv
Initialization vector.