public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Fernando Gont <fernando@gont.com.ar>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Libc-help <libc-help@sourceware.org>
Subject: Re: getentropy() vs. getrandom() vs. arc4random()
Date: Thu, 16 Jun 2022 14:12:51 -0300	[thread overview]
Message-ID: <04aecb69-30db-f20b-e392-bff8b3fddc67@gont.com.ar> (raw)
In-Reply-To: <AB83CF9E-34F7-4805-986F-9404C71B1986@linaro.org>

Hello, Adhemerval,

Thanks a lot for your response! In-line....

On 15/6/22 15:00, Adhemerval Zanella wrote:
[....]
>> Is this actually the case?
> 
> On glibc, getentropy and getrandom both end calling getrandom syscall
> although with different flags. The getentropy calls getrandom without
> any flag which in turn get entropy from /dev/urandom. The getrandom
> function allows us to specify which source you use through
> GRND_RANDOM flag.
> 
> Also, getentropy current has a hard limit of maximum of 256 bytes and
> it is not defined a cancelation entrypoint (so pthread_cancel does
> not act upon it).
> 
> So both functions drawn entropy direct from the kernel and with
> recent Linux random number development to unify both random and
> urandom the difference might ended up with just getentropy being a
> cancellation entrypoint.

One question here:
If getentropy() ends up calling getrandom() to read from /dev/urandom, 
my understanding is that it would never block. Is that correct?

However, the manpage for getentropy(3) says:
        A call to getentropy() may block if the system has just booted
        and the kernel has not yet collected enough randomness to
        initialize the entropy pool.  In this case, getentropy() will
        keep blocking even if a signal is handled, and will return only
        once the entropy pool has been initialized.

Am I missing something?


Aside, from what I read in the manual pages, getrandom()/getentropy() 
e.g. does not result in a uniform distribution. So, in other words, one 
can not really use them to comply with the requirements in RFC4086 
(i.e., as a cryptographically secure PRNG), but rather only use it as a 
building block to build such a CSPRNG?

Thanks!

Regards,
-- 
Fernando Gont
e-mail: fernando@gont.com.ar
PGP Fingerprint: 7809 84F5 322E 45C7 F1C9 3945 96EE A9EF D076 FFF1

  parent reply	other threads:[~2022-06-16 17:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 14:24 Fernando Gont
2022-06-15 18:00 ` Adhemerval Zanella
2022-06-15 18:03   ` Noah Goldstein
2022-06-15 20:29     ` Adhemerval Zanella
2022-06-16 17:12   ` Fernando Gont [this message]
2022-06-16 17:27     ` Yann Droneaud
2022-06-16 17:46       ` Adhemerval Zanella

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04aecb69-30db-f20b-e392-bff8b3fddc67@gont.com.ar \
    --to=fernando@gont.com.ar \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-help@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).