Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Secure Random Number Generator

Reply
Thread Tools

Secure Random Number Generator

 
 
Dave King
Guest
Posts: n/a
 
      03-13-2007
Hi-
Is there a secure random number generator for Ruby that works on
Windows and Linux?

Thanks,
Dave

 
Reply With Quote
 
 
 
 
M. Edward (Ed) Borasky
Guest
Posts: n/a
 
      03-13-2007
Dave King wrote:
> Hi-
> Is there a secure random number generator for Ruby that works on
> Windows and Linux?
>
> Thanks,
> Dave
>
>
>

Remind me again how a random number generator can be insecure ...

--
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blogspot.com/

If God had meant for carrots to be eaten cooked, He would have given rabbits fire.


 
Reply With Quote
 
 
 
 
Gary Wright
Guest
Posts: n/a
 
      03-13-2007

On Mar 13, 2007, at 1:03 AM, M. Edward (Ed) Borasky wrote:

> Dave King wrote:
>> Hi-
>> Is there a secure random number generator for Ruby that works on
>> Windows and Linux?


I'm assuming he means sufficiently random for cryptographic purposes.
Some pseudo-random number generators don't meet that requirement.

The Ruby 1.9 source code for random says:

This is based on trimmed version of MT19937. To get the original
version,
contact <http://www.math.keio.ac.jp/~matumoto/emt.html>.

The docs for Kernel#rand say

Ruby currently uses a modified Mersenne Twister with a period of
219937-1.

I'm not a crypto geek but I'm guessing that a Mersenne Twister algorithm
doesn't have sufficient entropy for crypto purposes.

As a proof of concept I whipped up this for MacOSX. It gets random data
from /dev/urandom, which based on the man page is better source of
random
data (Yarrow pseudo random number generator with entropy injected by the
MacOSX SecurityServer). I'm not claiming this is good for crypto work
either, just that it looks better than the Mersenne Twister. I think
this
would work on Linux also since it has /dev/urandom. I got nothing for
Windows.

module Kernel
# Return bytes from /dev/urandom.
# With no arguments, urandom grabs four bytes and returns them as an
# unsigned integer. With an integer argument, urandom returns a
string
# of that size filled with bytes from /dev/urandom.
def urandom(size=nil)
result = File.open('/dev/urandom') { |x| x.read(size || 4) }
size && result || result.unpack("L").first
end
end

Gary Wright




 
Reply With Quote
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      03-13-2007
On Tue, 13 Mar 2007, Gary Wright wrote:

> I got nothing for Windows.


don't you just have to run any 'ol code to get random numbers on windows?

(ducks)

-a
--
be kind whenever possible... it is always possible.
- the dalai lama

 
Reply With Quote
 
Husein Choroomi
Guest
Posts: n/a
 
      03-13-2007
http://raa.ruby-lang.org/search.rhtm...=random+number

On 3/13/07, Dave King <> wrote:
> Hi-
> Is there a secure random number generator for Ruby that works on
> Windows and Linux?
>
> Thanks,
> Dave
>
>



--
Husein Choroomi,
CEO, CTO
Yucca Intelligence Development
http://www.YuccaHQ.com

We make the web a better place!

 
Reply With Quote
 
Bill Kelly
Guest
Posts: n/a
 
      03-13-2007
From: <>
> On Tue, 13 Mar 2007, Gary Wright wrote:
>
>> I got nothing for Windows.

>
> don't you just have to run any 'ol code to get random numbers on windows?




I would propose installing registry-access-hooks to monitor and
generate random bits from all the trojan horses continually rewriting
dozens of registry keys per second to ensure they can't be deleted.


Regards,

Bill (who found a very, very tenacious trojan on his win xp box recently)
(check your windows/system32 folder for a hidden file called pmnnl.dll)




 
Reply With Quote
 
Joel VanderWerf
Guest
Posts: n/a
 
      03-13-2007
Dave King wrote:
> Hi-
> Is there a secure random number generator for Ruby that works on
> Windows and Linux?


Is ISAAC[1] secure enough for you?

I think Kirk Haines posted his implementation somewhere. (I've got one
too, but I never released it.)

[1] http://www.burtleburtle.net/bob/rand/isaac.html

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

 
Reply With Quote
 
khaines@enigo.com
Guest
Posts: n/a
 
      03-14-2007
On Tue, 13 Mar 2007, Joel VanderWerf wrote:

> Dave King wrote:
>> Hi-
>> Is there a secure random number generator for Ruby that works on
>> Windows and Linux?

>
> Is ISAAC[1] secure enough for you?
>
> I think Kirk Haines posted his implementation somewhere. (I've got one too,
> but I never released it.)


Crypt::ISAAC. I have a small update to it (that includes a pure C
implementation that someone else donated) that I will try to get uploaded.
May not get it done until after the MountainWest Rubyconf, though.


Kirk Haines


 
Reply With Quote
 
Dave King
Guest
Posts: n/a
 
      03-14-2007
Yeah I look at that, I was actually having trouble getting the setup.rb
script to run in Windows. It's fine for me to copy it over but I was
going to use it in an article and didn't want to have to explain how to
manually install it. Then again it could just be my laptop, I'll try it
on another computer tomorrow. Also, I noticed you said you were working
on better seeding for Windows, does the current seeding effect the
randomness much?

Thanks,
Dave

wrote:
> On Tue, 13 Mar 2007, Joel VanderWerf wrote:
>
>> Dave King wrote:
>>> Hi-
>>> Is there a secure random number generator for Ruby that works on
>>> Windows and Linux?

>>
>> Is ISAAC[1] secure enough for you?
>>
>> I think Kirk Haines posted his implementation somewhere. (I've got
>> one too, but I never released it.)

>
> Crypt::ISAAC. I have a small update to it (that includes a pure C
> implementation that someone else donated) that I will try to get
> uploaded. May not get it done until after the MountainWest Rubyconf,
> though.
>
>
> Kirk Haines
>
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Secure your digital information assets with Secure Auditor. SecureWindows with Secure Auditor alannis.albert@googlemail.com Cisco 0 04-14-2008 06:53 AM
Secure your digital information assets with Secure Auditor SecureWindows with Secure Auditor alannis.albert@googlemail.com Cisco 0 04-14-2008 06:52 AM
Secure your digital information assets with Secure Auditor and alsoSecure Windows with Secure Auditor alannis.albert@googlemail.com Wireless Networking 0 04-14-2008 06:37 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57