{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

fcn2ck1 fcn2ck3

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: 2, 9, 1, 24, 16, 8, 0 typedef short short struct { gen; exp; /* irreducible polynomial used in this field */ /* exponent used to generate this s function */ } sfn_desc; sfn_desc sfn = { { /* 101110111 { /* 110000111 { /* 110001101 { /* 110100011 { /* 110110001 { /* 111000011 { /* 111010111 { /* 111100111 { 00, 00} */ */ */ */ */ */ */ */ }; 375, 391, 397, 419, 433, 451, 471, 487, 31}, 31}, 31}, 31}, 31}, 31}, 31}, 31}, { { { { { { { { /* /* /* /* /* /* /* /* 101111011 110001011 110011111 110101001 110111101 111001111 111011101 111110011 */ */ */ */ */ */ */ */ 379, 395, 415, 425, 445, 463, 477, 499, 31}, 31}, 31}, 31}, 31}, 31}, 31}, 31}, typedef struct { Long loki_subkeys[ROUNDS]; } loki_ctx; static Long static short f(); s(); /* declare LOKI function f */ /* declare LOKI S–box fn s */ #define ROL12(b) b = ((b << 12) | (b >> 20)); #define ROL13(b) b = ((b << 13) | (b >> 19)); #ifdef LITTLE_ENDIAN #define bswap(cb) { register char c; c = cb[0]; cb[0] = c = cb[1]; cb[1] = c = cb[4]; cb[4] = c = cb[5]; cb[5] = } #endif cb[3]; cb[2]; cb[7]; cb[6]; cb[3] cb[2] cb[7] cb[6] = = = = c; c; c; c; \ \ \ \ \ \ void setlokikey(loki_ctx *c, char *key) { register i; register Long KL, KR; #ifdef LITTLE_ENDIAN bswap(key); /* swap bytes round if little–endian */ #endif KL = ((Long *)key)[0]; KR = ((Long *)key)[1]; for (i=0; i<ROUNDS; i+=4) { c–>loki_subkeys[i] = KL; ROL12 (KL); c–>loki_subkeys[i+1] = KL; ROL13 (KL); c–>loki_subkeys[i+2] = KR; ROL12 (KR); c–>loki_subkeys[i+3] = KR; ROL13 (KR); } #ifdef LITTLE_ENDIAN bswap(key); #endif } void enloki (loki_ctx *c, char *b) { register i; register Long L, R; #ifdef LITTLE_ENDIAN bswap(b); #endif L = ((Long *)b)[0]; R = ((Long *)b)[1]; /* Generate the 16 subkeys */ /* swap bytes back if little–endian */ /* left & right data halves */ /* swap bytes round if little–endian */ for (i=0; i<ROUNDS; i+=2) { /* Encrypt with the 16 subkeys */ L ^= f (R, c–>loki_subkeys[i]); R ^= f (L, c...
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