News for hackers. Stuff that matters.
Re:Convert standard Geiger counter to RNG by stcredzero on Monday November 13, 2023 @04:22PM (#38255591)
Not a crypto expert, but here's my understanding of the problem. The system just has to gain bits of entropy from the physical randomness source faster than the hardware and software leaks them. So one could feed the entropy into a stream cipher with the right characteristics.

What if one just counted the number of clicks, modulo 2? Then one could take the output of ChaCha20 or Salsa20 stream ciphers and every N outputs of the stream cipher, increment the stream cipher's counter bits 0 or 1 times. One would also have to re-key the stream cipher periodically. (Maybe after gathering 128 bits of output from the Geiger counter in another register, then using that.)

Re:Convert standard Geiger counter to RNG by lxgr on Monday November 13, 2023 @04:33PM (#38255700)
> So one could feed the entropy into a stream cipher with the right characteristics.

Certainly, but your proposed scheme does not feed entropy back into the stream cipher, it just offsets its output. This can be trivially broken if the stream cipher key ever leaks.

A better solution would combine (ideally securely hash) the stream cipher key with a relatively large (i.e. on the order of > 100 bits) number of bits.

Re:Convert standard Geiger counter to RNG by tptacek on Monday November 13, 2023 @05:38PM (#38256356)
I mean this is true, but it's also true that every cipher can be trivially broken if its key leaks. Yes: you want to rekey regularly (and that's not complicated). But whatever circumstance allowed your state to leak in the first place is most probably repeatable by an attacker, so you likely have much bigger problems than PRNG design.

If you want to snipe at people for freelancing their own CSPRNGs, the better point to make is that people should be relying on the OS's secure random generator to the exclusion of everything else; there are systems security reasons to avoid userland CSPRNGs.

But I think for the most part these are just people enjoying working out how a CSPRNG works. Which, mazel tov!

Re:Convert standard Geiger counter to RNG by stcredzero on Monday November 13, 2023 @07:53PM (#38257444)
Certainly, but your proposed scheme does not feed entropy back into the stream cipher, it just offsets its output.

Which effectively introduces entropy into the output, as well as to the internal state of the stream cipher.

This can be trivially broken if the stream cipher key ever leaks.

This is a trivial restatement of how symmetric ciphers are supposed to work.

Re:Convert standard Geiger counter to RNG by tptacek on Monday November 13, 2023 @05:37PM (#38256343)
I don't understand what you mean by "leak" here. You can definitely make a secure random bit generator with a stream cipher. Once it's fully initialized/seeded, it's practically never going to run out of random bits.
Re:Convert standard Geiger counter to RNG by stcredzero on Monday November 13, 2023 @07:50PM (#38257419)
I don't understand what you mean by "leak" here.

Again, not a crypto expert, but my understanding is that all stream ciphers leak some bits of the key with enough output. This is why differential cryptanalysis is possible against them. This is also why RC4 could be broken.

EDIT: Perhaps a better algorithm: Accumulate 128 bits of entropy and use that to key Salsa20. Then, whenever another 128 bits are accumulated, simply re-key the stream cipher.

Re:Convert standard Geiger counter to RNG by tptacek on Monday November 13, 2023 @10:07PM (#38258529)
It’s why RC4 is broken, not a thing we accept from ciphers that aren’t comically broken.
Re:Convert standard Geiger counter to RNG by stcredzero on Tuesday November 14, 2023 @02:09PM (#38267968)
Isn't that a matter of degree? RC4 leaks a lot. "Acceptable" ciphers leak so little, it's still not feasible to break the full version. But apparently this scales with increasing or reducing rounds. So it seems unlikely it ever goes to zero. It just gets near enough to zero, that there are no feasible attacks for some length of message.
Re:Convert standard Geiger counter to RNG by tptacek on Tuesday November 14, 2023 @02:31PM (#38268333)
No, it's not. A reasonable cryptanalytical model of a modern stream cipher (AED in a stream mode, or Salsa20, or whatever) is that --- within the birthday bounds of the underlying cipher (exabytes? you'd look it up, whatever you're using), and, in the case of something like an AEAD (or maybe just in the idiosyncratic case of GCM), the bounds of your nonce width --- they're not leaking _anything_. "Comical" really is the right word to use with respect to what RC4 did. It is kind of amazing that a cipher that broken remained in common use for as long as it did.
Re:Convert standard Geiger counter to RNG by stcredzero on Wednesday November 15, 2023 @02:57PM (#38281579)
within the birthday bounds of the underlying cipher (exabytes?

So modern stream ciphers do leak, just so slowly, it shouldn't ever matter in a practical sense if you're using them correctly? That was more or less my understanding to begin with, but maybe expressed ineptly.

the bounds of your nonce width --- they're not leaking _anything_

This reminds me of unicity distance. So under a certain number of outputs, one simply can't infer the internal state of the algorithm? It could be any number of internal states? That makes sense to me.

Re:Convert standard Geiger counter to RNG by tptacek on Wednesday November 15, 2023 @07:20PM (#38284303)
I don't think "leak" is the right way to think about it. There's are birthday bounds on the transform and, for nonce-based modes, on the nonces used for successive encryptions. I'm not sure it's really meaningful to think about the incremental marginal degree of "leakage" with each successive ciphertext up to that limit. We're coming up to the limit of what I'm comfortable talking about though; this is normally the point where 'pbsd jumps in to explain why what I'm saying is dumb.
Re:Convert standard Geiger counter to RNG by adrian_b on Tuesday November 14, 2023 @03:09AM (#38260420)
The term "stream cipher" is much more general than how you understand it.

There is a huge number of stream ciphers that have never been broken.

There is also a great number of stream ciphers that have been broken, but almost all of them belong to a class of ciphers that deserves the name "cheap stream ciphers".

Such "cheap stream ciphers" have been designed so that they can have a much cheaper implementation than the ciphers that are based on pseudorandom functions similar in complexity to DES and its successors, with the hope that despite being cheaper they will still be hard enough to break.

In most cases, sooner or later these hopes have been shown to be unfounded.

The term "stream cipher" just means that it encrypts a stream of plaintext symbols by combining a stream of encryption mask symbols with them.

There are many kinds of stream ciphers based on how the stream of encryption mask symbols are generated and based on the methods used to combine them with the plaintext.

Even if more general combination functions are possible when the only condition is to be able to decrypt the ciphertext, when an additional condition is imposed, that the statistical properties of the plaintext must not leak into the ciphertext, then the encryption mask symbols must be combined with the plaintext symbols using a quasigroup operation (a.k.a. a Latin square operation).

Most frequently, it is preferred that the quasigroup operation is a group operation, because this makes it simpler to implement. Moreover, usually it is preferred that the group operation is an additive group operation, to have an even cheaper implementation. Such stream ciphers are called additive stream ciphers.

When implemented in software, there are many additive group operations with equal complexity. However, when the encryption is implemented in hardware, addition modulo 2 is the cheapest so it is preferred.

The use of addition modulo 2 as a combination method has been invented by Gilbert S. Vernam in 1918. The term "binary additive stream cipher" should have been synonymous with "Vernam cipher". Unfortunately, in another example of mistaken historical attribution, the term "Vernam cipher" is used to mean any stream cipher where the encryption mask stream is truly random, which is a different invention, first described by Frank Miller in 1882 and rediscovered and popularized by Joseph Mauborgne, a user of Vernam machines.

Based on how the encryption mask stream is generated, there are many kinds of stream ciphers, but most of the practical stream ciphers are either synchronous stream ciphers, where the initial state and the transition function and the output function of the automaton that generates the encryption mask symbols do not depend on the plaintext or on the ciphertext, and self-synchronizing stream ciphers, where the encryption mask symbols are generated either as a pseudorandom function of the ciphertext symbols (these are a.k.a. ciphertext autokey stream ciphers) or as a pseudorandom function of the plaintext symbols (these are a.k.a. plaintext autokey stream ciphers; they have been abandoned a long time ago, because they are less secure). The two kinds of self-synchronizing stream ciphers are dual, i.e. starting from one such cipher a dual cipher is obtained by using the encryption algorithm for decryption and the decryption algorithm for encryption.

The stream ciphers that are most frequently used nowadays are binary additive synchronous stream ciphers, but there is a great variety of possible structures for the automaton that generates the encryption mask symbols. When implemented in software on a modern CPU, the simplest such automaton is made by using AES in counter mode (CTR mode).

Re:Convert standard Geiger counter to RNG by stcredzero on Tuesday November 14, 2023 @02:17PM (#38268087)
The term "stream cipher" is much more general than how you understand it.

This strikes me as a non-sequitur? Could you provide me with a quote where I misunderstood the term "stream cipher" and how I misunderstood it?

There is a huge number of stream ciphers that have never been broken.

I understand this to mean, that the full version of the algorithm doesn't have any feasible attacks. That the difficulty of the known attacks is so high, there is virtually zero value to them over using brute force.

Based on how the encryption mask stream is generated, there are many kinds of stream ciphers

If you read the thread carefully enough, you can deduce which kind of stream cipher I was thinking of.

Re:Convert standard Geiger counter to RNG by tptacek on Tuesday November 14, 2023 @02:34PM (#38268390)
I don't really follow the misunderstandings here, but on the off chance this re-level-sets the thread: you don't continuously inject new "entropy" (ie: rekey) a random bit generator out of concern that the underlying primitive is "leaking" (if it leaks, you fix the leak). Rather, you do so for post-compromise security, because there is basically no reason not to have some measure of post-compromise security such that if the state of your DRBG is compromised (by some systems vulnerability, not by cryptanalysis), in some relatively short interval security will be "restored" by rekeying.

I think that's pretty much it, the whole reason sophisticated CSPRNGs have entropy pools and stuff.

Re:Convert standard Geiger counter to RNG by adrian_b on Wednesday November 15, 2023 @04:17AM (#38274794)
I quote here what you have said:

"my understanding is that all stream ciphers leak some bits of the key with enough output"

This is a false statement.

Nowadays, the most frequently used encryption method is to use a stream cipher (more precisely a binary additive synchronous stream cipher), where the automaton that generates the encryption mask stream is implemented with a counter and with an output function that is an unpredictable pseudorandom function, usually either AES or ChaCha20.

With an appropriate pseudorandom function, such a stream cipher does not leak any bits of the key, even with enough output. There are methods of breaking a cipher with enough computation and memory, but those are specific to the pseudorandom function that happens to be used and they are not limited to stream ciphers, they are equally applicable to block ciphers that use the same pseudorandom function. Moreover, the known methods used to construct block ciphers are usually easier to break than good stream ciphers that use the same pseudorandom function.

It is obvious that when you have written "all stream ciphers", what you had in mind were not "all" such ciphers, but certain stream ciphers with very low implementation cost, but also with inadequate strength, which have been specified in many older communication protocols, e.g. in those for mobile phones (because the communication equipment manufacturers only cared about a low production cost, not about security, and the so-called encryption was only added to fool the customers, not to prevent professional attacks). Such cheap stream ciphers have been easily broken by anyone who has studied them seriously.

The ciphers that you have designated by "all stream ciphers" are an extremely small fraction of what is meant by "all stream ciphers" in the cryptographic literature, as I have explained in my previous post.

Re:Convert standard Geiger counter to RNG by stcredzero on Wednesday November 15, 2023 @02:47PM (#38281413)
There are methods of breaking a cipher with enough computation and memory, but those are specific to the pseudorandom function that happens to be used

But doesn't this constitute leakage of the algorithm's internal state in the output? (Albeit, very slow.)

and they are not limited to stream ciphers

I never said any of the above was limited to stream ciphers.