From d5aff9ac31a67cdd7a78327ed2915d2c7a7a133a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 9 Nov 2017 02:35:11 -0500 Subject: [PATCH] Fix php-encryption version 2 compatibility issues --- mod/dfrn_notify.php | 3 ++- src/Protocol/DFRN.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index c8dc093d17..b8c771b75a 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -183,7 +183,8 @@ function dfrn_notify_post(App $a) { break; case 2: try { - $data = \Defuse\Crypto\Crypto::decrypt(hex2bin($data), $final_key); + $FinalKey = \Defuse\Crypto\Key::loadFromAsciiSafeString($final_key); + $data = \Defuse\Crypto\Crypto::decrypt(hex2bin($data), $FinalKey); } catch (\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) { // VERY IMPORTANT /* * Either: diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 6ba8ed7d10..7f37f9839b 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1296,13 +1296,14 @@ class DFRN case 2: // RINO 2 based on php-encryption try { - $key = \Defuse\Crypto\Key::createNewRandomKey(); + $KeyObject = \Defuse\Crypto\Key::createNewRandomKey(); } catch (\Defuse\Crypto\Exception\CryptoException $ex) { logger('Cannot safely create a key'); return -4; } try { - $data = \Defuse\Crypto\Crypto::encrypt($postvars['data'], $key); + $data = \Defuse\Crypto\Crypto::encrypt($postvars['data'], $KeyObject); + $key = $KeyObject->saveToAsciiSafeString(); } catch (\Defuse\Crypto\Exception\CryptoException $ex) { logger('Cannot safely perform encryption'); return -6;