Skip to content

Commit 661cab6

Browse files
authored
#170 - issue - openssl 3.0 patch
1 parent fc7ab06 commit 661cab6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/functions.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
define('DOCDIR',sprintf('%s/',realpath(LIBDIR.'../doc/')));
2222
define('HOOKSDIR',sprintf('%s/',realpath(LIBDIR.'../hooks/')));
2323
define('JSDIR','js/');
24+
define('SESSION_CIPHER','aes256-gcm');
2425

2526
/**
2627
* Supplimental functions
@@ -768,9 +769,9 @@ function blowfish_encrypt($data,$secret=null) {
768769
if (! trim($secret))
769770
return $data;
770771

771-
if (! empty($data) && function_exists('openssl_encrypt') && in_array('bf-ecb', openssl_get_cipher_methods())) {
772-
$keylen = openssl_cipher_iv_length('bf-ecb') * 2;
773-
return openssl_encrypt($data, 'bf-ecb', substr($secret,0,$keylen));
772+
if (! empty($data) && function_exists('openssl_encrypt') && in_array(SESSION_CIPHER, openssl_get_cipher_methods())) {
773+
$keylen = openssl_cipher_iv_length(SESSION_CIPHER) * 2;
774+
return openssl_encrypt($data, SESSION_CIPHER, substr($secret,0,$keylen));
774775
}
775776

776777
if (function_exists('mcrypt_module_open') && ! empty($data)) {
@@ -829,9 +830,9 @@ function blowfish_decrypt($encdata,$secret=null) {
829830
if (! trim($secret))
830831
return $encdata;
831832

832-
if (! empty($encdata) && function_exists('openssl_encrypt') && in_array('bf-ecb', openssl_get_cipher_methods())) {
833-
$keylen = openssl_cipher_iv_length('bf-ecb') * 2;
834-
return trim(openssl_decrypt($encdata, 'bf-ecb', substr($secret,0,$keylen)));
833+
if (! empty($encdata) && function_exists('openssl_encrypt') && in_array(SESSION_CIPHER, openssl_get_cipher_methods())) {
834+
$keylen = openssl_cipher_iv_length(SESSION_CIPHER) * 2;
835+
return trim(openssl_decrypt($encdata, SESSION_CIPHER, substr($secret,0,$keylen)));
835836
}
836837

837838
if (function_exists('mcrypt_module_open') && ! empty($encdata)) {

0 commit comments

Comments
 (0)