{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

# 112 i benaroya and e biham differential cryptanalysis

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: += key–>t[p/4]; d = ROT9(d); } n1 n2 n3 n4 = = = = d; b; a; 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; q c b c p d c d q a d a = b & 0x7fc; ^= key–>t[q/4]; = ROT9(b); += b; = (p+c) & 0x7fc; += key–>t[p/4]; = ROT9(c); ^= c; = (q+d) & 0x7fc; ^= key–>t[q/4]; = ROT9(d); += 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 = wp++; *wp = wp++; *wp = wp++; *wp = wp++; b + key–>s[4*i]; c ^ key–>s[4*i+1]; d + key–>s[4*i+2]; a ^ key–>s[4*i+3]; if (i & 1) { a += n3; c += n4; } else { 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]^=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; int i,flag; unsig...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online