Entropy is a property of a physical process or a state of knowledge, not a property of a deterministic function such as a stream cipher, or of a value such as a specific password.
A stream cipher—a deterministic mathematical function—is considered secure if an adversary who does not know the $k$-bit key chosen uniformly at random and can only do a limited amount of computation, but has seen some sequence of output from the stream cipher, can't guess the next bit with probability better than $1/2 + n/2^k$, where $n$ is the number of times they can evaluate the stream cipher within their computational limits.
The adversary's state of knowledge has min-entropy $k$ bits in this case: the key is one of $2^k$ possibilities, and each possibility has equal probability $1/2^k$ as far as the adversary knows. Without knowing any cryptanalytic technique to break the stream cipher, the adversary's best strategy is to guess the key correctly with $1/2^k$ chance of being right, compute the stream cipher, check to see whether it produces the observed outputs, and if so guess the next bit it produces; if the key is wrong, the adversary's guess for the next bit is no better than a fair coin toss.
This strategy sounds stupid. But statistical tests of random number generators such as dieharder use an even stupider strategy than what the adversary's best strategy is in the generic case: they hypothesize some generating process with simple deviations from uniform, such as a different frequencies of one bits and zero bits, and typically perform a frequentist statistical test for the hypothesis. These tests are stupider because unlike the best generic attack on a stream cipher, they are written without even the generic knowledge that the output is produced by a stream cipher with an unknown key that a smarter adversary could evaluate with any candidate key.
Sometimes cryptanalysts find better attacks. For example, within days of the original publication of RC4 on sci.crypt, Bob Jenkins reported, in a post dated 1994-09-16 with message-id [email protected]
, a technique to predict the next bit with significantly better probability using a computation that was possible to do on a 1994-era laptop—thus breaking RC4, which would go on to be used in practice for two decades before anyone in a position to make decisions decided that it was a bad idea for TLS. But seldom is a seriously proposed stream cipher so hopelessly broken that generic statistical tests for random number generators like dieharder make a better attack.
In cryptography engineering, it is expedient to treat every $\ell$-bit output of a secure stream cipher under a key not known to an adversary as if the adversary's knowledge of it had, a priori, at most $\min(\ell, k)$ bits of min-entropy independently. This abuse of language is justified because a real computationally bounded adversary's best guess about the stream cipher output is, in practice, essentially the same as if it really were $\min(\ell, k)$.
We usually choose $k$ so that $n/2^k$ is negligible for any realistic values of $n$—e.g., if we pick $k = 100$, then we probably thwart any adversary whose energy budget for computation isn't enough to boil Lake Geneva. Standard cryptography errs on the side of safety by picking $k \geq 128$. Sensible cryptography also avoids multi-target attacks and potential future quantum cryptanalysis by picking $k \geq 256$.
output has a close to maximum entropy value
- what do you mean byentropy value
? And how are you measuring it? $\endgroup$