<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:85811302;
        mso-list-type:hybrid;
        mso-list-template-ids:-221589944 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Peter,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>You are absolutely correct.  There is a lot that can be done to improve gathering entropy on cryptography.  We have discussed this a number of times.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>At 3DICC use the croquet plugin and #gatherEntropy: by Andreas.  That works great for us.  We have very specific random needs including replicated randoms.<br><br><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>it uses <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>/dev/urandom on linux and MacOS and<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>SystemFunction036 in Advapi32.dll on windows<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>In general you hit on the issue.  We should have an implementation for #gatherEntropy: in crypto.  It should fire off for seeding PRNG during startup, The makeSeed in UUIDGenerator seems insufficient unless you are on linux.  <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>It queries the sound system and then defaults to a time calculation.  How good that is for you really depends on your specific needs for random.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>do we really want to have global fixed seed?  <o:p></o:p></p><p class=MsoListParagraph>[Ron Teitelbaum] No<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>Random new should actually setup a usable seed so I don't need to first run it N times before I can use the value<o:p></o:p></p><p class=MsoListParagraph>[Ron Teitelbaum] Yes it should call gatherEntropy to seed the PRNG<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>3)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>Should we switch to what UUIDGenerator is using… reading /dev/urandom for the initial seed setup?<o:p></o:p></p><p class=MsoListParagraph>[Ron Teitelbaum] No we should either implement a proper gatherEntropy method or use SystemFunction036 in Advapi32.dll for windows like we do in CroquetPlugin.  Chris previously pointed out the gatherEntropy requirements from <a href="http://www.amazon.com/Practical-Cryptography-Niels-Ferguson/dp/0471223573/ref=sr_1_1?ie=UTF8&amp;qid=1385152889&amp;sr=8-1&amp;keywords=schneier+practical+cryptography">http://www.amazon.com/Practical-Cryptography-Niels-Ferguson/dp/0471223573/ref=sr_1_1?ie=UTF8&amp;qid=1385152889&amp;sr=8-1&amp;keywords=schneier+practical+cryptography</a> that would be a good place to start or we should support the croquet plugin method gatherEntropy in cryptography.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>All the best,<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Ron Teitelbaum<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> Pharo-dev [mailto:pharo-dev-bounces@lists.pharo.org] <b>On Behalf Of </b>Robert Withers<br><b>Sent:</b> Wednesday, May 18, 2016 7:26 PM<br><b>To:</b> Peter Uhnák; Pharo Development List; Cryptography Mailing List<br><b>Subject:</b> Re: [Pharo-dev] Random is not random at startup<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Thanks for cc-ing me. I don't have much exposure to random, so I am cc-ing the Cryptography list, in hopes they might help. This doesn't very random, you're right. Here were Peter's questions:<o:p></o:p></p><div><p class=MsoNormal>My questions:<o:p></o:p></p></div><div><p class=MsoNormal>1) do we really want to have global fixed seed?<o:p></o:p></p></div><div><p class=MsoNormal>2) Random new should actually setup a usable seed so I don't need to first run it N times before I can use the value<o:p></o:p></p></div><div><p class=MsoNormal>3) Should we switch to what UUIDGenerator is using… reading /dev/urandom for the initial seed setup?<o:p></o:p></p></div><div><p class=MsoNormal>Rob<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On 05/18/2016 07:05 PM, Peter Uhnák wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><p class=MsoNormal>Hi,<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>(cc-ing Robert Withers as he seems to be working with cryptography and security... as this seems related and may have some implications, but I am likely wrong about the implications)<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>yesterday I've encountered a very surprising behavior<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>I executed the same script `10 atRandom` on the same image without saving it and got the same output:<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><div><p class=MsoNormal>while true; do<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; &nbsp; &nbsp; &nbsp; pharo-vm --nodisplay latest.image --no-default-preferences eval '10 atRandom'<o:p></o:p></p></div><div><p class=MsoNormal>done<o:p></o:p></p></div><div><p class=MsoNormal>10<o:p></o:p></p></div><div><p class=MsoNormal>10<o:p></o:p></p></div><div><p class=MsoNormal>10<o:p></o:p></p></div><div><p class=MsoNormal>10<o:p></o:p></p></div><div><p class=MsoNormal>10<o:p></o:p></p></div><div><p class=MsoNormal>10<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Not so random… not random at all.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Apparently the default random generator uses SharedRandom pool, that is initialized only once… so every time you start an image you get the EXACT same random seed... I think this is stupid, and I am not sure what are the security implications of this (e.g. when opening an SSL connection… having fixed world-wide initial seed seems like an awful, awful idea), but whatever…<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>So instead I tried to explicitly specify the Random generator… which I can do<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><div><p class=MsoNormal>while true; do<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; &nbsp; &nbsp; &nbsp; pharo-vm --nodisplay latest.image --no-default-preferences eval '10 atRandom: Random new'<o:p></o:p></p></div><div><p class=MsoNormal>done<o:p></o:p></p></div><div><p class=MsoNormal>5<o:p></o:p></p></div><div><p class=MsoNormal>5<o:p></o:p></p></div><div><p class=MsoNormal>5<o:p></o:p></p></div><div><p class=MsoNormal>5<o:p></o:p></p></div><div><p class=MsoNormal>5<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Still not random… what?<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><div><p class=MsoNormal>while true; do<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; &nbsp; &nbsp; &nbsp; pharo-vm --nodisplay latest.image --no-default-preferences eval 'Random new instVarNamed: #seed'<o:p></o:p></p></div><div><p class=MsoNormal>done<o:p></o:p></p></div><div><p class=MsoNormal>426306047<o:p></o:p></p></div><div><p class=MsoNormal>426305545<o:p></o:p></p></div><div><p class=MsoNormal>426305546<o:p></o:p></p></div><div><p class=MsoNormal>426306010<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>So the seed is different but thanks to the magic of masking the seed, I always get the same first several bits… thus the same result for small numbers.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>So if I actually want what seems like a random value… I have to at least once run the generator…<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><div><p class=MsoNormal>while true; do<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp; &nbsp; &nbsp; &nbsp; pharo-vm --nodisplay latest.image --no-default-preferences eval '10 atRandom: (Random new next; yourself)'<o:p></o:p></p></div><div><p class=MsoNormal>done<o:p></o:p></p></div><div><p class=MsoNormal>7<o:p></o:p></p></div><div><p class=MsoNormal>3<o:p></o:p></p></div><div><p class=MsoNormal>4<o:p></o:p></p></div><div><p class=MsoNormal>9<o:p></o:p></p></div><div><p class=MsoNormal>6<o:p></o:p></p></div><div><p class=MsoNormal>7<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Once I start to use it the properties of the algo kick in so it's pseudo-random… but I need to run it once to initialize it, which is wtf.<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>My questions:<o:p></o:p></p></div><div><p class=MsoNormal>1) do we really want to have global fixed seed?<o:p></o:p></p></div><div><p class=MsoNormal>2) Random new should actually setup a usable seed so I don't need to first run it N times before I can use the value<o:p></o:p></p></div><div><p class=MsoNormal>3) Should we switch to what UUIDGenerator is using… reading /dev/urandom for the initial seed setup?<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Peter<o:p></o:p></p></div></div></blockquote><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></div></body></html>