/* Remove the first block since it contains the salt (it was consumed
* by the rijndael_init() function above).
*/
- in_len -= 16;
- memmove(in, in+16, in_len);
+ in_len -= RIJNDAEL_BLOCKSIZE;
+ memmove(in, in+RIJNDAEL_BLOCKSIZE, in_len);
block_decrypt(&ctx, in, in_len, out, ctx.iv);
cipher_len = b64_decode(ctx->encrypted_msg, cipher);
+ /* Since we're using AES, make sure the incoming data is a multiple of
+ * the blocksize
+ */
+ if((cipher_len % RIJNDAEL_BLOCKSIZE) != 0)
+ {
+ free(cipher);
+ return(FKO_ERROR_INVALID_DATA);
+ }
+
/* Create a bucket for the plaintext data and decrypt the message
* data into it.
*/