Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • $\begingroup$ There is an important thing to note here: /dev/urandom outputs random bytes, and you then use tr to delete (tr -d, delete) all characters in this output, except (-c, use complementary set) for the digits 0 through 9. So on average, assuming that your system uses UTF-8 (where those digits are represented by a single byte each), you are throwing away all but 10/256 of the bytes read, resulting in actually further processing only 3.9% of /dev/urandom's output. I don't know if this changes its security properties in any way, but suspect that it makes predicting the PRNG output harder. $\endgroup$ Commented Feb 7, 2017 at 12:24
  • $\begingroup$ Yes, a hard question, that's why we are trying to ask the community about it, maybe someone with a much greater knowledge about the topic could have a hint that these numbers, that are limited to given interval are truly STILL are CSPRN. Thanks for the addition about the "tr" command. $\endgroup$ Commented Feb 7, 2017 at 12:48
  • 1
    $\begingroup$ If you assume the original function to be a PRG: Yes it is, and it's quite easy to prove (assume an attacker for your scheme, and build an attacker for the original PRG from that). However, your solution is not exactly efficient (in the practical sense). You seem to throw away a lot of the output of the CSPRNG, which you could use instead: For some (long) output, repeatedly do integer division by $101$, and use the remainders of those divisions for your list after adding the offset $100$. $\endgroup$ Commented Feb 7, 2017 at 12:55
  • $\begingroup$ "integer division by 101, and use the remainders of those divisions for your list after adding the offset 100" - can you please explain this with little more detailed? $\endgroup$ Commented Feb 7, 2017 at 17:33
  • $\begingroup$ @PeterBill /dev/urandom outputs bytes (which can be treated as integer values in the range $[0,255]$: 0 through 255 inclusive). Call one such byte value when treated as an integer $c$. Now compute the remainder of the integer division $\frac{c}{101}$ (also known as $c$ modulo 101) -- this transforms the value to one in the range $[0,100]$, because the remainder of an integer division will always be 0 through one less than the divisor. Add 100 to the remainder of the division to bring the total ($100 + [0,100]$) to your desired range $[100,200]$. Clear enough? You can use >1 byte at a time. $\endgroup$ Commented Feb 7, 2017 at 21:03