Re: Support getrandom() for pg_strong_random() source
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>, Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-30T11:09:01Z
Lists: pgsql-hackers
On 22.07.25 13:11, Dagfinn Ilmari Mannsåker wrote: > getrandom() is Linux-specific, while getentropy() is specified by POSIX > (since 2024). It was originally introduced by OpenBSD 5.6 in 2014, and > was added to macOS 10.12 in 2016, glibc 2.25 (same as getrandom()) in > 2017, musl 1.1.20 and FreeBSD 12.0 in 2018, and NetBSD 10.0 in 2024 > > Sources: > > https://pubs.opengroup.org/onlinepubs/9799919799/functions/getentropy.html > https://dotat.at/@/2024-10-01-getentropy.html > > So I think it's more worthwhile to add support for getentropy() than > getrandom(). The POSIX description of getentropy() says: "The intended use of this function is to create a seed for other pseudo-random number generators." So using getentropy() for generating the random numbers that are passed back to the application code would appear to be the wrong use.