LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-12-2007, 08:23 AM   #1
mistersnorfles
Member
 
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51

Rep: Reputation: 15
How Random & Pseudorandom #'s Interact


A few questions:

1. If I put a set of pseudorandom numbers (/dev/urandom) through a random (/dev/random) hash, does it make the result more random than the initial pseudorandom inputs?

2. If I put a set of random number through a pseudorandom hash, does it make the result less random than the input?

3. If I put a pseudorandom number through a pseudorandom hash, will it make the result more random?

Thanks,
Mr. Snorfles
 
Old 08-12-2007, 04:10 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
First, it is not that random and urandom are 'true random' and 'pseudorandom'. They have similar 'entropy pools' (places for storing result of some strange computations involving all the 'entropy' collected by kernel, kernel tries to use everything that has systematic component and truly random - from this system's point of view - component to make contents of 'entropy pool' unpredictable). Both have some algorithms of generating some data based on the entropy pools. The difference is only that 'random' tries to predict how much really unpredictable information is contained in its pool and refuses to give out so much data as to risk too much that part of it can be restored by knowing the rest.

So if you do not take much data from urandom there will be little difference. And are you sure you can decide what you mean under 'random'? Try dumping 512 bytes of audio input to /dev/urandom each 8 bytes you read (data written to /dev/urandom gets mixed in to its pool, so that resulting randomness is hopefully no less than original and no less than random part contained in dumped data) and you can think that it is nearly as random as just tossing a coin (which also can have deficiencies...).

If you have a good hash for mixing two random streams of data it should output a sequence that is no worse than any of inputs. Mixing pseudorandoms can improve things, but do not bother - kernel will be able to use noise from audio card..
 
Old 08-12-2007, 07:44 PM   #3
mistersnorfles
Member
 
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks for the very informative response. Let me ask a few questions to make sure I got everything.

You said:
Quote:
Both have some algorithms of generating some data based on the entropy pools. The difference is only that 'random' tries to predict how much really unpredictable information is contained in its pool and refuses to give out so much data as to risk too much that part of it can be restored by knowing the rest.
So /dev/random does exactly the same thing as /dev/urandom, except whenever it feels like it is providing too much information about itself (making it more likely that someone can predict what it will do), it stops handing out numbers?

And:
Quote:
So if you do not take much data from urandom there will be little difference.
So if I just slow down the rate at which I pull data from /dev/urandom, it will become just as random as /dev/random? Where can I configure how /dev/urandom operates?

And as far as:
Quote:
Try dumping 512 bytes of audio input to /dev/urandom each 8 bytes you read (data written to /dev/urandom gets mixed in to its pool, so that resulting randomness is hopefully no less than original and no less than random part contained in dumped data)
How do I go about dumping the audio into /dev/urandom? Would this work?:
Code:
dd if=/dev/sound/dsp of=/dev/urandom bs=512
Also, it would seem that I should be able to dump video data into /dev/urandom as well right?

Thanks again,
Mr. Snorfles
 
Old 08-12-2007, 10:49 PM   #4
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Quote:
So /dev/random does exactly the same thing as /dev/urandom
At some point in the past it was so. They even used one pool, as far as I remember. Now they are independent and probably the pools are formed in slightly different way, but they are very similar (unless you exhaust /dev/random entropy).

I do not know if /dev/urandom is configurable (and I am not exactly sure what do you want). You do not need to read slowly, you need quicker entropy input (it is some problem on some servers that have everything cached in RAM and so has little random events).

Quote:
dd if=/dev/sound/dsp of=/dev/urandom bs=512
It is correct on /dev/urandom side; but as far as I remember /dev/dsp is output. I meant input. Output has too little unpredictable noise. If you have video input device, you can also use it.
 
Old 08-13-2007, 07:31 AM   #5
mistersnorfles
Member
 
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51

Original Poster
Rep: Reputation: 15
So audio input is what I want? Like the microphone? Would I have to have a microphone attached to the computer? Why is the audio input less predictable than the audio output?

Thanks,
Mr. Snorfles
 
Old 08-13-2007, 07:44 AM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
No, you do not necessarily want microphone itself (though it can help); just audio input from empty slot is Analog-to-Digital Converter output on empty (and so reacting to every electromagnetic wave) input. It is physically random process. But microphone catches heat noise, so it is also good.
And audio output can be a) blank; b) the same music as last time. Really it will not lead to exact repetition, but will significantly lessen randomness in some sense. Audio output does not have noise until it has left digital form.
 
Old 08-13-2007, 08:22 AM   #7
mistersnorfles
Member
 
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51

Original Poster
Rep: Reputation: 15
That's interesting, I didn't realize that the microphone jack could do that. I'm going to go play around with that. Maybe I'll be back in a bit with some interesting results...

Thanks so much for your help raskin!

--Mr. Snorfles
 
  


Reply

Tags
encryption


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running out of entropy & /dev/random reads are blocking slacky Linux - General 1 06-15-2005 09:53 PM
cryptographic pseudorandom function saajii Programming 1 09-16-2004 07:58 AM
Interact ACT! thanko Linux - Software 3 03-14-2004 07:30 PM
DVD recording at random place & time questions dinningc Linux - Hardware 0 02-27-2004 09:52 AM
Need to interact with VB / COM from Perl jpbarto Programming 0 10-08-2003 10:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration