pike.git / lib / modules / Crypto / randomness.pmod

version» Context lines:

pike.git/lib/modules/Crypto/randomness.pmod:1: - // $Id: randomness.pmod,v 1.24 2003/01/20 17:44:00 nilsson Exp $ + // $Id: randomness.pmod,v 1.25 2003/03/07 17:41:48 nilsson Exp $      //! Assorted stronger or weaker randomnumber generators.   //! These devices try to collect entropy from the environment.   //! They differ in behaviour when they run low on entropy, /dev/random   //! will block if it can't provide enough random bits, while /dev/urandom   //! will degenerate into a reasonably strong pseudo random generator      #pike __REAL_VERSION__ -  + // #pragma strict_types      static constant RANDOM_DEVICE = "/dev/random";   static constant PRANDOM_DEVICE = "/dev/urandom";      /* Collect somewhat random data from the environment. Unfortunately,    * this is quite system dependent    */   static constant PATH = "/usr/sbin:/usr/etc:/usr/bin/:/sbin/:/etc:/bin";      #ifndef __NT__
pike.git/lib/modules/Crypto/randomness.pmod:50:   //! Executes several programs (last -256, arp -a, netstat -anv, netstat -mv,   //! netstat -sv, uptime, ps -fel, ps aux, vmstat -s, vmstat -M, iostat,   //! iostat -cdDItx) to generate some entropy from their output. On Microsoft   //! Windows the Windows cryptographic routines are called to generate random   //! data.   string some_entropy()   {   #ifdef __NT__    return nt_random_string(8192);   #else /* !__NT__ */ -  mapping env = getenv(); +  mapping env = [mapping(string:string)]getenv();    env->PATH = PATH;       Stdio.File parent_pipe = Stdio.File();    Stdio.File child_pipe = parent_pipe->pipe();    if (!child_pipe)    error( "Couldn't create pipe.\n" );       Stdio.File null = Stdio.File("/dev/null","rw");       foreach(SYSTEM_COMMANDS, string cmd)
pike.git/lib/modules/Crypto/randomness.pmod:104: Inside #if constant(Crypto.arcfour)
     #if constant(Crypto.arcfour)   //! A pseudo random generator based on the arcfour crypto.   class arcfour_random {       inherit Crypto.arcfour : arcfour;       //! Initialize and seed the arcfour random generator.    void create(string secret)    { -  object hash = Crypto.sha(); +  Crypto.sha hash = Crypto.sha();    hash->update(secret);       arcfour::set_encrypt_key(hash->digest());    }       //! Return a string of the next len random characters from the    //! arcfour random generator.    string read(int len)    {    if (len > 16384) return read(len/2)+read(len-len/2);
pike.git/lib/modules/Crypto/randomness.pmod:130:      //! Returns a reasonably random random-source.   RandomSource reasonably_random()   {   #ifdef __NT__    return NTSource();   #endif       if (file_stat(PRANDOM_DEVICE))    { -  object res = Stdio.File(); +  Stdio.File res = Stdio.File();    if (res->open(PRANDOM_DEVICE, "r"))    return res;    }       if (global_arcfour)    return global_arcfour;       string seed = some_entropy();   #if constant(Crypto.arcfour)    if (sizeof(seed) < 2001)