Tell me more ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I have a question about random number generators.

I have read from a real random number generator, based on a webcam ("randcam"). My problem is, that I do not really understand how the generation of the random numbers works. Has anyone heard of this principle before and can give some hints how it could be implemented? And how randomly is this method, I've read it should give real random numbers, but is this true? I've found an implementation in C++, but I did not really understand how this implementation works, I am not that familiar with C++.

share|improve this question
I've never heard of this randcam thing, and wouldn't recommend using it. Instead, I recommend using a standard random-number source, such as /dev/urandom, CryptGenRandom(), or similar (depending upon what platform your code is running on). – D.W. Dec 1 '12 at 20:06
@D.W. Sensor noise is a nice source of entropy. Obviously you still need to feed it into a standard PRNG. – CodesInChaos Dec 2 '12 at 8:32
@CodesInChaos, nonetheless, I stand by my comment. End users of cryptography shouldn't be rolling their own PRNG; they should use a standard system PRNG, and let the system designers take care of ensuring it has sufficient entropy. (Let the system designers choose to use webcam data if that is appropriate and improves security, but most users of cryptography should not be making decisions like this.) – D.W. Dec 3 '12 at 3:47
@D.W. Yes, but if we can't get creative, this site might end up repeating itself endlessly. In any case, if a person can't differentiate between what "sounds good" and what is "time-honored, proven cryptography", he shouldn't be allowed near cryptographic source code anyway (sadly we all know how often that occurs). – Thomas Dec 5 '12 at 8:39
@Thomas, Usually, the purpose of cryptography is to be secure against malicious attackers, not to "be creative". If you want to be secure, then you should use best practices, even if it feels like that's "repeating itself". A creative-but-insecure solution isn't going to help anyone. – D.W. Dec 5 '12 at 9:55
show 1 more comment

1 Answer

up vote 2 down vote accepted

A quick web search showed me this german page Zufallszahlen aus der Webcam ("random numbers from the web cam). (All other hits on the first Google result page are about an unrelated Pistonless rotary engine).

This page speaks about a program available from the same site, which tries to gather entropy from a web cam and produce "real" random numbers from this.

From the linked page (I didn't try to read the source code), the program tries to extract the electrical noise from the photo sensors by calculating differences between following frames, then assembles the difference bytes to blocks and hashes each of them with MD5. The size (and thus number) of these blocks is adjusted for each difference frame from the measured entropy (but it isn't described how this is measured) and also dependent on some adjustable factor.


The idea to use electronic noise from a web cam as entropy input sounds good. Of course, I would like to see a more theoretic analysis of the entropy which can be gathered, not just statistic tests (there are cryptographical awful RNGs which pass all statistical tests), and I would use a more sound cryptographic processing of the data.

From the cryptographical side, I wouldn't use MD5 for this, but a newer hash function like one of the SHA-2 family. While the broken collision resistance of MD5 is not a problem here, other then when your adversary can plug in its own device and feed arbitrary bits instead of the images, it is just bad for your reputation to use MD5 for anything security-relevant.

I would use an entropy pool design cryptographic random number generator. The entropy from the web cam would be added to the entropy pool, this pool mixed using pseudorandom functions, and then the random numbers extracted by another pseudo random functions. There are standardized constructions for this.

But as D.W. said, there is still missing quite some analysis (how much entropy do we actually get from the differences?, for example), and justifications for the crypto around this. So I wouldn't yet recommend using this for any productive use.

share|improve this answer
4  
Better yet, make the webcam interface with the operating system's entropy pool, that way you don't even need to do any work except feed it into some function. – Thomas Dec 2 '12 at 0:42
1  
I would want to see a lot more detailed analysis than that the idea "sounds good" before recommending this to users of cryptography. In other words: I don't think this is good advice to end users. I don't think it does a service to users to encourage them to roll their own entropy sources like this; I think giving users this kind of advice is likely to lead to increased incidence of poorly seeded crypo. Instead, I think it is better to stick to advising them to use standard, well-vetted crypto PRNGs provided by the system. – D.W. Dec 3 '12 at 3:49
2  
Among the risks associated with the technique is that the output of the webcam could be accessible to an adversary using a built-in legitimate feature of the webcam driver, not to mention a backdoor thereof. Also, a crash of the webcam driver has a good chance to degenerate into no available entropy. – fgrieu Dec 3 '12 at 21:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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