Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15027 > unrolled thread

Re: $RANDOM not Cryptographically secure pseudorandom number generator

Started byOle Tange <tange@gnu.org>
First post2019-01-02 02:29 +0100
Last post2019-01-02 12:01 +0100
Articles 2 — 2 participants

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: $RANDOM not Cryptographically secure pseudorandom number generator Ole Tange <tange@gnu.org> - 2019-01-02 02:29 +0100
    Re: $RANDOM not Cryptographically secure pseudorandom number generator Luuk <luuk@invalid.lan> - 2019-01-02 12:01 +0100

#15027 — Re: $RANDOM not Cryptographically secure pseudorandom number generator

FromOle Tange <tange@gnu.org>
Date2019-01-02 02:29 +0100
SubjectRe: $RANDOM not Cryptographically secure pseudorandom number generator
Message-ID<mailman.6674.1546392582.1284.bug-bash@gnu.org>
On Mon, Dec 31, 2018 at 8:12 PM Chet Ramey <chet.ramey@case.edu> wrote:
:
> Thanks for the patch. I'll take a look after I release bash-5.0. One
> question: can you reproduce the same random sequence by using the same
> seed? That's for backwards compatibility, even if the sequences themselves
> differ.

Yes. Seeding with a value will give the same sequence:

$ RANDOM=4; echo $RANDOM $RANDOM
21584 22135

$ RANDOM=4; echo $RANDOM $RANDOM
21584 22135

For backwards compatibility integers are supported, but they are
really parsed as strings. Strings make it easier to seed with more
than 64-bits:

RANDOM=`cat GPLv3.txt`

So these give the same value on 4.4.23, but differs with the patch applied:

RANDOM=$(echo 2^64 | bc );echo $RANDOM
RANDOM=$(echo 2^65 | bc );echo $RANDOM

RANDOM="foo"; echo $RANDOM
RANDOM="bar"; echo $RANDOM

RANDOM=2; echo $RANDOM
RANDOM=" 2.0"; echo $RANDOM
RANDOM=" 2.0noise"; echo $RANDOM


/Ole

[toc] | [next] | [standalone]


#15032

FromLuuk <luuk@invalid.lan>
Date2019-01-02 12:01 +0100
Message-ID<mailman.6692.1546436927.1284.bug-bash@gnu.org>
In reply to#15027
On 2-1-2019 02:29, Ole Tange wrote:
> On Mon, Dec 31, 2018 at 8:12 PM Chet Ramey <chet.ramey@case.edu> wrote:
> :
>> Thanks for the patch. I'll take a look after I release bash-5.0. One
>> question: can you reproduce the same random sequence by using the same
>> seed? That's for backwards compatibility, even if the sequences themselves
>> differ.
> 
> Yes. Seeding with a value will give the same sequence:
> 
> $ RANDOM=4; echo $RANDOM $RANDOM
> 21584 22135
> 
> $ RANDOM=4; echo $RANDOM $RANDOM
> 21584 22135
> 

But not across systems:
luuk@WINDOWS:/mnt/c/Windows/System32$ RANDOM=4;echo $RANDOM $RANDOM
1692 27588
luuk@WINDOWS:/mnt/c/Windows/System32$ RANDOM=4;echo $RANDOM $RANDOM
1692 27588

luuk@opensuse:~> RANDOM=4; echo $RANDOM $RANDOM
32221 21043
luuk@opensuse:~> RANDOM=4; echo $RANDOM $RANDOM
32221 21043

[toc] | [prev] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web