Take the 2-minute tour ×
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
1  
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
2  
@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
1  
@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
1  
@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
3  
@D.W. I think we all know that here. But dismissing an interesting question on the basis of "never heard of it - stick to best practices" doesn't help the OP who was looking for an explanation of how entropy was being extracted from webcam noise. The OP never even said he wanted to use it in a real life application, maybe he is just curious - so it's nice to give the OP a heads up about sensible cryptography practices, but it is ultimately off-topic advice. –  Thomas Dec 5 '12 at 10:05
show 1 more comment

2 Answers 2

up vote 5 down vote accepted

A quick web search for "randcam" 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 is 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 cryptographically awful RNGs which pass all statistical tests), and I would use a more sound cryptographic processing of the data.

From the cryptographic 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 pseudo random 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
5  
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
add comment

A video camera can obtain entropy, but only at a fairly low rate and only if allowed to see "unusual" scenes… like someone making funny faces, unusual movements, etc. Of course, this only works in a room with no video bugs.

Theoretical explanations…

Depending on your knowledge-range, the following sources may be able to explain ways webcams can be used for random number generation:

Getting more practical…

If the above is too theoretical for you and you want a more practical explanation of how it can be done, there's a cool "how-to" article at inventgeek.com that shows how to create an "alpha radiation visualizer" from scratch within an hour… using a webcam and a regular smoke-alarm device as radiation source.

share|improve this answer
add comment

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.