{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

applied cryptography - protocols, algorithms, and source code in c

19 n 12 jun 1983 pp 442444 99 h beker and f piper

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c, d) + e + w[i] + 0x8f1bbcdc; e = d; d = c; c = ROT2(b); b = a; a = temp; } for (i=60;i<80;i++) { temp = ROT27(a) + F4(b, c, d) + e + w[i] + 0xca62c1d6; e = d; d = c; c = ROT2(b); b = a; a = temp; } h[0] = h0+a; h[1] = h1+b; h[2] = h2+c; h[3] = h3+d; h[4] = h4+e; return (ALG_OK); } unsigned long gamma(a, i) unsigned char *a; int i; { unsigned long h[5]; (void) g(a, i/5, h); return h[i % 5]; } int seal_init(seal_ctx *result, unsigned char *key) { int i; unsigned long h[5]; for (i=0;i<510;i+=5) g(key, i/5, &(result–>t[i])); /* horrible special case for the end */ g(key, 510/5, h); for (i=510;i<512;i++) result–>t[i] = h[i–510]; /* 0x1000 mod 5 is +1, so have horrible special case for the start */ g(key, (–1+0x1000)/5, h); for (i=0;i<4;i++) result–>s[i] = h[i+1]; for (i=4;i<254;i+=5) 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; int l; 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 ^ 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...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online