News for hackers. Stuff that matters.
Re:How to safely generate a random number by tptacek on Tuesday February 25, 2014 @10:05PM (#7302597)
urandom and /dev/random aren't two different CSPRNGs. They aren't really even two different designs. They are two different pools into which the same kinds of raw entropy are mixed; the interface to /dev/random's pool happens to have a weird gate on it that tries to determine how much "entropy" is "left" in the pool. I'm oversimplifying a little, but that's the gist of it.

So the problem here is, if you're on a solid state embedded system that doesn't generate enough entropy to drive urandom, you're not doing enough to drive /dev/random either --- except, owing to a design flaw in Linux, on first-boot-ever, where /dev/random's entropy estimator gate saves from you from the bug that is Linux's willingness to give you output from an unseeded RNG. It shouldn't do that. FreeBSD doesn't. But if you're worried about that problem, the correct fix is to explicitly seed urandom from /dev/random on boot, not to use /dev/random in your code!

Once the CSPRNG is seeded, the idea of a "sufficient amount of entropy" is silly. Think of a CSPRNG as a stream cipher. Think of its output as you would the keystream of that cipher. What does it mean, within reason (ie, not hundreds of terabytes) for a keystream to have "sufficient" key in it? Because that's essentially the same question the maintainer for /dev/random is asking.

Re:How to safely generate a random number by luke-stanley on Tuesday February 25, 2014 @10:31PM (#7302709)
How do we know there isn't some predictable pattern from common urandom sources? What is meant to make the state non-predictable anyway? If I cared about it, someone could just add a library on top of it that combines them with more entropy sources. Like camera noise, temperature changes, audio static etc. For some reason the author says not to build libraries on top of urandom because they might be hacked. Well if something has compromised your system anyway, why does that matter?
Re:How to safely generate a random number by tptacek on Tuesday February 25, 2014 @11:00PM (#7302803)
"The urandom sources"? What do you think that means? The code is right there.
Re:How to safely generate a random number by luke-stanley on Friday February 28, 2014 @04:19PM (#7321568)
I'm talking about the sources of it's random input, not it's source code.
Re:How to safely generate a random number by tveita on Tuesday February 25, 2014 @10:48PM (#7302768)
You can call it a bug or design flaw if you'd like, but this behaviour is documented, well known, and it's how every single Linux system operates.

urandom simply isn't guaranteed to be random enough for cryptographic keys. Misusing it for this causes real-world problems.

You are telling people to write insecure software. That it could be secure if Linux worked differently from how it actually works is completely irrelevant and bordering on denialism.

If you want to fix Linux to be more like the other systems, great! Then /dev/random will be non-blocking and everyone can use that. Meanwhile, I'd much rather block than find myself sharing prime factors with random strangers.

Re:How to safely generate a random number by tptacek on Tuesday February 25, 2014 @10:59PM (#7302800)
On the one hand you have Nacl, from Daniel J. Bernstein, Tanja Lange, and Peter Schwabe, the gold standard of misuse-resistant crypto libraries, relying entirely on urandom and documenting why.

On the other, you have HN's 'tveita, saying that urandom "isn't guaranteed to be random enough for cryptographic keys".

I could continue the argument, but since the whole post you're commenting on is that argument, I'd be repeating myself. So instead, I'll just ask: what specific assertion in that post do you disagree with?

Re:How to safely generate a random number by tveita on Tuesday February 25, 2014 @11:18PM (#7302858)
How about the very post I replied to?

> the bug that is Linux's willingness to give you output from an unseeded RNG

So there you have it. But don't worry, no one uses this "Linux" thing, certainly not in embedded systems.

https://factorable.net/

Re:How to safely generate a random number by tptacek on Tuesday February 25, 2014 @11:29PM (#7302893)
Keep reading. I think you stopped too early.
Re:How to safely generate a random number by tveita on Wednesday February 26, 2014 @12:12AM (#7303040)
I read it all, don't be a jerk.

When you're writing a program for generic use, you can't trust the underlying system to be set up above and beyond a stock install. If you want to use seeding as a workaround, it should be done from every program that requires secure randomness. That doesn't seem to be what you're advocating. And if you're just generating a key, why not read it directly from random instead?

You can pretend that urandom gives good randomness and be surprised when you get key collisions. Just like you can pretend that strncpy null-terminates strings and be surprised when you get a buffer overflow vulnerability. That makes you a menace.

For what's it's worth, I agree that an adequately seeded CSPRNG should never 'run out' of entropy, and I wouldn't mind if Linux got a BSD-style shared random/urandom. But as it stands, urandom is not guaranteed to be adequately seeded, and I have no idea why you would advocate taking that risk.

Re:How to safely generate a random number by tptacek on Wednesday February 26, 2014 @08:17AM (#7304690)
Oh, we're talking past each other. Sorry. When I said "post", I meant the story this thread links to, not the comment thread. I believe you read the comments in their entirety. I think if you reread the post, you'd see that it rebuts your argument.
Re:How to safely generate a random number by luke-stanley on Friday February 28, 2014 @04:24PM (#7321599)
For encryption, the only way to be really secure is to have the same amount of randomness as there is data to encrypt, as a shared key. (A one time pad.) This isn't that hard to do so long as you can give it to the people that need it ahead of time, and should solve all kinds of theoretical problems. Mailing memory cards sealed in photoed glitter paint could work well too. It would be fun to 3D print a replica though.