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

version» Context lines:

pike.git/lib/modules/Crypto/randomness.pmod:1: - // $Id: randomness.pmod,v 1.23 2003/01/09 17:43:20 grubba Exp $ + // $Id: randomness.pmod,v 1.24 2003/01/20 17:44:00 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__      static constant RANDOM_DEVICE = "/dev/random";
pike.git/lib/modules/Crypto/randomness.pmod:140:    object 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 (strlen(seed) < 2001) +  if (sizeof(seed) < 2001)    seed = random_string(2001); // Well, we're only at reasonably random...    return (global_arcfour = arcfour_random(sprintf("%4c%O%s", time(),    _memory_usage(), seed)));   #else /* !constant(Crypto.arcfour) */       // Not very random, but at least a fallback...    if(!goodseed) {    random_seed( time() + Array.sum( (array)seed ) );    goodseed = 1;    }