protected function _openssl_initialize($params)
{
if (!empty($params['cipher'])) {
$params['cipher'] = strtolower($params['cipher']);
$this->_cipher_alias($params['cipher']);
$this->_cipher = $params['cipher'];
}
if (!empty($params['mode'])) {
$params['mode'] = strtolower($params['mode']);
if (!isset($this->_modes['openssl'][$params['mode']])) {
log_message('error', 'Encryption: OpenSSL mode ' . strtoupper($params['mode']) . ' is not available.');
} else {
$this->_mode = $this->_modes['openssl'][$params['mode']];
}
}
if (isset($this->_cipher, $this->_mode)) {
// This is mostly for the stream mode, which doesn't get suffixed in OpenSSL
$handle = empty($this->_mode) ? $this->_cipher : $this->_cipher . '-' . $this->_mode;
if (!in_array($handle, openssl_get_cipher_methods(), TRUE)) {
$this->_handle = NULL;
log_message('error', 'Encryption: Unable to initialize OpenSSL with method ' . strtoupper($handle) . '.');
} else {
$this->_handle = $handle;
log_message('info', 'Encryption: OpenSSL initialized with method ' . strtoupper($handle) . '.');
}
}
}