News for hackers. Stuff that matters.
Re:Myths about /dev/urandom (2014) by Taniwha on Saturday August 18, 2018 @12:10AM (#17786808)
BTW - a tiny bit of python to keep /dev/urandom fed post 4.8 - useful if you have a hardware RNG (either an external one or the one in your CPU):

  #! /usr/bin/python
  #
  #       OneRNG /dev/urandom tickler
  #       (C) Copyright Paul Campbell Moonbase Otago 2018
  #       Released under a GPL 3.0 license
  #
  import time

  with open("/dev/random", 'rb') as r:
          while True:
                  with 
  open("/proc/sys/kernel/random/entropy_avail", 'r') as e:  
                          iv = e.read()
                          print(iv)
                          if iv > 1500:
                                  x= r.read(1000)
                          e.close()
                  time.sleep(1)
Re:Myths about /dev/urandom (2014) by acqq on Saturday August 18, 2018 @03:36AM (#17787343)
GPL 3.0 for a few obvious lines seems to be really an unfitting license.

Non-licensed English language version, containing the same information:

Once per second, read /proc/sys/kernel/random/entropy_avail and if the resulting number is more than 1500 perform a read of 1000 bytes from /dev/random.

Re:Myths about /dev/urandom (2014) by nothrabannosir on Saturday August 18, 2018 @08:08AM (#17788113)
(this is more of a tangential licensing PSA, since we're on the subject)

Not licensing something is, ironically, restrictive. If you want to release to public domain (or equivalent), you have to explicitly mention that. E.g. by licensing under CC0.

Otherwise, default copyright and "all rights reserved" applies.

https://creativecommons.org/share-your-work/public-domain/cc...

(But, IMO, nothing wrong with publicizing use of GPL 3! :) thanks either way to both)

Re:Myths about /dev/urandom (2014) by semi-extrinsic on Saturday August 18, 2018 @09:22AM (#17788330)
I think GP is getting at something else. As the length/complexity of the code goes to zero, the copyright and "all rights reserved" vanishes; this is well established, or else we'd all have to license "Hello world" examples from Kernighan and Ritchie's book.

If someone writes the same one-sentence pseudocode as GP in a book or blogpost, nobody could reasonably claim that an implementation would fall under the copyright of that book. And I think you'd be very hard pressed to argue it's copyrightable just because someone typed it out into real code.

Re:Myths about /dev/urandom (2014) by Taniwha on Sunday August 19, 2018 @12:50AM (#17792667)
sorry, just grabbed my standard disclaimer, can't release code without copyrighting it first. As others have pointed out it's trivial to reimplement in the language of your choice go for it
Re:Myths about /dev/urandom (2014) by canhascodez on Saturday August 18, 2018 @02:16AM (#17787154)
Ruby version:

  #!/usr/bin/env ruby

  source = File.open('/dev/random', 'rb')

  loop do
    source.read(1000) unless File.read('/proc/sys/kernel/random/entropy_avail').to_i < 1500
    sleep 1
  end
Re:Myths about /dev/urandom (2014) by cuspycode on Saturday August 18, 2018 @02:20AM (#17787162)
Do you have a gist or similar link for this code? Copy & paste doesn't work due to indentation issues.
Re:Myths about /dev/urandom (2014) by tptacek on Saturday August 18, 2018 @12:47PM (#17789310)
What problem does this solve?
Re:Myths about /dev/urandom (2014) by paavoova on Saturday August 18, 2018 @04:43AM (#17787528)
entropy_avail returns bits of entropy to a maximum of 4096(?), but this reads 1000 bytes. Why check if it's greater than 1500 if you're going to use it all anyway? Am I missing something here?
Re:Myths about /dev/urandom (2014) by Taniwha on Sunday August 19, 2018 @02:34AM (#17792915)
remember that this is for people with external entropy sources, the kernel entropy will refill fast. 1500 is more a measure of "is /dev/random busy at the moment" if it is then it's pulling data from from the external entropy source and /dev/urandom is essentially already being fed with more entropy

The missing mechanism we're trying to emulate used to essentially read N bytes (whatever user space happened to want at the time) every M seconds our experience has been that that can be way more than 1000 bytes, but reduce it if you like