1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| void mydeaes(char *p, char * iv,int plen, char *key){
int pArray0[4][4]; int pArray1[4][4]; int pIv[4][4]; int k=0; char key_use[16];
convertToIntArray(iv, pIv);
for(int k1 = 31; k1 >= 0; k1 -= 1) {
memcpy(key_use, key, 16); getRoundIvAndKey(k1, iv, key_use, pIv); extendKey(key_use);
convertToIntArray(&p[16], pArray1); convertToIntArray(&p[0], pArray0);
addRoundKey(pArray1, 10); for(int i = 9; i >= 1; i--) { mydeshift(pArray1); deSubBytes(pArray1); addRoundKey(pArray1, i);
myTranspose(pArray1); deMixColumns(pArray1); myTranspose(pArray1); } mydeshift(pArray1); deSubBytes(pArray1); addRoundKey(pArray1, 0);
for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { pArray1[i][j] ^= pArray0[i][j]; } }
addRoundKey(pArray0, 10); for(int i = 9; i >= 1; i--) { mydeshift(pArray0); deSubBytes(pArray0); addRoundKey(pArray0, i);
myTranspose(pArray0); deMixColumns(pArray0); myTranspose(pArray0); } mydeshift(pArray0); deSubBytes(pArray0); addRoundKey(pArray0, 0);
for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { pArray0[i][j] ^= pIv[i][j]; } } convertArrayToStr(pArray0, &p[0]); convertArrayToStr(pArray1, &p[16]); } }
|