]> git.mxchange.org Git - friendica.git/commitdiff
Fix php-encryption version 2 compatibility issues
authorHypolite Petovan <mrpetovan@gmail.com>
Thu, 9 Nov 2017 07:35:11 +0000 (02:35 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Thu, 9 Nov 2017 07:35:11 +0000 (02:35 -0500)
mod/dfrn_notify.php
src/Protocol/DFRN.php

index c8dc093d17e6280aee023e66118ad8dcf56fd46b..b8c771b75a0cd6f18ee2e4af8850c714307543d7 100644 (file)
@@ -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:
index 6ba8ed7d10e57f2d5fd9a8c87719d5bbd68d132d..7f37f9839b1fda38d1bdee8b3b7b404aec06fa51 100644 (file)
@@ -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;