553d4c3a

( )


: int unsigned 4 .

, :

//

// - (2^11)-1

// fi(x) = 1(+)x^2(+)x^11

unsigned NextMValue(unsigned prev)

{

register unsigned c = 0;

if(prev & (1<<1))

c++;

if(prev & (1<<10))

c++;

return (prev<<1)|(c&1);

}

prev , , .

, :

//

// 32-

// fi(x) = 1(+)x^1(+)x^27(+)x^28(+)x^32

unsigned NextSignature32

­(unsigned prev, unsigned newbit)

{

if(prev&(1<<0))

newbit++;

if(prev&(1<<26))

newbit++;

if(prev&(1<<27))

newbit++;

if(prev&(1<<31))

newbit++;

return (prev<<1)|(newbit&1);

}

:

unsigned char * generate_gamma(unsigned char *pw, unsigned pwlen, unsigned gamma_len, unsigned char * gamma = NULL)

{

const

gb_len = 256;

static int

polynomial[] = { 1, 5, 23, 171, 243, 1057, 2047, -1 };

//polynomial[] = { 1, 18, 20, 39, -1 }; // 2^40 - 1

static unsigned char

buf[gb_len+1];

memset(buf, 0, sizeof(buf));

if(pwlen)

for(int i = 0; i < gb_len; i++)

buf[i+1] = pw[i%pwlen];

else