--0016364d2e311169990495e401a0
Content-Type: text/plain; charset=ISO-8859-1
Dear Alex and bugs,
I just checked the source tree, and karc4random() does not use
read_random_unlimited().
Well, it does not use it directly ... I see a call to it elsewhere in:
/sys/libkern/arc4random.c
I sent a post into bugs@dragonflybsd.org a while back and I think it was
Matthew Dillon who replied
stating that there are numerous references to e.g. karc4random() strewn
about all over the source tree,
and it would be a good idea to update those references to use the superior
CSPRNG in:
/sys/kern/kern_nrandom.c
But it seems nobody has bothered to do that.
I'm just sending this bug report in, because the mmap randomisation is a new
commit, i.e. it is new
code, and since it is new code it should be using the best CSPRNG available
and not the old references
to karc4random().
Here is the relevant source snippet:
u_int32_t
116<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l116>karc4random(void)
117<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l117>{
118<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l118>
u_int32_t ret;
119<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l119>
struct timeval tv_now;
120<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l120>
121<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l121>
/* Initialize array if needed. */
122<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l122>
if (!arc4_initialized)
123<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l123>
arc4_init();
124<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l124>
125<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l125>
getmicrotime(&tv_now);
126<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l126>
if ((++arc4_numruns > ARC4_MAXRUNS) ||
127<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l127>
(tv_now.tv_sec > arc4_tv_nextreseed.tv_sec))
128<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l128>
{
129<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l129>
arc4_randomstir();
130<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l130>
}
131<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l131>
132<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l132>
ret = arc4_randbyte();
133<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l133>
ret |= arc4_randbyte() << 8;
134<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l134>
ret |= arc4_randbyte() << 16;
135<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l135>
ret |= arc4_randbyte() << 24;
136<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l136>
137<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l137>
return ret;
138<http://gitweb.dragonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l138>}
On 25 November 2010 16:32, Alex Hornung (via DragonFly issue tracker) <
bugs@crater.dragonflybsd.org> wrote:
>
> Alex Hornung <ahornung@gmail.com> added the comment:
>
> After a short check it uses exactly the same interface to get the
> 'randomness'
> (entropy?), read_random_unlimited().
>
> So what exactly do you mean? And why is karc4random no good?
>
> Cheers,
> Alex
>
> _____________________________________________________
> DragonFly issue tracker <bugs@lists.dragonflybsd.org>
> <http://bugs.dragonflybsd.org/issue1924>
> _____________________________________________________
>
--
Sincerely,
Robin Carey
--0016364d2e311169990495e401a0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Dear Alex and bugs,</div>
<div>=A0</div>
<div>I just checked the source tree, and karc4random() does not use read_ra=
ndom_unlimited().</div>
<div>=A0</div>
<div>Well, it does not use it directly ... I see a call to it elsewhere in:=
</div>
<div>=A0</div>
<div>/sys/libkern/arc4random.c</div>
<div>=A0</div>
<div>I sent a post into <a href=3D"mailto:bugs@dragonflybsd.org">bugs@drago=
nflybsd.org</a> a while back and I think it was Matthew Dillon who replied<=
/div>
<div>stating that there are numerous references to e.g. karc4random() strew=
n about all over the source tree,</div>
<div>and it would be a good idea to update those references to use the supe=
rior CSPRNG in:</div>
<div>=A0</div>
<div>/sys/kern/kern_nrandom.c</div>
<div>=A0</div>
<div>But it seems nobody has bothered to do that.</div>
<div>=A0</div>
<div>I'm just sending this bug report in, because the mmap randomisatio=
n is a new commit, i.e. it is new</div>
<div>code, and since it is new code it should be using the best CSPRNG avai=
lable and not the old references</div>
<div>to karc4random().</div>
<div>=A0</div>
<div>Here is the relevant source snippet:</div>
<div>=A0</div>
<div>u_int32_t=20
<div class=3D"pre"><a id=3D"l116" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l116">11=
6</a> karc4random(void)</div>
<div class=3D"pre"><a id=3D"l117" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l117">11=
7</a> {</div>
<div class=3D"pre"><a id=3D"l118" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l118">11=
8</a> =A0=A0=A0=A0=A0=A0=A0=A0u_int32_t=A0ret;</div>
<div class=3D"pre"><a id=3D"l119" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l119">11=
9</a> =A0=A0=A0=A0=A0=A0=A0=A0struct=A0timeval=A0tv_now;</div>
<div class=3D"pre"><a id=3D"l120" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l120">12=
0</a> </div>
<div class=3D"pre"><a id=3D"l121" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l121">12=
1</a> =A0=A0=A0=A0=A0=A0=A0=A0/*=A0Initialize=A0array=A0if=A0needed.=A0*/</=
div>
<div class=3D"pre"><a id=3D"l122" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l122">12=
2</a> =A0=A0=A0=A0=A0=A0=A0=A0if=A0(!arc4_initialized)</div>
<div class=3D"pre"><a id=3D"l123" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l123">12=
3</a> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0arc4_init();</div>
<div class=3D"pre"><a id=3D"l124" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l124">12=
4</a> </div>
<div class=3D"pre"><a id=3D"l125" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l125">12=
5</a> =A0=A0=A0=A0=A0=A0=A0=A0getmicrotime(&tv_now);</div>
<div class=3D"pre"><a id=3D"l126" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l126">12=
6</a> =A0=A0=A0=A0=A0=A0=A0=A0if=A0((++arc4_numruns=A0>=A0ARC4_MAXRUNS)=
=A0||=A0</div>
<div class=3D"pre"><a id=3D"l127" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l127">12=
7</a> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0(tv_now.tv_sec=A0>=A0arc4_tv_n=
extreseed.tv_sec))</div>
<div class=3D"pre"><a id=3D"l128" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l128">12=
8</a> =A0=A0=A0=A0=A0=A0=A0=A0{</div>
<div class=3D"pre"><a id=3D"l129" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l129">12=
9</a> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0arc4_randomstir();</d=
iv>
<div class=3D"pre"><a id=3D"l130" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l130">13=
0</a> =A0=A0=A0=A0=A0=A0=A0=A0}</div>
<div class=3D"pre"><a id=3D"l131" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l131">13=
1</a> </div>
<div class=3D"pre"><a id=3D"l132" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l132">13=
2</a> =A0=A0=A0=A0=A0=A0=A0=A0ret=A0=3D=A0arc4_randbyte();</div>
<div class=3D"pre"><a id=3D"l133" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l133">13=
3</a> =A0=A0=A0=A0=A0=A0=A0=A0ret=A0|=3D=A0arc4_randbyte()=A0<<=A08;<=
/div>
<div class=3D"pre"><a id=3D"l134" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l134">13=
4</a> =A0=A0=A0=A0=A0=A0=A0=A0ret=A0|=3D=A0arc4_randbyte()=A0<<=A016;=
</div>
<div class=3D"pre"><a id=3D"l135" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l135">13=
5</a> =A0=A0=A0=A0=A0=A0=A0=A0ret=A0|=3D=A0arc4_randbyte()=A0<<=A024;=
</div>
<div class=3D"pre"><a id=3D"l136" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l136">13=
6</a> </div>
<div class=3D"pre"><a id=3D"l137" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l137">13=
7</a> =A0=A0=A0=A0=A0=A0=A0=A0return=A0ret;</div>
<div class=3D"pre"><a id=3D"l138" class=3D"linenr" href=3D"http://gitweb.dr=
agonflybsd.org/dragonfly.git/blob/master:/sys/libkern/arc4random.c#l138">13=
8</a> }</div><br><br></div>
<div class=3D"gmail_quote">On 25 November 2010 16:32, Alex Hornung (via Dra=
gonFly issue tracker) <span dir=3D"ltr"><<a href=3D"mailto:bugs@crater.d=
ragonflybsd.org">bugs@crater.dragonflybsd.org</a>></span> wrote:<br>
<blockquote style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3D"gmail_quote">
<div class=3D"im"><br>Alex Hornung <<a href=3D"mailto:ahornung@gmail.com=
">ahornung@gmail.com</a>> added the comment:<br><br></div>After a short =
check it uses exactly the same interface to get the 'randomness'<br=
>
(entropy?), read_random_unlimited().<br><br>So what exactly do you mean? An=
d why is karc4random no good?<br><br>Cheers,<br><font color=3D"#888888">Ale=
x<br></font>
<div>
<div></div>
<div class=3D"h5"><br>_____________________________________________________=
<br>DragonFly issue tracker <<a href=3D"mailto:bugs@lists.dragonflybsd.o=
rg">bugs@lists.dragonflybsd.org</a>><br><<a href=3D"http://bugs.drago=
nflybsd.org/issue1924" target=3D"_blank">http://bugs.dragonflybsd.org/issue=
1924</a>><br>
_____________________________________________________<br></div></div></bloc=
kquote></div><br><br clear=3D"all"><br>-- <br>Sincerely,<br>Robin Carey<br>
--0016364d2e311169990495e401a0--