Message ID | 20221010230613.1076905-1-Jason@zx2c4.com |
---|---|
Headers | show |
Series | treewide cleanup of random integer usage | expand |
On Mon, 10 Oct 2022 17:06:06 -0600 Jason A. Donenfeld wrote: > - If you want a secure or an insecure random u64, use get_random_u64(). > - If you want a secure or an insecure random u32, use get_random_u32(). > * The old function prandom_u32() has been deprecated for a while now > and is just a wrapper around get_random_u32(). Same for > get_random_int(). > - If you want a secure or an insecure random u16, use get_random_u16(). > - If you want a secure or an insecure random u8, use get_random_u8(). > - If you want secure or insecure random bytes, use get_random_bytes(). > * The old function prandom_bytes() has been deprecated for a while now > and has long been a wrapper around get_random_bytes(). > - If you want a non-uniform random u32, u16, or u8 bounded by a certain > open interval maximum, use prandom_u32_max(). > * I say "non-uniform", because it doesn't do any rejection sampling or > divisions. Hence, it stays within the prandom_* namespace. Acked-by: Jakub Kicinski <kuba@kernel.org>
Am Donnerstag, 13. Oktober 2022, 12:16:35 CEST schrieb Florian Westphal: > Rolf Eike Beer <eike-kernel@sf-tec.de> wrote: > > Florian, can you comment and maybe fix it? > > Can't comment, do not remember -- this was 5 years ago. > > > Or you wanted to move the variable before the loop and keep the random > > state between the loops and only reseed when all '1' bits have been > > consumed. > Probably. No clue, best to NOT change it to not block Jasons series and > then just simplify this and remove all the useless shifts. Sure. Jason, just in case you are going to do a v7 this could move to u8 then.
On Thu, Oct 13, 2022 at 01:40:40PM +0200, Rolf Eike Beer wrote: > Am Donnerstag, 13. Oktober 2022, 12:16:35 CEST schrieb Florian Westphal: > > Rolf Eike Beer <eike-kernel@sf-tec.de> wrote: > > > Florian, can you comment and maybe fix it? > > > > Can't comment, do not remember -- this was 5 years ago. > > > > > Or you wanted to move the variable before the loop and keep the random > > > state between the loops and only reseed when all '1' bits have been > > > consumed. > > Probably. No clue, best to NOT change it to not block Jasons series and > > then just simplify this and remove all the useless shifts. > > Sure. Jason, just in case you are going to do a v7 this could move to u8 then. Indeed I think this is one to send individually to netdev@ once the tree opens there for 6.2. Jason