Merge pull request #24925 from ATM-Consulting/FIX_openssl_iv_truncation_shouldnt_rely_on_dol_trunc

FIX: use dol_substr instead of dol_trunc for truncating openssl initialization vector
This commit is contained in:
Laurent Destailleur
2023-06-04 15:21:45 +02:00
committed by GitHub

View File

@@ -152,7 +152,7 @@ function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed =
if (empty($forceseed)) {
$ivseed = dolGetRandomBytes($ivlen);
} else {
$ivseed = dol_trunc(md5($forceseed), $ivlen, 'right', 'UTF-8', 1);
$ivseed = dol_substr(md5($forceseed), 0, $ivlen, 'ascii', 1);
}
$newchain = openssl_encrypt($chain, $ciphering, $key, 0, $ivseed);