{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

# 86 wg barker cryptanalysis of the hagelin cryptograph

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: amp;ampc,data,1); a5_decrypt(&ampc,data+1,99); flag = 0; for(i=0;i<100;i++) if(data[i]!=i)flag = 1; if(flag)printf(“Decrypt failed\n”); else printf(“Decrypt succeeded\n”); } SEAL #undef SEAL_DEBUG #define ALG_OK 0 #define ALG_NOTOK 1 #define WORDS_PER_SEAL_CALL 1024 typedef struct { unsigned long t[520]; /* 512 rounded up to a multiple of 5 + 5*/ unsigned long s[265]; /* 256 rounded up to a multiple of 5 + 5*/ unsigned long r[20]; /* 16 rounded up to multiple of 5 */ unsigned long counter; /* 32–bit synch value. */ unsigned long ks_buf[WORDS_PER_SEAL_CALL]; int ks_pos; } seal_ctx; #define #define #define #define #define #define ROT2(x) (((x) >> 2) | ROT9(x) (((x) >> 9) | ROT8(x) (((x) >> 8) | ROT16(x) (((x) >> 16) ROT24(x) (((x) >> 24) ROT27(x) (((x) >> 27) ((x) << 30)) ((x) << 23)) ((x) << 24)) | ((x) << 16)) | ((x) << 8)) | ((x) << 5)) #define WORD(cp) #define #define #define #define F1(x, F2(x, F3(x, F4(x, y, y, y, y, ((cp[0] << 24)|(cp[1] << 16)|(cp[2] << 8)|(cp[3])) z) z) z) z) (((x) & (y)) | ((~(x)) & (z))) ((x)^(y)^(z)) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) ((x)^(y)^(z)) int g(in, i, h) unsigned char *in; int i; unsigned long *h; { unsigned long h0; unsigned long h1; unsigned long h2; unsigned long h3; unsigned long h4; unsigned unsigned unsigned unsigned unsigned unsigned unsigned kp h0 h1 h2 h3 h4 = = = = = = long long long long char long long a; b;unsigned long c; d; e; *kp; w[80]; temp; in; WORD(kp); WORD(kp); WORD(kp); WORD(kp); WORD(kp); kp kp kp kp kp += += += += += 4; 4; 4; 4; 4; w[0] = i; for (i=1;i<16;i++) w[i] = 0; for (i=16;i<80;i++) w[i] = w[i–3]^w[i–8]^w[i–14]^w[i–16]; a b c d e = = = = = h0; h1; h2; h3; h4; for (i=0;i<20;i++) { temp = ROT27(a) + F1(b, c, d) + e + w[i] + 0x5a827999; e = d; d = c; c = ROT2(b); b = a; a = temp; } for (i=20;i<40;i++) { temp = ROT27(a) + F2(b, c, d) + e + w[i] + 0x6ed9eba1; e = d; d = c; c = ROT2(b); b = a; a = temp; } for (i=40;i<60;i++) { temp = ROT27(a) + F3(b,...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online