Re: Possible issue with srand or rand in base?

2010-02-22 Thread Jonathan Thornburg
In http://marc.info/?l=openbsd-techm=126562459427981w=1, Janne Johansson jj () it ! su ! se wrote [[about rand(3)]] The weird part of this (I think) for us outside viewers is that rand() has been known to be really poor at random for a long time. Not a few years, but like 20+ years and more.

Re: Possible issue with srand or rand in base?

2010-02-08 Thread Marc Espie
On Sun, Feb 07, 2010 at 01:59:33PM -0500, Brad Tilley wrote: I wrote a small cpp application to generate randomish passwords. It compiles and runs OK on OpenBSD, however, it does not seem to create random strings (the first and last chars seldom ever change, etc). The same code compiles and

Re: Possible issue with srand or rand in base?

2010-02-08 Thread Brad Tilley
I placed the GUI version there are source.cpp. I don't have the simpler, non-GUI version that I posted yesterday, but the use of srand and rand are the same in both examples. The GUI version compiles on OpenBSD if you have fltk installed from ports. I only wrote the simpler version to

Re: Possible issue with srand or rand in base?

2010-02-08 Thread Marc Espie
On Mon, Feb 08, 2010 at 08:10:11AM -0500, Brad Tilley wrote: I placed the GUI version there are source.cpp. I don't have the simpler, non-GUI version that I posted yesterday, but the use of srand and rand are the same in both examples. The GUI version compiles on OpenBSD if you have fltk

Possible issue with srand or rand in base?

2010-02-07 Thread Brad Tilley
I wrote a small cpp application to generate randomish passwords. It compiles and runs OK on OpenBSD, however, it does not seem to create random strings (the first and last chars seldom ever change, etc). The same code compiles and runs on Linux and Windows and *does* produce randomish strings

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Otto Moerbeek
On Sun, Feb 07, 2010 at 01:59:33PM -0500, Brad Tilley wrote: I wrote a small cpp application to generate randomish passwords. It compiles and runs OK on OpenBSD, however, it does not seem to create random strings (the first and last chars seldom ever change, etc). The same code compiles

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Vadim Zhukov
On 7 February 2010 c. 21:59:33 Brad Tilley wrote: I wrote a small cpp application to generate randomish passwords. It compiles and runs OK on OpenBSD, however, it does not seem to create random strings (the first and last chars seldom ever change, etc). The same code compiles and runs on Linux

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Otto Moerbeek
On Sun, Feb 07, 2010 at 10:42:40PM +0300, Vadim Zhukov wrote: On 7 February 2010 c. 21:59:33 Brad Tilley wrote: I wrote a small cpp application to generate randomish passwords. It compiles and runs OK on OpenBSD, however, it does not seem to create random strings (the first and last chars

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Nicholas Marriott
The traditional implementation of rand() (including OpenBSD's) cycles very quickly in the lower bits (try printing a few eg rand() 0xf). If you do have to use it for anything, try to use the high bits, although as others have said you should avoid using it at all particularly for passwords. On

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Vadim Zhukov
On 7 February 2010 c. 22:57:31 Otto Moerbeek wrote: On Sun, Feb 07, 2010 at 08:54:04PM +0100, Otto Moerbeek wrote: On Sun, Feb 07, 2010 at 10:42:40PM +0300, Vadim Zhukov wrote: On 7 February 2010 c. 21:59:33 Brad Tilley wrote: I wrote a small cpp application to generate randomish

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Philip Guenther
On Sunday, February 7, 2010, Otto Moerbeek wrote: That is still wrong for this purpose. Although random(3) is a better random number generator than rand, is still a cryptographic weak generator. Better use arc4random() Or rather, since he needs to reduce the range, use arc4random_uniform()

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Otto Moerbeek
On Sun, Feb 07, 2010 at 12:26:43PM -0800, Philip Guenther wrote: On Sunday, February 7, 2010, Otto Moerbeek wrote: That is still wrong for this purpose. Although random(3) is a better random number generator than rand, is still a cryptographic weak generator. Better use arc4random()

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Otto Moerbeek
On Sun, Feb 07, 2010 at 03:39:25PM -0500, Brad Tilley wrote: On Sun, 07 Feb 2010 21:32 +0100, Otto Moerbeek o...@drijf.net wrote: On Sun, Feb 07, 2010 at 12:26:43PM -0800, Philip Guenther wrote: On Sunday, February 7, 2010, Otto Moerbeek wrote: That is still wrong for this

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Brad Tilley
On Sun, 07 Feb 2010 21:32 +0100, Otto Moerbeek o...@drijf.net wrote: On Sun, Feb 07, 2010 at 12:26:43PM -0800, Philip Guenther wrote: On Sunday, February 7, 2010, Otto Moerbeek wrote: That is still wrong for this purpose. Although random(3) is a better random number generator than

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Brad Tilley
On Sun, 07 Feb 2010 21:40 +0100, Otto Moerbeek o...@drijf.net wrote: On Sun, Feb 07, 2010 at 03:39:25PM -0500, Brad Tilley wrote: On Sun, 07 Feb 2010 21:32 +0100, Otto Moerbeek o...@drijf.net wrote: On Sun, Feb 07, 2010 at 12:26:43PM -0800, Philip Guenther wrote: On Sunday,

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Miod Vallat
(That C++ made me cry. Iterating across a map to convert an integer in the range 1..56 to a character?!? If only C++ had a datastructure which gave O(1) lookup for small indexes, like an array does in C.) Not to mention that fixed array gets rebuilt upon every function call! Makes you wish

Re: Possible issue with srand or rand in base?

2010-02-07 Thread Brad Tilley
On Sun, 07 Feb 2010 22:03 +0100, Otto Moerbeek o...@drijf.net wrote: On Sun, Feb 07, 2010 at 03:43:59PM -0500, Brad Tilley wrote: That's OK, my skin is thick. Thanks for the feedback. I had some older fltk code there initially that behaves in a similar fashion (only it has a GUI). It