bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with Random Numbers


From: Dr. Adam J. Elbirt
Subject: Help with Random Numbers
Date: Wed, 28 Nov 2007 13:39:34 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)

I'm running into two problems related to the use of the mpz_urandomb function:

1. I always get the same number.
2. The number is 32 bits instead of 256 bits.

Sample code:

        mpz_init(modulus);
        mpz_init_set_str(modulus,
"830BD41A71825C6AEAF89AC06FEA5B51E65601E6E1273AC30BE6644F3F80F766B94BC3C2888452C0192B2562E1EC386A7C9B22F92BF597A6694CFB65146A6180BF567357707CBB4F222057266A1891AF416AF4814AEC2F495A4A16D7173857C64BE0FD530D80D98730D7CB5574ACB2FCFA41215A93C1675D17E11EA7743E913B",
16);

        mpz_init(exponent_256);
        gmp_randinit_default(exponent_seed);
        gmp_randseed(exponent_seed, modulus);
        mpz_urandomb(exponent_256, exponent_seed, 256);

        for(n=0; n<1000; n++)
        {
                for(k=255; k>=0; k--)
                {
                        ...
                }
                mpz_urandomb(exponent_256, exponent_seed, 256);
        }


Any help as to how to fix this would be greatly appreciated.

Adam
-- 

Dr. Adam J. Elbirt
Director - Information Security Laboratory
Associate Director - Center for Network and Information Security
Assistant Professor
Department of Computer Science
One University Avenue
215 Olsen Hall
Lowell, MA  01854
address@hidden
address@hidden
978-934-3328 Office
978-934-3551 FAX
http://faculty.uml.edu/aelbirt

reply via email to

[Prev in Thread] Current Thread [Next in Thread]