8
$\begingroup$

As per resources given below, after adding the bits to entropy pool, the Linux RNG estimates the amount of entropy for "credit_entropy_bits" function. It is estimating the amount of entropy of an event as a function of its timing. Initially, the estimator calculates the jiffies differences on three levels. Then, estimator takes the minimum of the differences absolute values and finally, it assigns it a value between 0 and 11.

I am using a TRNG for supplying entropy to Linux entropy pool. The output of TRNG is 160 bits i.e. the entropy of source is 160 bits. In case of TRNG, What will be value of entropy for "credit_entropy_bits" function ? Will it be 160 bits ?

I have pointed the "rng_current" to "rng-caam". I am running "rngd" with r option i.e. "rngd -r /dev/hwrng".

$\endgroup$
4
  • $\begingroup$ How are you supplying the entropy? By writing to /dev/random? That does not increase the entropy count at all. You can increase it (as a privileged user) by using the RNDADDENTROPY ioctl. $\endgroup$
    – otus
    Commented Aug 1, 2016 at 7:42
  • $\begingroup$ @otus , I have pointed the "rng_current" to "rng-caam". I am running "rngd" with r option i.e. "rngd -r /dev/hwrng". Killing and re-running rngd with trace program i.e. "strace rngd -r /dev/hwrng" confirms that it is reading/getting 8 bytes. $\endgroup$ Commented Aug 1, 2016 at 8:00
  • 1
    $\begingroup$ If you have a TRNG, why do you want to obfuscate it's output by injecting the entropy into the /dev/random pool? Why not use the entropy directly? $\endgroup$
    – Paul Uszak
    Commented Aug 15, 2016 at 10:58
  • $\begingroup$ @Paul Uszak , It was the build in function of chip. I am already looking at directly using the TRNG's output. $\endgroup$ Commented Aug 16, 2016 at 9:34

1 Answer 1

5
$\begingroup$

When you are adding entropy from outside the kernel, the kernel's entropy estimation functions are not used. Instead the entropy count is either not updated (e.g. if you just write data to /dev/random) or is updated according to the entropy count given to the kernel (e.g. through the RNDADDENTROPY ioctl).

Since you are using rngd, it will run some tests and assuming they pass ask the kernel to credit the entropy count with the full size of the data that was mixed in. I.e. 160 bits if you had 160 bits of data from the TRNG.

$\endgroup$
6
  • $\begingroup$ Thanks for the clarification. The output of TRNG is 160 bits which is being re-seeded after 1 million bits (2^20). rngd is passing data in group of 512 bits. The credit the entropy should still be160 bits or 512 bits ? $\endgroup$ Commented Aug 1, 2016 at 9:24
  • 1
    $\begingroup$ @user2363993 if rngd passes in 512 bits, entropy count should increase by 512 bits. $\endgroup$
    – otus
    Commented Aug 1, 2016 at 9:26
  • $\begingroup$ so this entropy count is w.r.t to kernel entropy pool and it is not w.r.t source entropy which is 160 bits ? Can you please also refer me to some book or paper so that I can further clarify my understanding of kernel entropy. Thanks, $\endgroup$ Commented Aug 1, 2016 at 9:31
  • 1
    $\begingroup$ @user2363993, the kernel has no way of knowing the source entropy, so it relies on what it is told by (in this case) rngd. If you know the device only generates 160 bits at a time, you can tell rngd to use only that much with -s 20, but it will credit the full amount each time it mixes in entropy. $\endgroup$
    – otus
    Commented Aug 1, 2016 at 9:45
  • 1
    $\begingroup$ Regarding papers/books, I don't know of any good ones. Any that exist may be/become quickly outdated – e.g. the next kernel version will overhaul how /dev/urandom works. $\endgroup$
    – otus
    Commented Aug 1, 2016 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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