]> git.mxchange.org Git - friendica.git/commitdiff
use "random_bytes" instead of "openssl_random_pseudo_bytes"
authorMichael <heluecht@pirati.ca>
Tue, 11 May 2021 13:12:12 +0000 (13:12 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 11 May 2021 13:12:12 +0000 (13:12 +0000)
mod/dfrn_confirm.php
src/Module/Api/Mastodon/Apps.php
src/Module/BaseApi.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php

index 164198c9d4ba58a1dbbc59bc031b34df9f1b1c98..47cc09326f7101ecedccf675ab4aa23d2f0bd299 100644 (file)
@@ -181,7 +181,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                 * random key which is encrypted with their site public key.
                 */
 
-               $src_aes_key = openssl_random_pseudo_bytes(64);
+               $src_aes_key = random_bytes(64);
 
                $result = '';
                openssl_private_encrypt($dfrn_id, $result, $user['prvkey']);
index b5d98d455f2f3ff3963fb78233a04b6ba90d34e3..3d06cdbb05cc56012d8e00af90ae60692948ad77 100644 (file)
@@ -46,8 +46,8 @@ class Apps extends BaseApi
                        DI::mstdnError()->RecordNotFound();
                }
 
-               $client_id     = bin2hex(openssl_random_pseudo_bytes(32));
-               $client_secret = bin2hex(openssl_random_pseudo_bytes(32));
+               $client_id     = bin2hex(random_bytes(32));
+               $client_secret = bin2hex(random_bytes(32));
 
                $fields = ['client_id' => $client_id, 'client_secret' => $client_secret, 'name' => $name, 'redirect_uri' => $redirect];
 
index 739d400e3c048936a3ab73d3009bde9768086a70..9e7ee38365708f249c22271c6fd3fe6d9598f5fe 100644 (file)
@@ -216,8 +216,8 @@ class BaseApi extends BaseModule
 
        public static function getTokenForUser(array $application, int $uid)
        {
-               $code         = bin2hex(openssl_random_pseudo_bytes(32));
-               $access_token = bin2hex(openssl_random_pseudo_bytes(32));
+               $code         = bin2hex(random_bytes(32));
+               $access_token = bin2hex(random_bytes(32));
 
                $fields = ['application-id' => $application['id'], 'uid' => $uid, 'code' => $code, 'access_token' => $access_token, 'created_at' => DateTimeFormat::utcNow(DateTimeFormat::MYSQL)];
                if (!DBA::insert('application-token', $fields, Database::INSERT_UPDATE)) {
index df974729bab07261d01cfe7b8645d167727391cc..a24fbaa0332d0d2cf3be309e2124f5236acada19 100644 (file)
@@ -1272,7 +1272,7 @@ class DFRN
 
                        switch ($rino_remote_version) {
                                case 1:
-                                       $key = openssl_random_pseudo_bytes(16);
+                                       $key = random_bytes(16);
                                        $data = self::aesEncrypt($postvars['data'], $key);
                                        break;
 
index 16f934eccf3cbef0d475be9de2228ec16163644b..00da7d3915d2dd68d0f7c6013af0472c5f4b3c8e 100644 (file)
@@ -2870,9 +2870,9 @@ class Diaspora
                        return false;
                }
 
-               $aes_key = openssl_random_pseudo_bytes(32);
+               $aes_key = random_bytes(32);
                $b_aes_key = base64_encode($aes_key);
-               $iv = openssl_random_pseudo_bytes(16);
+               $iv = random_bytes(16);
                $b_iv = base64_encode($iv);
 
                $ciphertext = self::aesEncrypt($aes_key, $iv, $msg);