Code:
//Module name test.c
//Compile:
//cl /DINTERMEDIATE_VALUE_KAT /DTRACE_KAT_MCT test.c rijndael-alg-fst.c rijndael-api-fst.c
#include <stdio.h>
#include <string.h>
#include "rijndael-api-fst.h"
int main(void) {
u8 input[16];
u8 output[16];
int i, keyLength = 128;
keyInstance keyInst;
BYTE keyMaterial[320];
cipherInstance cipherInst;
memset(keyMaterial, 0, sizeof (keyMaterial));
for (i = 0; i < keyLength/8; i++) {
sprintf(&keyMaterial[2*i], "%02X", i);
}
sprintf(input, "Gumit was here!!");
/* encryption */
makeKey(&keyInst, DIR_ENCRYPT, keyLength, keyMaterial);
cipherInit(&cipherInst, MODE_ECB, NULL);
blockEncrypt(&cipherInst, &keyInst, input, 128, output);
/* decryption: */
makeKey(&keyInst, DIR_DECRYPT, keyLength, keyMaterial);
cipherInit(&cipherInst, MODE_ECB, NULL);
memset(input, 0, sizeof input);
blockDecrypt(&cipherInst, &keyInst, output, 128, input);
for (i = 0; i < 16; i++)
printf("%c",input[i]);
printf("\n");
return 0;
}