-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #905 : la fonction mcrypt_cbc est obsolète. #913
Conversation
Fix #905 |
@@ -5,7 +5,7 @@ | |||
|
|||
$comptaFact = new Facture($bdd); | |||
|
|||
$ref = trim(mcrypt_cbc (MCRYPT_TripleDES, 'PaiementFactureAFUP_AFUP', base64_decode(str_replace(' ', '+', urldecode($_GET['ref']))), MCRYPT_DECRYPT, '@PaiFact')); | |||
$ref = $comptaFact->decryptLink(str_replace(' ', '+', urldecode($_GET['ref']))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le fallback sur l'ancien chiffrement est nécessaire pour conserver le fonctionnement des liens existants
$ref = $comptaFact->decryptLink(str_replace(' ', '+', urldecode($_GET['ref']))); | |
$ref = $comptaFact->decryptLink(str_replace(' ', '+', urldecode($_GET['ref']))); | |
if ($ref === false) { | |
$ref = trim(mcrypt_cbc (MCRYPT_TripleDES, 'PaiementFactureAFUP_AFUP', base64_decode(str_replace(' ', '+', urldecode($_GET['ref']))), MCRYPT_DECRYPT, '@PaiFact')); | |
} |
{ | ||
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher)); | ||
|
||
return base64_encode(openssl_encrypt($data, $this->cipher, $this->key, 0, $iv) . '::' . $iv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utilisation de URLBase64 car la valeur est utilisée dans une URL.
return base64_encode(openssl_encrypt($data, $this->cipher, $this->key, 0, $iv) . '::' . $iv); | |
return str_replace(['+','/'] , ['-','_'], base64_encode(openssl_encrypt($data, $this->cipher, $this->key, 0, $iv) . '::' . $iv)); |
|
||
public function decryptLink($data) | ||
{ | ||
list($encrypted_data, $iv) = explode('::', base64_decode($data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gestion des erreurs liées à base64_decode et l'absence du séparateur
list($encrypted_data, $iv) = explode('::', base64_decode($data)); | |
$decoded = base64_decode(str_replace(['-', '_'], ['+', '/'],$data)); | |
if ($decoded === false || strpos($decoded, '::') === false) { | |
return false; | |
} | |
list($encrypted_data, $iv) = explode('::', $decoded); |
@@ -9,6 +9,9 @@ | |||
|
|||
class Facture | |||
{ | |||
private $cipher = 'aes-256-gcm'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L'algo aes-256-gcm
demande l'ajout de l'argument tag
pour le chiffrement et déchiffrement. Pour éviter sont utilisation, il est possible d'utiliser aes-256-cbc
.
private $cipher = 'aes-256-gcm'; | |
private $cipher = 'aes-256-cbc'; |
Cela a été traité dans cette PR #1356 je ferme donc celle. Merci pour l'alerte et la première version. |
No description provided.