Thread (34 messages) 34 messages, 7 authors, 2021-11-22

Re: [PATCH 1/2] wrapper: add a helper to generate numbers from a CSPRNG

From: brian m. carlson <hidden>
Date: 2021-11-18 22:16:32

On 2021-11-18 at 07:19:08, Junio C Hamano wrote:
Presumably csprn_bytes() grabs bytes from underlying mechanism in
smaller chunk, but would not return until it fills the buffer---ah,
your "make sure our buffer handling is correct" is primarily about
the check that we get full 1k bytes in the loop?  We ask 1k chunk 64
times and we must get full 1k chunk every time?
Yes, that's what we'd expect to happen.
What I was wondering about was the other half of the check, ensuring
all buckets[] are painted that gave us the cute 10^-100 math.
Say the buffer handling is incorrect and we read only a few bytes
instead of the full 1 KiB.  Then we'll end up filling only some of the
buckets, and the check will fail much of the time, because we won't get
sufficient number of random bytes to fill all the buckets.

The check is that we got enough data that looks like random bytes over
the course of our requests.
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help