Branch: Tag:

1999-11-25

1999-11-25 23:10:52 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Now falls back on pike_random() if Crypto.rc4 is missing.

Rev: lib/modules/Crypto/randomness.pmod:1.13

1: - /* $Id: randomness.pmod,v 1.12 1999/09/13 22:19:15 hubbe Exp $ + /* $Id: randomness.pmod,v 1.13 1999/11/25 23:10:52 grubba Exp $    */      //! module Crypto
98:    }   }    + #if constant(Crypto.rc4)   //! class rc4_random   //! A pseudo random generator based on the rc4 crypto.   class rc4_random {
123:    }   }    + #endif /* constant(Crypto.rc4) */      object reasonably_random()   {
136:    if (global_rc4)    return global_rc4;    + #if constant(Crypto.rc4)    string seed = some_entropy();    if (strlen(seed) > 2000)    return (global_rc4 = rc4_random(sprintf("%4c%O%s", time(), _memory_usage(), seed))); -  + #else /* !constant(Crypto.rc4) */ +  /* Not very random, but at least a fallback... */ +  return global_rc4 = pike_random(); + #endif /* constant(Crypto.rc4) */    throw( ({ "Crypto.randomness.reasonably_random: No source found\n", backtrace() }) );   }