{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

e wi 0xca62c1d6 e d d c c rot2b b a a

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (j = 0; j < 256; j += 2) { Blowfish_encipher(c,&ampdatal, &ampdatar); c–>S[i][j] = datal; c–>S[i][j + 1] = datar; } } } void blf_key(blf_ctx *c, char *k, int len){ InitializeBlowfish(c,k,len); } void blf_enc(blf_ctx *c, unsigned long *data, int blocks){ unsigned long *d; int i; d = data; for(i=0;i<blocks;i++){ Blowfish_encipher(c,d,d+1); d += 2; } } void blf_dec(blf_ctx *c, unsigned long *data, int blocks){ unsigned long *d; int i; d = data; for(i=0;i<blocks;i++){ Blowfish_decipher(c,d,d+1); d += 2; } } void main(void){ blf_ctx c; char key=“AAAAA”; unsigned long data[10]; int i; for(i=0;i<10;i++) data[i] = i; blf_key(&ampc,key,5); blf_enc(&ampc,data,5); blf_dec(&ampc,data,1); blf_dec(&ampc,data+2,4); for(i=0;i<10;i+=2) printf(“Block %01d decrypts to: %08lx %08lx.\n”, i/2,data[i],data[i+1]); } 3–Way #define #define #define typedef STRT_E STRT_D NMBR 0×0b0b /* round constant of first encryption round */ 0xb1b1 /* round constant of first decryption round */ 11 /* number of rounds is 11 */ unsigned long int word32 ; /* the program only works correctly if long = 32bits */ typedef unsigned long u4; typedef unsigned char u1; typedef struct { u4 k[3],ki[3], ercon[NMBR+1],drcon[NMBR+1]; } twy_ctx; /* Note: encrypt and decrypt expect full blocks––padding blocks is caller’s responsibility. All bulk encryption is done in ECB mode by these calls. Other modes may be added easily enough. */ /* destroy: Context. */ /* Scrub context of all sensitive data. */ void twy_destroy(twy_ctx *); /* encrypt: Context, ptr to data block, # of blocks. */ void twy_enc(twy_ctx *, u4 *, int); /* decrypt: Context, ptr to data block, # of blocks. */ void twy_dec(twy_ctx *, u4 *, int); /* key: Context, ptr to key data. */ void twy_key(twy_ctx *, u4 *); /* ACCODE––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */ /* End of AC code pr...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern