int main (void)
{
UCHAR ucEncryptKey[16] = {0};
UCHAR ucDecryptKey[16] = {0};
AES_KEY aesEncryptKey;
AES_KEY aesDecryptKey;
UCHAR ucInData[512] = {0};
UCHAR ucEncryptOutData[512] = {0};
UCHAR ucDecryptOutData[512] = {0};
INT ucIndex;
memcpy(ucEncryptKey, "xiaoji-dun-mo-gu", 16);
memcpy(ucDecryptKey, "xiaoji-dun-mo-gu", 16);
for (ucIndex = 0; ucIndex < 512; ucIndex++) {
ucInData[ucIndex] = (ucIndex % 256) + 1;
}
printf("before encrypt = ");
for (ucIndex = 0; ucIndex < 512; ucIndex++) {
printf("%02x ", ucInData[ucIndex]);
}
printf("\n\n");
AES_set_encrypt_key(ucEncryptKey, 128, &aesEncryptKey);
for (ucIndex = 0; ucIndex < 32; ucIndex++) {
AES_ecb_encrypt(ucInData + 16 * ucIndex, ucEncryptOutData + 16 * ucIndex, &aesEncryptKey, AES_ENCRYPT);
}
printf("after encrypt = ");
for (ucIndex = 0; ucIndex < 512; ucIndex++) {
printf("%02x ", ucEncryptOutData[ucIndex]);
}
printf("\n\n");
AES_set_decrypt_key(ucDecryptKey, 128, &aesDecryptKey);
for (ucIndex = 0; ucIndex < 32; ucIndex++) {
AES_ecb_encrypt(ucEncryptOutData + 16 * ucIndex, ucDecryptOutData + 16 * ucIndex, &aesDecryptKey, AES_DECRYPT);
}
printf("after decrypt = ");
for (ucIndex = 0; ucIndex < 512; ucIndex++) {
printf("%02x ", ucDecryptOutData[ucIndex]);
}
printf("\n\n");
return 0;
}