#include "stdio.h"
#include "memory.h"
#include "time.h"
#include "stdlib.h"
int DES_DecryptBlock(ElemType cipherBlock[8], ElemType subKeys[16][48],ElemType plainBlock[8])
{
ElemType cipherBits[64];
ElemType copyRight[48];
int cnt;
Char8ToBit64(cipherBlock,cipherBits);
DES_IP_Transform(cipherBits);
for(cnt = 15; cnt >= 0; cnt--)
{
memcpy(copyRight,cipherBits+32,32);
DES_E_Transform(copyRight);
DES_XOR(copyRight,subKeys[cnt],48);
DES_SBOX(copyRight);
DES_P_Transform(copyRight);
DES_XOR(cipherBits,copyRight,32);
if(cnt != 0)
{
DES_Swap(cipherBits,cipherBits+32);
}
}
DES_IP_1_Transform(cipherBits);
Bit64ToChar8(cipherBits,plainBlock);
return 0;
}