/* Decoded by unphp.net */ cipherMode == CipherMode::CBC) { if ($properties->keySize == ChunkSize::e128bits) { return new \phpseclib\Crypt\AES(); } else { if ($properties->keySize == ChunkSize::e256bits) { return new \phpseclib\Crypt\Rijndael(); } else { vt_loge("Unsupported cipher mode: " . $properties->cipherMode); throw new \InvalidArgumentException("Unsupported cipher mode: " . $properties->cipherMode); } } } else { vt_loge("Unsupported cipher mode: " . $properties->cipherMode); throw new \InvalidArgumentException("Unsupported cipher mode: " . $properties->cipherMode); } } public function decrypt($cipher, &$plain) { try { $cipher_mode = $this->getCipherMode($this->properties); $cipher_mode->setBlockLength($this->properties->blockSize); $cipher_mode->setKey($this->key); $cipher_mode->setIV($this->iv); $cipher_mode->disablePadding(); $plain = $cipher_mode->decrypt($cipher); $unpadded = CryptoUtils::unpad($plain, $this->properties->paddingMode, $this->properties->blockSize); $plain = $unpadded; } catch (Exception $e) { vt_loge("Error in decrypt: " . $e); return VTCryptoError::VERR_CRYPTO_ERROR; } return VTCryptoError::VERR_CRYPTO_SUCCESS; } public function encrypt($plain, &$cipher) { $padded = CryptoUtils::pad($plain, $this->properties->paddingMode, $this->properties->blockSize); try { $cipher_mode = $this->getCipherMode($this->properties); $cipher_mode->setBlockLength($this->properties->blockSize); $cipher_mode->setKey($this->key); $cipher_mode->setIV($this->iv); $cipher_mode->disablePadding(); $cipher = $cipher_mode->encrypt($padded); } catch (Exception $e) { vt_loge("Error in encrypt: " . $e); return VTCryptoError::VERR_CRYPTO_ERROR; } return VTCryptoError::VERR_CRYPTO_SUCCESS; } public function setIV($iv) { $this->iv = $iv; } public function setKey($key) { $this->key = $key; } public function setProperties(AESProperties $properties) { $this->properties = $properties; } } ?>