]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/Crypto.php
Merge pull request #4243 from MrPetovan/task/switch-to-array-new-style
[friendica.git] / src / Util / Crypto.php
index c63149e5fab9628ac810423f94d9d04f1d806712..22cb775336253b8bfb3ca18e0b0d4ce2e3be9ad9 100644 (file)
@@ -6,6 +6,7 @@ namespace Friendica\Util;
 
 use Friendica\Core\Config;
 use ASN_BASE;
+use ASNValue;
 
 require_once 'library/ASNValue.class.php';
 require_once 'library/asn1.php';
@@ -95,7 +96,7 @@ class Crypto
                $modulus->SetIntBuffer($Modulus);
                $publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
                $publicExponent->SetIntBuffer($PublicExponent);
-               $keySequenceItems = array($modulus, $publicExponent);
+               $keySequenceItems = [$modulus, $publicExponent];
                $keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
                $keySequence->SetSequence($keySequenceItems);
                //Encode bit string
@@ -124,7 +125,7 @@ class Crypto
                $modulus->SetIntBuffer($Modulus);
                $publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
                $publicExponent->SetIntBuffer($PublicExponent);
-               $keySequenceItems = array($modulus, $publicExponent);
+               $keySequenceItems = [$modulus, $publicExponent];
                $keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
                $keySequence->SetSequence($keySequenceItems);
                //Encode bit string
@@ -189,7 +190,7 @@ class Crypto
         * @param string $e   exponent reference
         * @return void
         */
-       private static function pemToMe($key, &$m, &$e)
+       public static function pemToMe($key, &$m, &$e)
        {
                $lines = explode("\n", $key);
                unset($lines[0]);
@@ -214,27 +215,17 @@ class Crypto
                return $key;
        }
 
-       /**
-        * @param string $pubkey public key
-        * @return string
-        */
-       public static function salmonKey($pubkey)
-       {
-               self::pemToMe($pubkey, $m, $e);
-               return 'RSA' . '.' . base64url_encode($m, true) . '.' . base64url_encode($e, true);
-       }
-
        /**
         * @param integer $bits number of bits
         * @return mixed
         */
        public static function newKeypair($bits)
        {
-               $openssl_options = array(
+               $openssl_options = [
                        'digest_alg'       => 'sha1',
                        'private_key_bits' => $bits,
                        'encrypt_key'      => false
-               );
+               ];
 
                $conf = Config::get('system', 'openssl_conf_file');
                if ($conf) {
@@ -248,7 +239,7 @@ class Crypto
                }
 
                // Get private key
-               $response = array('prvkey' => '', 'pubkey' => '');
+               $response = ['prvkey' => '', 'pubkey' => ''];
 
                openssl_pkey_export($result, $response['prvkey']);