- Timestamp:
- Aug 23, 2010, 7:47:43 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/rijndael-alg-fst.c
r230 r291 15 15 #include <stdio.h> 16 16 #include <stdlib.h> 17 #include <string.h> 17 18 18 19 #ifdef SH_ENCRYPT … … 29 30 word8 tk[MAXKC][4]; 30 31 int KC = ROUNDS - 6; 32 word32 tmp; 31 33 32 34 for (j = KC-1; j >= 0; j--) { 33 *((word32*)tk[j]) = *((word32*)k[j]);35 memmove( &(tk[j]), &(k[j]), sizeof(word32)); 34 36 } 35 37 r = 0; 36 38 t = 0; 39 37 40 /* copy values into round key array */ 38 41 for (j = 0; (j < KC) && (r < ROUNDS + 1); ) { 39 42 for (; (j < KC) && (t < 4); j++, t++) { 40 *((word32*)W[r][t]) = *((word32*)tk[j]);41 }43 memmove( &(W[r][t]), &(tk[j]), sizeof(word32)); 44 } 42 45 if (t == 4) { 43 46 r++; … … 56 59 if (KC != 8) { 57 60 for (j = 1; j < KC; j++) { 58 *((word32*)tk[j]) ^= *((word32*)tk[j-1]); 61 tmp = *((word32*)tk[j-1]); 62 *((word32*)tk[j]) ^= tmp; 59 63 } 60 64 } else { 61 65 for (j = 1; j < KC/2; j++) { 62 *((word32*)tk[j]) ^= *((word32*)tk[j-1]); 66 tmp = *((word32*)tk[j-1]); 67 *((word32*)tk[j]) ^= tmp; 63 68 } 64 69 tk[KC/2][0] ^= S[tk[KC/2 - 1][0]]; … … 67 72 tk[KC/2][3] ^= S[tk[KC/2 - 1][3]]; 68 73 for (j = KC/2 + 1; j < KC; j++) { 69 *((word32*)tk[j]) ^= *((word32*)tk[j-1]); 74 tmp = *((word32*)tk[j-1]); 75 *((word32*)tk[j]) ^= tmp; 70 76 } 71 77 } … … 73 79 for (j = 0; (j < KC) && (r < ROUNDS + 1); ) { 74 80 for (; (j < KC) && (t < 4); j++, t++) { 75 *((word32*)W[r][t]) = *((word32*)tk[j]);81 memmove( &(W[r][t]), &(tk[j]), sizeof(word32)); 76 82 } 77 83 if (t == 4) {
Note:
See TracChangeset
for help on using the changeset viewer.