]> git.mxchange.org Git - friendica.git/blobdiff - include/dfrn.php
Merge branch 'develop' into rewrites/coding-convention-split2
[friendica.git] / include / dfrn.php
index 83d76a0ae45cea961b58cd1ea60944fac1f10a0c..aae935963d0427c7b6ab7afd3cefc62ecc73893a 100644 (file)
@@ -931,6 +931,30 @@ class dfrn {
                return $entry;
        }
 
+       /**
+        * @brief encrypts data via AES
+        *
+        * @param string $data The data that is to be encrypted
+        * @param string $key The AES key
+        *
+        * @return string encrypted data
+        */
+       private static function aes_encrypt($data, $key) {
+               return openssl_encrypt($data, 'aes-128-ecb', $key, OPENSSL_RAW_DATA);
+       }
+
+       /**
+        * @brief decrypts data via AES
+        *
+        * @param string $encrypted The encrypted data
+        * @param string $key The AES key
+        *
+        * @return string decrypted data
+        */
+       public static function aes_decrypt($encrypted, $key) {
+               return openssl_decrypt($encrypted, 'aes-128-ecb', $key, OPENSSL_RAW_DATA);
+       }
+
        /**
         * @brief Delivers the atom content to the contacts
         *
@@ -958,11 +982,6 @@ class dfrn {
                $rino = get_config('system', 'rino_encrypt');
                $rino = intval($rino);
 
-               // use RINO1 if mcrypt isn't installed and RINO2 was selected
-               if ($rino == 2 and !function_exists('mcrypt_create_iv')) {
-                       $rino = 1;
-               }
-
                logger("Local rino version: ". $rino, LOGGER_DEBUG);
 
                $ssl_val = intval(get_config('system','ssl_policy'));
@@ -1093,8 +1112,8 @@ class dfrn {
                        switch ($rino_remote_version) {
                                case 1:
                                        // Deprecated rino version!
-                                       $key = substr(random_string(), 0, 16);
-                                       $data = aes_encrypt($postvars['data'],$key);
+                                       $key = openssl_random_pseudo_bytes(16);
+                                       $data = self::aes_encrypt($postvars['data'], $key);
                                        break;
                                case 2:
                                        // RINO 2 based on php-encryption
@@ -1458,7 +1477,9 @@ class dfrn {
                        $poco["photo"] = $author["avatar"];
                        $poco["hide"] = $hide;
                        $poco["contact-type"] = $contact["contact-type"];
-                       update_gcontact($poco);
+                       $gcid = update_gcontact($poco);
+
+                       link_gcontact($gcid, $importer["uid"], $contact["id"]);
                }
 
                return($author);