Ремонт принтеров, сканнеров, факсов и остальной офисной техники


назад Оглавление вперед




[202]

g(key, (i+0x1000)/5, &(result->s[i])); /* horrible special case for the end */ g(key, (254+0x1000)/5, h); for (i=254;i<256;i++)

result->s[i] = h[i-254];

/* 0x2000 mod 5 is +2, so have horrible special case at the start */ g(key, (-2+0x2000)/5, h); for (i=0;i<3;i++)

result->r[i] = h[i+2]; for (i=3;i<13;i+=5)

g(key, (i+0x2000)/5, &(result->r[i]));

/* horrible special case for the end */

g(key, (13+0x2000)/5, h); for (i=13;i<16;i++)

result->r[i] = h[i-13]; return (ALG OK);

int seal(seal ctx *key, unsigned long in, unsigned long *out)

int i; int j;

unsigned long a; unsigned long b; unsigned long c; unsigned long d; unsigned short p; unsigned short q; unsigned long n1; unsigned long n2; unsigned long n3; unsigned long n4; unsigned long *wp;

wp = out;

for (l=0;l<4;l++) {

a = in A key->r[4*l]; b = ROT8(in) л key->r[4*l+1]; c = ROT16(in) л key->r[4*l+2]; d = ROT24(in) л key->r[4*l+3];

for (j=0;j<2;j++)

p = a & 0x7fc;

b += key->t[p/4]; a = ROT9(a);

p = b & 0x7fc;

c += key->t[p/4];

b = ROT9(b); p = c & 0x7fc;

d += key->t[p/4]; c = ROT9(c);

p = d & 0x7fc;

a += key->t[p/4];

d = ROT9(d);


n1 = d; n2 = b;

n3 = a;

n4 = c;

p = a & 0x7fc; b += key->t[p/4]; a = ROT9(a);

p = b & 0x7fc;

c += key->t[p/4];

b = ROT9(b);

p = c & 0x7fc; d += key->t[p/4]; c = ROT9(c);

p = d & 0x7fc; a += key->t[p/4]; d = ROT9(d);

/* This generates 64 32-bit words, or 256 bytes of keystream. */

for (i=0;i<64;i++)

p = a & 0x7fc;

b += key->t[p/4]; a = ROT9(a);

b A= a;

q = b & 0x7fc;

c л= key->t[q/4];

b = ROT9(b);

c += b;

p = (p+c) & 0x7fc;

d += key->t[p/4]; c = ROT9(c);

d A= c;

q = (q+d) & 0x7fc; a л= key->t[q/4]; d = ROT9(d);

a += d;

p = (p+a) & 0x7fc; b л= key->t[p/4];

a = ROT9(a);

q = (q+b) & 0x7fc;

c += key->t[q/4];

b = ROT9(b);

p = (p+c) & 0x7fc; d л= key->t[p/4];

c = ROT9(c);

q = (q+d) & 0x7fc;

a += key->t[q/4];

d = ROT9(d);

*wp = b + key->s[4*i];


*wp =c A key->s[4*i+1]; wp++;

*wp =d + key->s[4*i+2];

*wp = a A key->s[4*i+3]; wp++;

if (i & 1)

a += n3; c += n4;

a += n1;

c += n2;

return (ALG OK);

/* Added call to refill ks buf and reset counter and ks pos. */ void seal refill buffer(seal ctx *c){

seal(c,c->counter,c->ks buf);

c->counter++;

c->ks pos = 0;

void seal key(seal ctx *c, unsigned char *key){ seal init(c,key);

c->counter = 0; /* By default, init to zero. */

c->ks pos = WORDS PER SEAL CALL;

/* Refill keystream buffer on next call. */

/* This encrypts the next w words with SEAL. */

void seal encrypt(seal ctx *c, unsigned long *data ptr, int w){ int i;

for(i=0;i<w;i++){

if(c->ks pos>=WORDS PER SEAL CALL) seal refill buffer(c);

data ptr[i]A=c->ks buf[c->ks pos]; c->ks pos++;

void seal decrypt(seal ctx *c, unsigned long *data ptr, int w) { seal encrypt(c,data ptr,w);

void seal resynch(seal ctx *c, unsigned long synch word){ c->counter = synch word;

c->ks pos = WORDS PER SEAL CALL;

void main(void){

seal ctx sc;

unsigned long buf[1000],t;



[стр.Начало] [стр.1] [стр.2] [стр.3] [стр.4] [стр.5] [стр.6] [стр.7] [стр.8] [стр.9] [стр.10] [стр.11] [стр.12] [стр.13] [стр.14] [стр.15] [стр.16] [стр.17] [стр.18] [стр.19] [стр.20] [стр.21] [стр.22] [стр.23] [стр.24] [стр.25] [стр.26] [стр.27] [стр.28] [стр.29] [стр.30] [стр.31] [стр.32] [стр.33] [стр.34] [стр.35] [стр.36] [стр.37] [стр.38] [стр.39] [стр.40] [стр.41] [стр.42] [стр.43] [стр.44] [стр.45] [стр.46] [стр.47] [стр.48] [стр.49] [стр.50] [стр.51] [стр.52] [стр.53] [стр.54] [стр.55] [стр.56] [стр.57] [стр.58] [стр.59] [стр.60] [стр.61] [стр.62] [стр.63] [стр.64] [стр.65] [стр.66] [стр.67] [стр.68] [стр.69] [стр.70] [стр.71] [стр.72] [стр.73] [стр.74] [стр.75] [стр.76] [стр.77] [стр.78] [стр.79] [стр.80] [стр.81] [стр.82] [стр.83] [стр.84] [стр.85] [стр.86] [стр.87] [стр.88] [стр.89] [стр.90] [стр.91] [стр.92] [стр.93] [стр.94] [стр.95] [стр.96] [стр.97] [стр.98] [стр.99] [стр.100] [стр.101] [стр.102] [стр.103] [стр.104] [стр.105] [стр.106] [стр.107] [стр.108] [стр.109] [стр.110] [стр.111] [стр.112] [стр.113] [стр.114] [стр.115] [стр.116] [стр.117] [стр.118] [стр.119] [стр.120] [стр.121] [стр.122] [стр.123] [стр.124] [стр.125] [стр.126] [стр.127] [стр.128] [стр.129] [стр.130] [стр.131] [стр.132] [стр.133] [стр.134] [стр.135] [стр.136] [стр.137] [стр.138] [стр.139] [стр.140] [стр.141] [стр.142] [стр.143] [стр.144] [стр.145] [стр.146] [стр.147] [стр.148] [стр.149] [стр.150] [стр.151] [стр.152] [стр.153] [стр.154] [стр.155] [стр.156] [стр.157] [стр.158] [стр.159] [стр.160] [стр.161] [стр.162] [стр.163] [стр.164] [стр.165] [стр.166] [стр.167] [стр.168] [стр.169] [стр.170] [стр.171] [стр.172] [стр.173] [стр.174] [стр.175] [стр.176] [стр.177] [стр.178] [стр.179] [стр.180] [стр.181] [стр.182] [стр.183] [стр.184] [стр.185] [стр.186] [стр.187] [стр.188] [стр.189] [стр.190] [стр.191] [стр.192] [стр.193] [стр.194] [стр.195] [стр.196] [стр.197] [стр.198] [стр.199] [стр.200] [стр.201] [стр.202] [стр.203]