Bug#537952: Use more random random seed than localtime

Jonathan Yu jonathan.i.yu at gmail.com
Thu Jul 30 23:49:15 UTC 2009


Don:

On Thu, Jul 30, 2009 at 7:35 PM, Don Armstrong<don at donarmstrong.com> wrote:
> On Thu, 30 Jul 2009, Jonathan Yu wrote:
>> I should also note that changing the patch to this:
>> +void
>> +set_default_seed(long time)
>> +       PREINIT:
>> +       long seed;
>> +       CODE:
>> +       seed = Perl_get_seed;
>> +       setall(seed, seed);
>>
>> Yielded the same error. Am I missing something about how to use setall()?
>
> Yes. You're missing the modulus which is present in my second patch.

I don't think I am. Here is the code prior to that bit:

+#ifdef Perl_seed
+/* For whatever reason, the random seeds need to be in 1..2^30; the below will
+ * be uniformly distributed assuming the seed value is uniformly distributed.
+ *
+ * This approach isn't cryptographically secure. Consider using /dev/random
+ * or Math::TrulyRandom to get some real entropy.
+ */
+#define Perl_get_seed (long)(Perl_seed(aTHX) % 1073741824L)
+#else
+/* If we don't support seeds, return 0 so we can fall back to localtime for
+ * default seeding. There's a chance Perl_seed will return 0 and mask this,
+ * but in that case the data should still be "random enough" anyway.
+ */
+#define Perl_get_seed 0L
+#endif /* Perl_seed */
+

I did that so that if Perl_seed isn't available, it would fall back to
using 'time' (which is passed in as a parameter).
>
>
> Don Armstrong
>
> --
> It has always been Debian's philosophy in the past to stick to what
> makes sense, regardless of what crack the rest of the universe is
> smoking.
>  -- Andrew Suffield in 20030403211305.GD29698 at doc.ic.ac.uk
>
> http://www.donarmstrong.com              http://rzlab.ucr.edu
>
>
>
> _______________________________________________
> pkg-perl-maintainers mailing list
> pkg-perl-maintainers at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/pkg-perl-maintainers
>





More information about the pkg-perl-maintainers mailing list