4 ms·
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
by Taniwha 8y ago
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)
- canhascodez 8y agoRuby 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
- cuspycode 8y agoDo you have a gist or similar link for this code? Copy & paste doesn't work due to indentation issues.
- acqq 8y agoGPL 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.
- nothrabannosir 8y ago(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/cc0/ https://creativecommons.org/share-your-work/public-domain/cc... (But, IMO, nothing wrong with publicizing use of GPL 3! :) thanks either way to both)
- semi-extrinsic 8y agoI 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.
- Taniwha 8y agosorry, 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
- paavoova 8y agoentropy_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?
- Taniwha 8y agoremember 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
- tptacek 8y agoWhat problem does this solve?