25

Is there a tool available for Linux systems that can measure the "quality" of entropy on the system?

I know how to count the entropy:

cat /proc/sys/kernel/random/entropy_avail

And I know that some systems have "good" sources of entropy (hardware entropy keys), and some don't (virtual machines).

But is there a tool that can provide a metric as to the "quality" of the entropy on the system?

migrated from crypto.stackexchange.com Feb 15 '12 at 19:03

This question came from our site for software developers, mathematicians and others interested in cryptography.

  • Im interested, Why would you want to calculate entropy of a system? – whoami Feb 16 '12 at 11:45
25

http://www.fourmilab.ch/random/ works for me.

sudo apt-get install ent
head -c 1M /dev/urandom > /tmp/out
ent /tmp/out
  • 4
    Cool tool. You can check a device in just one command with dd if=/dev/urandom bs=1M count=1 | ent – l0b0 Jun 13 '13 at 15:22
  • 7
    Note that running an entropy estimator on /dev/urandom is completely useless. /dev/urandom is the output of a crypto-quality PRNG, and an entropy estimator will always give full marks to any semi-decent PRNG. You need to run the entropy estimator on the unconditioned entropy source, which Linux doesn't expose outside the kernel. Cc @DustinKirkland – Gilles Mar 28 '15 at 20:44
  • @Gilles there is no way? – Felipe Nov 9 '15 at 21:24
  • @FelipeMicaroniLalli No way to do what? Estimate the entropy from the output of /dev/urandom? Yes. The output of /dev/urandom (or /dev/random, same issue) is the output of a crypto-quality PRNG, and that will always have top marks for entropy estimation. If you want to estimate the entropy, you need to dig into the kernel, figure out what it uses for entropy sources, and measure for a VERY long time. – Gilles Nov 9 '15 at 21:43
  • 1
    @FelipeMicaroniLalli No, the entropy source does not affect the PRNG in a way that can be measured. This is rather off-topic for Unix & Linux but I know I've seen it discussed on Cryptography, try searching the tags [entropy] and [randomness] there. – Gilles Nov 9 '15 at 22:07
6

"ent" is an excellent command line tool for a simple and quick estimation of entropy.

I've used it to help learn how linear congruential generators work. But if by "measuring entropy" you mean "measuring randomness"... the problem becomes more complex.

For a more robust test of randomness you should checkout the dieharder test suite: http://www.phy.duke.edu/~rgb/General/dieharder.php

It is not as easy to use as "ent" but it is far more rigorous.

For more in depth study, "Cipher's by Ritter" also provides a good selection of links:

http://www.ciphersbyritter.com/NETLINKS.HTM#RandomnessLinks

3

Tools can only ever give you an upper bound on the entropy. For most uses, in particular security related uses you're more interested in a lower bound.

Calculating the entropy of an arbitrary file is mathematically impossible, so there can be no tool that can do it.

I can easily write a file generator that generates very low entropy files, but will still pass your entropy tests. Just use a crypto PRNG with a small seed.

0

You can use Binwalk with the -E option:

# binwalk -E data

DECIMAL       HEXADECIMAL     ENTROPY
--------------------------------------------------------------------------------
0             0x0             Falling entropy edge (0.000000)
2443264       0x254800        Rising entropy edge (0.988510)

You can get the source code from its GitHub repository.

0

ncomputers.org/entropyarray performs a faster entropy test than ent with 16, 32, 64, 128, 256 and 512 bits serial correlation tests.

with ncomputers.org/entropy tool, you may also perform visual frequency and distribution tests, plotting the outputs entropy.freq and entropy.gaus

as an example you may perform an online test of up to 1GB using servertest.online/entropytest

entropy.freq entropy.gaus

-5

I think you are looking for:

cat /proc/sys/kernel/random/entropy_avail
  • Sorry, no, I'm well aware of entropy_avail. I'm trying to measure the quality of that entropy. – Dustin Kirkland Feb 15 '12 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.