Added support for AES IGE #1095

Open
wants to merge 2 commits into
from

Projects

None yet

2 participants

@danog
Contributor
danog commented Feb 10, 2017

Added support for AES IGE encryption/decryption mode: unfortunately, native and inline mode don't seem to work properly, and I can't find the problem, so a bit of help would be real nice :)

phpseclib/Crypt/Common/SymmetricKey.php
@@ -498,10 +505,12 @@ public function setIV($iv)
throw new \InvalidArgumentException('This algorithm does not use an IV.');
}
- if (strlen($iv) != $this->block_size) {
- throw new \LengthException('Received initialization vector of size ' . strlen($iv) . ', but size ' . $this->block_size . ' is required');
+ if (strlen($iv) != $this->block_size*($this->mode === self::MODE_IGE ? 2 : 1)) {
@bantu
bantu Feb 11, 2017 Member

Let's introduce a new variable: expected_iv_length

@danog
danog Feb 11, 2017 Contributor

Done!

@@ -840,6 +849,21 @@ public function encrypt($plaintext)
return $result;
case self::MODE_CTR:
return $this->openssl_ctr_process($plaintext, $this->encryptIV, $this->enbuffer);
+ case self::MODE_IGE:
+ $ciphertext = '';
@bantu
bantu Feb 11, 2017 Member

This block seems to be (largely) duplicated a bunch of times below.

@danog
danog Feb 11, 2017 Contributor

Yes, but I wasn't sure whether it was a good idea to create a separate function just to avoid duplicating a few lines of code.
Should I do that?

@danog
danog Feb 13, 2017 Contributor

Also, what about the problems in the native module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment