mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

#getrandom

2 posts1 participant0 posts today
Felix Palmen :freebsd: :c64:<p>I revisited that, AGAIN. Getting <a href="https://mastodon.bsd.cafe/tags/random" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>random</span></a> data in <a href="https://mastodon.bsd.cafe/tags/poser" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>poser</span></a> now has yet another fallback, in case we don't have <a href="https://mastodon.bsd.cafe/tags/arc4random" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>arc4random</span></a> and we also don't have <a href="https://mastodon.bsd.cafe/tags/getrandom" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>getrandom</span></a>: read from /dev/random and/or /dev/urandom, "old style" 🙈. Still better to try this before resorting to a simple little <a href="https://mastodon.bsd.cafe/tags/xorshift" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>xorshift</span></a>.</p><p>In the best case — arc4random found — this is still all the code of PSC_Random_bytes() 😆:</p><p> arc4random_buf(buf, count);<br> return count;</p><p><a href="https://zirias.github.io/poser/api/latest/class_p_s_c___random.html" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">zirias.github.io/poser/api/lat</span><span class="invisible">est/class_p_s_c___random.html</span></a></p><p><a href="https://mastodon.bsd.cafe/tags/C" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>C</span></a> <a href="https://mastodon.bsd.cafe/tags/coding" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>coding</span></a></p>
Felix Palmen :freebsd: :c64:<p>About the <a href="https://mastodon.bsd.cafe/tags/random" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>random</span></a> thingie ... I need random data in <a href="https://mastodon.bsd.cafe/tags/swad" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>swad</span></a> to generate unpredictable <a href="https://mastodon.bsd.cafe/tags/session" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>session</span></a> IDs.</p><p>I previously had an implementation trying the <a href="https://mastodon.bsd.cafe/tags/Linux" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Linux</span></a>-originating <a href="https://mastodon.bsd.cafe/tags/getrandom" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>getrandom</span></a> if available, with a fallback to a stupid internal <a href="https://mastodon.bsd.cafe/tags/xorshift" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>xorshift</span></a> <a href="https://mastodon.bsd.cafe/tags/PRNG" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>PRNG</span></a>, which could be disabled because it's obviously NOT cryptographically secure, and WAS disabled for the generation of session IDs.</p><p>Then I learned <a href="https://mastodon.bsd.cafe/tags/arc4random" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>arc4random</span></a> is available on many systems nowadays (<a href="https://mastodon.bsd.cafe/tags/FreeBSD" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>FreeBSD</span></a>, <a href="https://mastodon.bsd.cafe/tags/NetBSD" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>NetBSD</span></a>, even Linux with a recent-enough glibc), so I decided to add a compile check for it and replace the whole mess with nothing but an arc4random call IF it is available.</p><p>arc4random originates from <a href="https://mastodon.bsd.cafe/tags/OpenBSD" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>OpenBSD</span></a> and provides the only sane way to get cryptographically secure random data. It automatically and transparently (re-)seeds from OS entropy sources, but uses an internal CSPRNG most of the time (nowadays typically <a href="https://mastodon.bsd.cafe/tags/ChaCha20" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ChaCha20</span></a>, so it's a misnomer, but hey ...). It never fails, it never blocks. It just works. Awesome.</p>