AES implementation not working
I made a simple AES implementation but it fails to parse data above 100byte for some reason.
Code:
char *dbuf;
dbuf = malloc(10240000);
in = 0;
n = (strlen(fbuffer)) / 16; //cycle times
for (j=0; j<n; j++)
{
for(i = 0; i < 16; i++)
{
if (j > 0) {
in = j * 16; };
ctext[i] = fbuffer[i+in];
};
ctext[16]='\0';
aes_decrypt(ctx, ctext, ptext);
ptext[16]='\0';
strcat(dbuf, ptext);
};
dbuf[(strlen(fbuffer))] = '\0';
For some reason it stops decrypting it correctly above about 100byte and just prints out garbage.
I can't figure out why. Hopefully it is a simple problem to solve.