Re: Re: Still wondering about random numbers...

From: "Joe Conway" <joseph(dot)conway(at)home(dot)com>
To: "Dr(dot) Evil" <drevil(at)sidereal(dot)kz>, <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: <bruno(at)wolff(dot)to>, <lockhart(at)fourpalms(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: Still wondering about random numbers...
Date: 2001-08-08 00:53:20
Message-ID: 053801c11fa4$857cf0e0$48d210ac@jecw2k1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

> > Isn't /dev/random best used for seeding the random number generator,
> > rather than for getting random number?
>
> It is best used for any situation when quality random numbers are
> needed. This includes seeding, and in some cases it may also include
> generating session keys and other things. It's good to have a
> choice. Right now I have a lot of pl/pgsql which calls plain old
> RANDOM() to generate session keys, and that is not good. Before I
> launch this thing, I will need to find a way of getting better random
> numbers. If anyone has created a function like that for PG, please
> mail me, because I need it.

As I said earlier, I just recently created a function for something else I'm
working on which returns a binary string from /dev/urandom of whatever
length you request. I'm using it for initialization vectors (IVs) for 3des
cbc and for session keys. It should be relatively easy to turn into a pgsql
contrib function, so I'll post something to patches within the next couple
of days. It would not be intended to replace the standard RANDOM() function,
just compliment it. Biggest question in my mind is the return type -- should
it return pure binary as a bytea type, or hex as a text type? Any thoughts
on this?

I agree with other comments regarding /dev/random. During testing I found
that it can block for significant periods of time, especially when used
repetitively.

-- Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Lockhart 2001-08-08 01:19:16 Re: [GENERAL] user guide
Previous Message David Wheeler 2001-08-08 00:44:36 Long Query

Browse pgsql-patches by date

  From Date Subject
Next Message Doug McNaught 2001-08-08 03:15:14 Re: Re: Still wondering about random numbers...
Previous Message Dr. Evil 2001-08-08 00:34:44 Re: Still wondering about random numbers...