From 035394cbf2c4edff8cd36595beaee2c1e9dcc4c4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 19 Jan 2018 11:34:56 -0500 Subject: [PATCH] RINO code cleanup - Restore original use Friendica\Util\Crypto - Remove RINO1 deprecation comments - Fix undefined variable $rino_remote_version --- mod/dfrn_notify.php | 10 +++------- src/Protocol/DFRN.php | 7 ++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 9c5aff2ead..8903d66e35 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -143,7 +143,7 @@ function dfrn_notify_post(App $a) { // if local rino is lower than remote rino, abort: should not happen! // but only for $remote_rino > 1, because old code did't send rino version - if ($rino_remote_version > 1 && $rino < $rino_remote) { + if ($rino_remote > 1 && $rino < $rino_remote) { logger("rino version '$rino_remote' is lower than supported '$rino'"); xml_status(0, "rino version '$rino_remote' is lower than supported '$rino'"); } @@ -166,15 +166,11 @@ function dfrn_notify_post(App $a) { } } - #logger('rino: received key : ' . $final_key); - switch($rino_remote) { case 0: case 1: - /* - * we got a key. old code send only the key, without RINO version. - * we assume RINO 1 if key and no RINO version - */ + // we got a key. old code send only the key, without RINO version. + // we assume RINO 1 if key and no RINO version $data = DFRN::aesDecrypt(hex2bin($data), $final_key); break; default: diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 76e8d58564..305e3d3fde 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -22,7 +22,7 @@ use Friendica\Model\Term; use Friendica\Model\User; use Friendica\Object\Image; use Friendica\Protocol\OStatus; -use Friendica\Util\Crypto as FriendicaCrypto; +use Friendica\Util\Crypto; use Friendica\Util\XML; use dba; @@ -468,7 +468,7 @@ class DFRN /* get site pubkey. this could be a new installation with no site keys*/ $pubkey = Config::get('system', 'site_pubkey'); if (! $pubkey) { - $res = FriendicaCrypto::newKeypair(2048); + $res = Crypto::newKeypair(2048); Config::set('system', 'site_prvkey', $res['prvkey']); Config::set('system', 'site_pubkey', $res['pubkey']); } @@ -1295,9 +1295,10 @@ class DFRN switch ($rino_remote_version) { case 1: case 2: + // Force downgrade in case the remote server is still using the deprecated version 2 $rino = 1; $rino_remote_version = 1; - // Deprecated rino version! + $key = openssl_random_pseudo_bytes(16); $data = self::aesEncrypt($postvars['data'], $key); break;