Re: [RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2023-01-02 Thread Alejandro Colomar
d it a bug): *  usr.bin/ssh/auth.c:     -  *cp = hashchars[arc4random_uniform(sizeof(hashchars) - 1)];     +  *cp = hashchars[arc4random_range(0, sizeof(hashchars) - 1)]; Reconsidering, this one is probably better just as arc4random_uniform(sizeof(hashchars)). I was also wrong here. I was confu

Re: [RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2022-12-31 Thread Ingo Schwarze
ch the old *_uniform() code. >> >> Below are the cases where I changed the behavior (I considered it a bug): >> >> * usr.bin/ssh/auth.c: >> >> - *cp = hashchars[arc4random_uniform(sizeof(hashchars) - 1)]; >> + *cp = hashchars[arc4ran

Re: [RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2022-12-31 Thread Alejandro Colomar
- *cp = hashchars[arc4random_uniform(sizeof(hashchars) - 1)]; + *cp = hashchars[arc4random_range(0, sizeof(hashchars) - 1)]; Reconsidering, this one is probably better just as arc4random_uniform(sizeof(hashchars)). * usr.sbin/ftp-proxy/ftp-proxy.c: - return (IPPORT_H

Re: [RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2022-12-31 Thread Ingo Schwarze
are rare. For example, array indices run from 0 to sizeof(array)-1, sizeof(array) points to the storage location beyond the last element, and C programmers are used to that. So the was arc4random_uniform(3) works feels familiar to C programmers, whereas your proposal of arc4random_range(3)

[RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2022-12-31 Thread Alejandro Colomar
vious ones (although I may be wrong) I fixed them. And in some cases where it was very unclear, I didn't touch the old *_uniform() code. Below are the cases where I changed the behavior (I considered it a bug): * usr.bin/ssh/auth.c: - *cp = hashchars[arc4random_uniform(sizeof(hash

Re: Picky, but much more efficient arc4random_uniform!

2022-05-21 Thread Theo de Raadt
We will not be using your code. End of story. Luke Small wrote: > Marc, all you all have to do is say is that you all refuse to provide it.

Re: Picky, but much more efficient arc4random_uniform!

2022-05-21 Thread Luke Small
Marc, all you all have to do is say is that you all refuse to provide it. I was asked to at least provide evidence for correctness. I did so; and I’d say I did a stellar job aside from getting some kind of statistical program. The following has an attached source code for my test (along with refe

Re: Picky, but much more efficient arc4random_uniform!

2022-05-21 Thread Marc Espie
On Sat, May 21, 2022 at 07:47:40AM -0500, Luke Small wrote: > Perhaps it was rude sending off list stuff to the list. Your email sounded > "less than friendly" and more of a professional challenge that you were > definitely in the works to produce; much like Damien Miller’s challenge to > prove cor

Re: Picky, but much more efficient arc4random_uniform!

2022-05-21 Thread Luke Small
: I worked in __builtin_clz(upperbound-1) mentioned earlier in the thread; instead of my binary search. It made the knuth sort simulation run even faster. arc4random_uniform now takes 130% of the time mine takes for a series of random numbers decreasing from 65535 to 2. “__builtin_clz((upperbound - 1

Re: Picky, but much more efficient arc4random_uniform!

2022-05-21 Thread Crystal Kolipe
On Fri, May 20, 2022 at 09:48:28PM -0500, Luke Small wrote: > Crystal: You can prove that for random, repetitive, correct, database > record name generation using small upperbounds, the demonstrated 1/3-1/2 > runtime isn???t worth it for an upperbound like 26 - 92 in a business context > that fight

Re: Picky, but much more efficient arc4random_uniform!

2022-05-20 Thread Luke Small
Crystal: You can prove that for random, repetitive, correct, database record name generation using small upperbounds, the demonstrated 1/3-1/2 runtime isn’t worth it for an upperbound like 26 - 92 in a business context that fights for every last millisecond? Bring it. Prove the correctness of wha

Re: Picky, but much more efficient arc4random_uniform!

2022-05-20 Thread Luke Small
wrote a highly dynamically allocated program to test at intervals of intervals to show at various stages to show the degree that the output remains random This is an example of some output: testing arc4random_uniform(5) and arc4random_uniform_small_unlocked(5): 256X

Fwd: Picky, but much more efficient arc4random_uniform!

2022-05-20 Thread Luke Small
wrote a highly dynamically allocated program to test at intervals of intervals to show at various stages to show the degree that the output remains random This is an example of some output: testing arc4random_uniform(5) and arc4random_uniform_small_unlocked(5): 256X

Re: Picky, but much more efficient arc4random_uniform!

2022-05-18 Thread Steffen Nurpmeso
Joerg Sonnenberger wrote in : |Am Wed, May 18, 2022 at 12:49:21PM +0200 schrieb Steffen Nurpmeso: |> What surprised me was that the Apple code requires more calls, and |> that today divisions and multiplications still matter. I think it |> was the Cyrix 166+ (or was it Athlon 1600+) where +,-

Re: Picky, but much more efficient arc4random_uniform!

2022-05-18 Thread Joerg Sonnenberger
Am Wed, May 18, 2022 at 12:49:21PM +0200 schrieb Steffen Nurpmeso: > What surprised me was that the Apple code requires more calls, and > that today divisions and multiplications still matter. I think it > was the Cyrix 166+ (or was it Athlon 1600+) where +,-,<<,>> was > one cycle, * was ten cycle

Re: Picky, but much more efficient arc4random_uniform!

2022-05-18 Thread Steffen Nurpmeso
Steffen Nurpmeso wrote in <20220518104921.sr0ht%stef...@sdaoden.eu>: ... |The web site that has been linked from the man from the country |that has an even much worse Earth Country Overshoot Day than |Germany and is almost en par with Australia or even USA (April |3rd, pooh; never again a Saa

Re: Picky, but much more efficient arc4random_uniform!

2022-05-18 Thread Steffen Nurpmeso
Philip Guenther wrote in : |On Tue, May 17, 2022 at 1:10 PM Steffen Nurpmeso \ |wrote: |> Joerg Sonnenberger wrote in |> : |>|Am Fri, May 13, 2022 at 09:43:26AM -0500 schrieb Luke Small: |>|> I made a couple new versions of a new kind of arc4random_uniform-like |> ..

Re: Picky, but much more efficient arc4random_uniform!

2022-05-18 Thread Otto Moerbeek
een in the web page were because of less rnd calls. That was a mistake. > What Theo said is 100% right - the cost is dominated by that of the > underlying RNG. If anyone wants a faster arc4random_uniform() then the > first place to look it at arc4random(). One more reason to keep the curre

Re: Picky, but much more efficient arc4random_uniform!

2022-05-18 Thread Damien Miller
of suceeding (at least for small upper_bounds) than mask-and-test, but my brain is too addled with a cold to calculate it :/ What Theo said is 100% right - the cost is dominated by that of the underlying RNG. If anyone wants a faster arc4random_uniform() then the first place to look it at arc4r

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Otto Moerbeek
On Wed, May 18, 2022 at 02:50:28PM +1000, Damien Miller wrote: > On Tue, 17 May 2022, Raimo Niskanen wrote: > > > Why reinvent the wheel? > > > > Here is a pretty good walkthrough of established methods: > > > > https://www.pcg-random.org/posts/bounded-rands.html > > > > It sounds to me as

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Theo de Raadt
> However, I don't see a speedup for either of the alternate approaches. Or maybe, just maybe, the underlying function (arc4random, which in the dominant case it is just a small chacha step) is so inexpensive relative to the proposed higher-level logic changes? So this is all tilting at windmills

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Damien Miller
On Tue, 17 May 2022, Raimo Niskanen wrote: > Why reinvent the wheel? > > Here is a pretty good walkthrough of established methods: > > https://www.pcg-random.org/posts/bounded-rands.html > > It sounds to me as if your suggested methor essentially is > "Bitmask with Rejection -- Apple's Meth

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Philip Guenther
On Tue, May 17, 2022 at 1:10 PM Steffen Nurpmeso wrote: > Joerg Sonnenberger wrote in > : > |Am Fri, May 13, 2022 at 09:43:26AM -0500 schrieb Luke Small: > |> I made a couple new versions of a new kind of arc4random_uniform-like > ... > |If your main use case is l

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Steffen Nurpmeso
Steffen Nurpmeso wrote in <20220517220924.xohqc%stef...@sdaoden.eu>: |Joerg Sonnenberger wrote in | : ||Am Fri, May 13, 2022 at 09:43:26AM -0500 schrieb Luke Small: ||> I made a couple new versions of a new kind of arc4random_uniform-like ... |0 bytes "do not occur", so

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Steffen Nurpmeso
Joerg Sonnenberger wrote in : |Am Fri, May 13, 2022 at 09:43:26AM -0500 schrieb Luke Small: |> I made a couple new versions of a new kind of arc4random_uniform-like ... |If your main use case is limiting the amount of cryptography when using |small bounds, there is a much simpler approach

Re: Picky, but much more efficient arc4random_uniform!

2022-05-17 Thread Joerg Sonnenberger
Am Fri, May 13, 2022 at 09:43:26AM -0500 schrieb Luke Small: > I made a couple new versions of a new kind of arc4random_uniform-like > function and some example functions which use them. Instead of having a > sufficiently large random number greater than the modulus, I pick a random >

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Damien Miller
getchar” doesn’t > “see also” to getchar_unlocked() by the way.) > > If you look at profiling with programs that call it a lot, > arc4random() inside arc4random_uniform() calls the expensive rekey > function which makes it take more time. That’s why I can get around > 2X-3X performance on

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Luke Small
that call it a lot, arc4random() inside arc4random_uniform() calls the expensive rekey function which makes it take more time. That’s why I can get around 2X-3X performance on a typical repetitive small upperbound loop and an extra 20% improvement on a single 65536 Knuth shuffle, loop even though my

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Stuart Henderson
how often are you even calling arc4random_uniform to consider it slow?!) if the consequence is not a crash but instead subtly broken randomness, how long do you think it's going to take to notice and report/fix it? even *very* broken randomness in widespread software distributions has been kno

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Luke Small
No...am I incorrect, especially on OpenBSD? Of course since you made such a remark, you seem like the kind of fellow that would put the nail in the coffin for spite. ...now I sound like an asshole. On Mon, May 16, 2022 at 4:00 PM Theo de Raadt wrote: > hey luke you know you sound like an assho

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Theo de Raadt
hey luke you know you sound like an asshole right? Luke Small wrote: > If you’re not running a threaded program, my function wouldn’t be “less > safe.” > > I’d imagine that 99% of programs aren’t multithreaded. > > On Mon, May 16, 2022 at 1:01 PM wrote: > > > > There is the specifically non

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Luke Small
If you’re not running a threaded program, my function wouldn’t be “less safe.” I’d imagine that 99% of programs aren’t multithreaded. On Mon, May 16, 2022 at 1:01 PM wrote: > > There is the specifically non-threadsafe call getchar_unlocked() on > OpenBSD > > which is presumably available for pe

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Steffen Nurpmeso
w upper bound then modulo will "remove a |> lot of randomization". For example if you have a program which |> generates Lotto numbers (1..49), then using _uniform() as it is will |> generate many duplicates. | |Wut. The *WHOLE POINT* of arc4random_uniform() is that it ha

Re: Picky, but much more efficient arc4random_uniform!

2022-05-16 Thread Sven M . Hallberg
Luke Small on Sun, May 15 2022: > The current implementation is nothing more than a naive arc4random() % > upper_bound which trashes initial arc4random() calls it doesn’t like, Yes, that's exactly what it is. > The whole transformation by modulus of perfectly decent random data > seems so awkward

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Luke Small
Yeah. It most likely won't go in. From past experience and advice, not necessarily just from a perceived lack of merit. However, many, if not all of the arguments are based upon non-facts and misconceptions from earlier submissions or just not understanding what the software is doing. The only re

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Luke Small
I’m not trying to be rude, but you don’t realize what’s going on here: uuu is a bitmask: ‘uuu’ (or (1 << bits)-1 ) in “ret = rand_holder & uuu;“ , only puts the lower ‘bit’ quantity of bits of rand_holder into ret, then it right shifts rand_holder afterward to trash them every time in the loop wh

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Mike Larkin
ets the parameters of being a value less than the upper bound. Much > > like > > > arc4random_buf(). > > > > > > If I use arc4random_uniform() repeatedly to create a random distribution > > of > > > say numbers less than 0x1000 or even something weird

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Luke Small
gt; like > > arc4random_buf(). > > > > If I use arc4random_uniform() repeatedly to create a random distribution > of > > say numbers less than 0x1000 or even something weird like 0x1300 will the > > random distribution be better with arc4random_uniform() or with mine

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Damien Miller
per bound. Much like > arc4random_buf(). > > If I use arc4random_uniform() repeatedly to create a random distribution of > say numbers less than 0x1000 or even something weird like 0x1300 will the > random distribution be better with arc4random_uniform() or with mine? For > 0x1000

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Damien Miller
beginning of another) 32 bit pseudorandom > cipher is "correct." You don't need to understand chacha20 to understand . arc4random_uniform() I certainly didn't when I wrote it. The underlying CSPRNG is irrelevant to how arc4random_unifo

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Luke Small
Do I really have to use specific terminology to make a point? I'm not educated enough on chacha20 enough to know whether, like I pointed out, whether choosing 5 bits from the middle of (or even from the tail end of one and the beginning of another) 32 bit pseudorandom cipher is "correct." ...corr

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Philip Guenther
On Sun, 15 May 2022, Luke Small wrote: > The current implementation is nothing more than a naive arc4random() % > upper_bound which trashes initial arc4random() calls it doesn’t like, then > transforms over a desired modulus. The whole transformation by modulus of > perfectly decent random data see

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Luke Small
; > But I don't think anybody else execpt Luke was talking about > "improving". The sole purpose of arc4random_uniform() is to give a > good implementation of a random number function in a specific range > using arc4random() as the source. This is needed because t

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Otto Moerbeek
t has already more or less made that point. > I think I can say we know here uniformity is only *one* of the desirable properties of a secure random generator. But I don't think anybody else execpt Luke was talking about "improving". The sole purpose of arc4random_uniform() is to give a good implementation of a random number function in a specific range using arc4random() as the source. This is needed because the naive implementation arc4random() % upper_bound is not uniform. -Otto

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Crystal Kolipe
On Sun, May 15, 2022 at 11:44:29AM +0200, Otto Moerbeek wrote: > On Sun, May 15, 2022 at 04:27:30AM -0500, Luke Small wrote: > > How did someone prove the current implementation was cryptographically > > sound? Did they run massive simulations which ran the gamut of the uint32_t > > range which dem

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Marc Espie
Random generators have been analyzed for years. Pick up "Concrete mathematics" by Don E. Knuth, read it, then come back with actual science.

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Otto Moerbeek
On Sun, May 15, 2022 at 04:27:30AM -0500, Luke Small wrote: > I have a feeling that making it threadsafe under any quantity of threads > and still perform is likely not feasible, but if I could; or if making a > nonthreadsafe variant was possible: > > Creating a mathematical proof that somehow is

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Luke Small
I have a feeling that making it threadsafe under any quantity of threads and still perform is likely not feasible, but if I could; or if making a nonthreadsafe variant was possible: Creating a mathematical proof that somehow is “simple and probably correct” enough, would be an impossible task even

Re: Picky, but much more efficient arc4random_uniform!

2022-05-15 Thread Otto Moerbeek
On Sun, May 15, 2022 at 01:12:28AM -0500, Luke Small wrote: > This is version 1, which I was pretty sure was secure. > > I revamped it with a few features and implanted the binary search for 'bit' > > in most cases, which aren't intentionally worst-case, it's pretty darned > fast! > > This is a

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Luke Small
r bound then modulo will "remove a > > lot of randomization". For example if you have a program which > > generates Lotto numbers (1..49), then using _uniform() as it is will > > generate many duplicates. > > Wut. The *WHOLE POINT* of arc4random_uniform() is th

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Otto Moerbeek
rst place? > > > > The problem is that if have a low upper bound then modulo will "remove a > > lot of randomization". For example if you have a program which > > generates Lotto numbers (1..49), then using _uniform() as it is will > > generate many dupli

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Philip Guenther
move a > lot of randomization". For example if you have a program which > generates Lotto numbers (1..49), then using _uniform() as it is will > generate many duplicates. Wut. The *WHOLE POINT* of arc4random_uniform() is that it has uniform distribution. Says right so in the

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Steffen Nurpmeso
Stuart Henderson wrote in : |On 2022/05/14 06:56, Luke Small wrote: |> If I use arc4random_uniform() repeatedly to create a random distribution \ |> of |> say numbers less than 0x1000 or even something weird like 0x1300 will the |> random distribution be better with arc4random_

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Matthew Martin
int main() { int results[3] = { 0, 0, 0 }; for (int i = 0; i < 10; i++) { results[arc4random_uniform_fast_simple(3)]++; } for (int i = 0; i < 3; i++) printf("%d: %d\n", i, results[i]); return 0; } % ./a.out 0: 24809 1: 50

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Stuart Henderson
On 2022/05/14 06:56, Luke Small wrote: > If I use arc4random_uniform() repeatedly to create a random distribution of > say numbers less than 0x1000 or even something weird like 0x1300 will the > random distribution be better with arc4random_uniform() or with mine? there's no p

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Luke Small
Look at my code. I don’t even use a modulus operator. I perform hit and miss with a random bitstream. How can I have a bias of something I don’t do? I return a bitstream which meets the parameters of being a value less than the upper bound. Much like arc4random_buf(). If I use arc4random_uniform

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Otto Moerbeek
On Sat, May 14, 2022 at 05:48:10AM -0500, Luke Small wrote: > arc4random_uniform_fast2 that I made, streams in data from arc4random() and > uses the datastream directly and uses it as a bit by bit right "sliding > window" in the last loop. arc4random_uniform() uses a modulus

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Luke Small
arc4random_uniform_fast2 that I made, streams in data from arc4random() and uses the datastream directly and uses it as a bit by bit right "sliding window" in the last loop. arc4random_uniform() uses a modulus which I is simple to implement, but I wonder how cryptographically sound o

Re: Picky, but much more efficient arc4random_uniform!

2022-05-13 Thread Otto Moerbeek
rrect. -Otto On Fri, May 13, 2022 at 09:43:26AM -0500, Luke Small wrote: > I made a couple new versions of a new kind of arc4random_uniform-like > function and some example functions which use them. Instead of having a > sufficiently large random number greater than the mod

Picky, but much more efficient arc4random_uniform!

2022-05-13 Thread Luke Small
I made a couple new versions of a new kind of arc4random_uniform-like function and some example functions which use them. Instead of having a sufficiently large random number greater than the modulus, I pick a random number using arc4random() from a bitfield where the length of the bitfield is

Re: [patch] Convert modulus to arc4random_uniform

2015-12-17 Thread Ted Unangst
Theo Buehler wrote: > I've now committed most of your diff, thanks once again. > > o I asked for further review on the kernel parts > o I'm going to skip hack for now > > Here's a patch for libc, based on the previous discussion. > I think this is easier to read and understand. No binary

Re: [patch] Convert modulus to arc4random_uniform

2015-12-17 Thread Theo Buehler
I've now committed most of your diff, thanks once again. o I asked for further review on the kernel parts o I'm going to skip hack for now Here's a patch for libc, based on the previous discussion. I think this is easier to read and understand. No binary change on amd64. ok? Index: lib

Re: [patch] Convert modulus to arc4random_uniform

2015-12-08 Thread Jérémie Courrèges-Anglas
Matthew Martin writes: > On Mon, Dec 07, 2015 at 09:33:47AM +0100, Theo Buehler wrote: >> I think some of these are ok, but I'm unsure about some of the others. >> Here are some of my concerns: >> >> - since arc4random_uniform can potentially loop indefinite

Re: [patch] Convert modulus to arc4random_uniform

2015-12-07 Thread Theo Buehler
> I'll look into hack tonight when I have more time. Honestly, I would prefer to leave hack as it is right now since it will take some work to repair it anyway. I would not want to add another layer of (potential) complications. > > > Index: lib/libc/stdlib/rand.c > > > =

Re: [patch] Convert modulus to arc4random_uniform

2015-12-07 Thread Matthew Martin
On Mon, Dec 07, 2015 at 09:33:47AM +0100, Theo Buehler wrote: > I think some of these are ok, but I'm unsure about some of the others. > Here are some of my concerns: > > - since arc4random_uniform can potentially loop indefinitely, it > might interfere with predictable tim

Re: [patch] Convert modulus to arc4random_uniform

2015-12-07 Thread Theo Buehler
On Mon, Dec 07, 2015 at 12:49:17AM -0600, Matthew Martin wrote: > > Theo's diff inspired me to look for other cases of modulo bias. The > following diff converts most modulus operations on a random number to > use arc4random_uniform or & as appropriate. I excluded &g

[patch] Convert modulus to arc4random_uniform

2015-12-06 Thread Matthew Martin
Theo's diff inspired me to look for other cases of modulo bias. The following diff converts most modulus operations on a random number to use arc4random_uniform or & as appropriate. I excluded lib/libsqlite3/src/resolve.c regress/lib/libevent/test-time.c usr.sbin/nsd/rrl.c usr.sbin/n

Re: Arc4random_uniform

2012-06-09 Thread Jorden Verwer
> I agree that simply "min = -upper_bound % upper_bound" should be > sufficient in all cases, since u_int32_t arithmetic is defined as > modulo 2**32 by the C standard, at least as of C99 and I think C89 > too. (Even if we supported any 1s-complement architectures, the > compiler would still need

Re: Arc4random_uniform

2012-06-08 Thread Matthew Dempsky
ion has for ranges that are not a power of 2. It works > correctly, but there are some considerations (transparency and chroot > jail compatibility) that have led me to look at alternative > implementations. This is where arc4random_uniform comes in. The way it > avoids biased results

Arc4random_uniform

2012-06-08 Thread Jorden Verwer
id the systematic bias a naive implementation has for ranges that are not a power of 2. It works correctly, but there are some considerations (transparency and chroot jail compatibility) that have led me to look at alternative implementations. This is where arc4random_uniform comes in. The way it avoids biased