agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: solomon.medland@gmail.com
Subject: gen_random_uuid random source clarification
Date: Tue, 08 Apr 2025 18:00:29 +0000
Message-ID: <174413522954.679.17007996269873921261@wrigleys.postgresql.org> (raw)

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/functions-uuid.html
Description:

In reference to the documentation for gen_random_uuid at:
https://www.postgresql.org/docs/17/functions-uuid.html
It would be good to add a comment about the quality/suitability of the
random bits generated.
The function internally traces back to pg_strong_random, with this source
code comment:
https://github.com/postgres/postgres/blob/8969194b73dbc9642a0302225f686f9febd95c90/src/port/pg_stron...
"The returned bytes are cryptographically secure, suitable for use e.g. in
authentication."
It would be good to add a similar comment to the doc page for
gen_random_uuid for clarity.
Technically speaking, the UUID4 spec dictates that a random UUID "SHOULD"
use a cryptographically secure source, but does not make it mandatory and
suggests that a less secure source can be used as a fallback when CSPRNG is
not available:
https://datatracker.ietf.org/doc/html/rfc9562#name-unguessability
Therefore I think it is valuable to note that gen_random_uuid *always*
relies on a secure source, and will fail when no secure source is available
rather than using a fallback (at least, that is my understanding based on a
quick scan of the source code).


Message-ID: <174413522954.679.17007996269873921261@wrigleys.postgresql.org>
Permalink:  ../174413522954.679.17007996269873921261@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/174413522954.679.17007996269873921261@wrigleys.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, solomon.medland@gmail.com
  Subject: Re: gen_random_uuid random source clarification
  In-Reply-To: <174413522954.679.17007996269873921261@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox