diff --git a/app/Util/Crypto.php b/app/Util/Crypto.php
index fe7b6b4c6..26abb2cd9 100644
--- a/app/Util/Crypto.php
+++ b/app/Util/Crypto.php
@@ -12,7 +12,7 @@ class Crypto {
throw new \Exception("internal openssl iv error");
}
$key = static::hash($key);
- $iv = openssl_random_pseudo_bytes($iv_size);
+ $iv = random_bytes($iv_size); // @phpstan-ignore argument.type (iv is >0)
$cipher = openssl_encrypt(
$plaintext, static::ENC_ALGO, $key, OPENSSL_RAW_DATA, $iv,
$tag, $aad, static::GCM_TAG_SIZE);
diff --git a/lib/util.php b/lib/util.php
index 7bbb9e3bc..0504a4950 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -683,16 +683,12 @@ function make_utf8(?string $str): string {
* @param int $len
* @return string random alphanumeric string
*/
-function randomString($len = 32) {
+function randomString(int $len = 32): string {
$alphabet = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789');
- $max = count($alphabet);
- $mask = 2 ** (int)ceil(log($len, 2)) - 1;
+ $max = count($alphabet) - 1;
$out = '';
- while (strlen($out) < $len) {
- $n = ord(openssl_random_pseudo_bytes(1)) & $mask;
- if ($n < $max) {
- $out .= $alphabet[$n];
- }
+ for ($i = 0; $i < $len; $i++) {
+ $out .= $alphabet[random_int(0, $max)];
}
return $out;
}
diff --git a/sections/tools/data/site_info.php b/sections/tools/data/site_info.php
index c8f867503..b77969b65 100644
--- a/sections/tools/data/site_info.php
+++ b/sections/tools/data/site_info.php
@@ -40,7 +40,6 @@ if (isset($_GET['mode']) && $_GET['mode'] === 'userrank') {
'table' => $rankTable,
]);
} else {
- $random = openssl_random_pseudo_bytes(8, $strong);
$db = new DB();
$pg = new DB\Pg(PG_RO_DSN);
echo $Twig->render('admin/site-info.twig', [
@@ -48,7 +47,6 @@ if (isset($_GET['mode']) && $_GET['mode'] === 'userrank') {
'gid' => gid(posix_getgid()),
'euid' => uid(posix_geteuid()),
'egid' => gid(posix_getegid()),
- 'openssl_strong' => $strong,
'mysql_version' => $db->version(),
'index' => [
'redundant' => $db->redundantIndexList(),
diff --git a/templates/admin/site-info.twig b/templates/admin/site-info.twig
index 41796c905..7c71f88ff 100644
--- a/templates/admin/site-info.twig
+++ b/templates/admin/site-info.twig
@@ -29,15 +29,9 @@ div#phpinfo hr {width: 934px; background-color: #ccc; border: 0; height: 1px;}
Uptime: {{ site_info.uptime.uptime|raw }}
Idle time: {{ site_info.uptime.idletime|raw }}
User: {{ uid }}
- Group: {{ euid }}
+ Group: {{ gid }}
Effective User: {{ euid }}
- Effective Group: {{ euid }}
-
openssl_random_pseudo_bytes():
-{%- if openssl_strong -%}
- Strong
-{%- else -%}
- Weak/broken
-{%- endif -%}
+ Effective Group: {{ egid }}