in reply to Cryptographically Secure Psuedorandom Number Genergator - PRNG?

If you've got usable C, couldn't you Inline::C it?

ISAAC source


Caution: Contents may have been coded under pressure.
  • Comment on Re: Cryptographically Secure Psuedorandom Number Genergator - PRNG?

Replies are listed 'Best First'.
Re^2: Cryptographically Secure Psuedorandom Number Genergator - PRNG?
by hv (Prior) on Jun 09, 2005 at 23:08 UTC

    That page itself links to a perl version of the ISAAC code: http://burtleburtle.net/bob/rand/randperl.txt.

    But the code is trivial enough that exposing the C code via an XS or Inline module should be a pretty straightforward path to retaining the speed of C if that's an issue.

    Hugo

      Aha! Thank you! I'm working producing a module for that code that can provide a drop-in replacement to the default rand(). I will probably publish it in the Monestary first, then work on submitting to CPAN (which will be a new experience for me, and so might take some time).

      As I mention in my new update to the parent node, however, I also need a cross-platform (at least *NIX and Win) method to generate a seed. For ISAAC specifically, I would want at least one and no more than 256 32-bit values with which to seed the PRNG. Any thoughts?

      Yoda would agree with Perl design: there is no try{}

        You don't like the random bytes from a random file idea?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

        Not sure how best to seed if you can't rely on /dev/random. I've seen a colleague on Mac trying to generate an ssh (or maybe PGP) key and being required to "type randomly for long enough" to generate random bits for security; not sure what application that was though.

        So maybe the thing you need to look at is the device driver code for /dev/random. Everything2 has some interesting information about what it does, and for Linux the source should be in drivers/char/random.c.

        Hugo