Re: Problem with gmp_randinit_set

2017-03-03 Thread Pedro Gimeno
What I had in mind for the upper half, is something like this: gmp_uint_least32_t k[4]; ... k[0] = high_bit ? 0x4BEDAF6D : 0x5443092C; k[1] = high_bit ? 0x674DD5FB : 0xA67C9FE2; k[2] = high_bit ? 0xB79D42BC : 0x31CC686A; k[3] = high_bit ? 0x94C371EA : 0xC41175D6; Marco Bodrato wrote,

Re: Problem with gmp_randinit_set

2017-03-02 Thread Marco Bodrato
Ciao, Il Ven, 3 Marzo 2017 3:10 am, Pedro Gimeno ha scritto: > Marco Bodrato wrote, On 2017-03-02 21:37: > Just one comment. You're switching algorithms for the top half. Wouldn't > it be easier to change the key (the k[] array) instead? That might also > produce less correlation in the upper

Re: Problem with gmp_randinit_set

2017-02-21 Thread Pedro Gimeno
Marco Bodrato wrote, On 2017-02-21 15:21: > Problem: e is even! > value and (2^n-k-value) will be mangled to the same seed... > Well, these are more bugs then. I've wanted to replace that seeding routine since it was written. I was never happy with it, but I didn't find a suitable replacement

Re: Problem with gmp_randinit_set

2017-02-19 Thread Marco Bodrato
Ciao, Il Dom, 19 Febbraio 2017 9:21 am, Niels Möller ha scritto: > But shifting, as you suggest, might be simpler, using > > 2 B^623 = 20023 (mod p) A possible generalization follows: #include #include #include #include #define GSIZE (19937 / GMP_NUMB_BITS) #define GSHIFT (19937 %

Re: Problem with gmp_randinit_set

2017-02-17 Thread Niels Möller
ni...@lysator.liu.se (Niels Möller) writes: > It shouldn't be too hard to rewrite randseed_mt to use mpn_powm, right? > Which probably didn't exist when the original version was written. Or if we want to take advantage of the structure, we need an mpn function to reduce numbers modulo 2^19937 -

Re: Problem with gmp_randinit_set

2017-02-17 Thread Pedro Gimeno
Torbjörn Granlund wrote, On 2017-02-16 23:19: > Pedro Gimeno writes: > I haven't read you xxtea patch yet, but let's first see that we agree on > the theory! > > I believe the named modes ECB, CTR, ICM, whatnot don't necessarily apply > to PRNG use as we have no

Re: Problem with gmp_randinit_set

2017-02-16 Thread Torbjörn Granlund
Pedro Gimeno writes: With something like the attached? Perhaps. In fact I don't know why it isn't doing it now. Can that structure possibly come from disk or some other place that makes the pointers invalid? I guess not. That patch makes a lot of sense... I'll

Re: Problem with gmp_randinit_set

2017-02-16 Thread Torbjörn Granlund
Pedro Gimeno writes: I chose xxtea for being simple and small (as can be seen in the patch) and for having variable block size, so I could encrypt just 1 block of 19936 bits, eliminating the need to choose a suitable enciphering mode. For ciphers with smaller

Re: Problem with gmp_randinit_set

2017-02-14 Thread Pedro Gimeno
Torbjörn Granlund wrote, On 2017-02-15 03:40: > Pedro Gimeno writes: > > One possible fix would be to resurrect my patch for a different > seeding routine, which was based on the xxtea encryption > [...] > > I like the idea of applying a symmetric cipher for

Re: Problem with gmp_randinit_set

2017-02-14 Thread Torbjörn Granlund
Pedro Gimeno writes: Ah, yes, that was a problem that needed to be avoided. Thanks for looking into this. One possible fix would be to resurrect my patch for a different seeding routine, which was based on the xxtea encryption algorithm. That one is faster

Re: Problem with gmp_randinit_set

2017-02-14 Thread Pedro Gimeno
Torbjörn Granlund wrote, On 2017-02-15 00:45: > Pedro Gimeno writes: > > Torbjörn Granlund wrote, On 2017-02-14 01:41: > > > One can change Mersenne_Twister_Generator_Noseed to > > Mersenne_Twister_Generator to fix this (and move __gmp_randiset_mt to > >

Re: Problem with gmp_randinit_set

2017-02-14 Thread Torbjörn Granlund
Pedro Gimeno writes: Torbjörn Granlund wrote, On 2017-02-14 01:41: > One can change Mersenne_Twister_Generator_Noseed to > Mersenne_Twister_Generator to fix this (and move __gmp_randiset_mt to > randmts.c as mandated by Mersenne_Twister_Generator's scope), and

Re: Problem with gmp_randinit_set

2017-02-14 Thread Pedro Gimeno
Torbjörn Granlund wrote, On 2017-02-14 01:41: > One can change Mersenne_Twister_Generator_Noseed to > Mersenne_Twister_Generator to fix this (and move __gmp_randiset_mt to > randmts.c as mandated by Mersenne_Twister_Generator's scope), and then > your code supposedly runs without a crash. But I

Re: Problem with gmp_randinit_set

2017-02-13 Thread Torbjörn Granlund
gmp_randinit_set(b, a); gmp_randseed_ui(b, 123456); /* crashes */ AFAICT this is a gmp bug, but I don't rule out the possibility that it's a user bug. This looks like a GMP bug. I never looked properly through the GMP PRNG code, and looking at it now I don't immediately

Problem with gmp_randinit_set

2017-02-13 Thread sisyphus1
Hi, The following program crashes for me on MS Windows 7, gmp-6.1.2, when the line "gmp_randseed_ui(b, 123456);" is executed. I built gmp in the MSYS2 shell using gcc version 5.3.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project). Configure command was: ./configure CC="gcc