bugfix to ensure that incoming SPA data in AES mode is a multiple of the Rjindael blocksize (16)

This commit is contained in:
Michael Rash
2012-02-10 15:10:19 -05:00
parent 6dbe523052
commit de41b0a1ec
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -249,8 +249,8 @@ rij_decrypt(unsigned char *in, size_t in_len,
/* 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);
+9
View File
@@ -139,6 +139,15 @@ _rijndael_decrypt(fko_ctx_t ctx, const char *dec_key, int encryption_mode)
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.
*/