]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Crypto.php
Ensure ParseUrl::getSiteinfo always returns the url and type keys
[friendica.git] / src / Util / Crypto.php
index 628b45f89b6c19b59896a1e3a78684aa3551939e..8adacf71041bf41953fda879f7b73a4bfb9d3e22 100644 (file)
@@ -1,12 +1,28 @@
 <?php
 /**
- * @file src/Util/Crypto.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
+
 namespace Friendica\Util;
 
 use ASN_BASE;
 use ASNValue;
-use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
@@ -377,7 +393,7 @@ class Crypto
                        // log the offending call so we can track it down
                        if (!openssl_public_encrypt($key, $k, $pubkey)) {
                                $x = debug_backtrace();
-                               Logger::log('RSA failed. ' . print_r($x[0], true));
+                               Logger::notice('RSA failed', ['trace' => $x[0]]);
                        }
 
                        $result['alg'] = $alg;
@@ -445,11 +461,12 @@ class Crypto
                        return;
                }
 
-               $alg = ((array_key_exists('alg', $data)) ? $data['alg'] : 'aes256cbc');
+               $alg = $data['alg'] ?? 'aes256cbc';
                if ($alg === 'aes256cbc') {
-                       return self::encapsulateAes($data['data'], $prvkey);
+                       return self::unencapsulateAes($data['data'], $prvkey);
                }
-               return self::encapsulateOther($data['data'], $prvkey, $alg);
+
+               return self::unencapsulateOther($data, $prvkey, $alg);
        }
 
        /**