|
|
Log in / Subscribe / Register

Depleting entropy

Depleting entropy

Posted Oct 10, 2026 23:04 UTC (Sat) by cesarb (subscriber, #6266)
In reply to: Weird dichotomy by mb
Parent article: Python's two modules for random numbers

> because entropy in a CSPRNG cannot be "depleted", no matter how much you read from it.

It actually *can*, in theory (if you had 2048 bits of unpredictability in your CSPRNG, and read 2048 bits from it, on average there's a single possible internal state which matches the output, so your entropy is zero), but the only way to exploit it is brute force. So as long as the entropy was large enough before the CSPRNG generated its first output, it should be fine even when the theoretical entropy is depleted.

(It's easier to see with smaller numbers: seed your CSPRNG with only 10 bits of entropy, use it to generate 10 bits of output, and you should be able to easily find the correct seed for that output by trying all 2**10 possible seeds. If you generated only 9 bits of output, there should be two possible seeds which match the output, so you have 1 bit of entropy left. With only 8 bits of output, there should be four possible seeds, so 2 bits of entropy left. And so on.)


to post comments

Depleting entropy

Posted Oct 11, 2026 9:13 UTC (Sun) by farnz (subscriber, #17727) [Link] (1 responses)

FWIW, if these attacks are of concern to you, there's /proc/sys/kernel/random/entropy_avail to read how much entropy the kernel estimates it has in the CSPRNG pool, and /proc/sys/kernel/random/poolsize to find out how large the pool is (both numbers in bits).

On my laptop, at the time of writing, they're both at 256 bits. A brute force attack has a worst case time of 2256 guesses to get the pool contents, and an average time of 2255 guesses. Assuming a guesser making guesses at a rate of 100 GHz, you'd need approximately 1056 guessers in parallel to bring the brute forcing time down to single digit centuries on average (or roughly a million guessers for each atom in the Earth).

For some applications, that might be unacceptably easy - for the things I do with my laptop, it's fine.

Depleting entropy

Posted Oct 12, 2026 13:32 UTC (Mon) by daroc (editor, #160859) [Link]

I believe that the reported size is capped or approximated in some way. Let me find a reference ...

It's not listed explicitly in this article about the merging of random and urandom, but you can see that the sysfs interfaces now report static numbers. The constant is defined here and then hooked up to sysfs here.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds