--- libaitio/src/crypt.c 2011/10/07 09:14:41 1.3.8.1 +++ libaitio/src/crypt.c 2011/10/07 10:32:36 1.3.8.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: crypt.c,v 1.3.8.1 2011/10/07 09:14:41 misho Exp $ +* $Id: crypt.c,v 1.3.8.2 2011/10/07 10:32:36 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -176,14 +176,15 @@ io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp * @inLen = Input buffer data length * @ppOutput = Output buffer with cipher data, must be free after use * @pKey = Key + * @IV = IVector/Nonce/Counter * return: -1 error or >-1 how many cipher blocks proceeded */ int -io_ctr_AES(u_char *pInput, int inLen, u_char **ppOutput, u_char *pKey) +io_ctr_AES(u_char *pInput, int inLen, u_char **ppOutput, u_char *pKey, u_char IV[AES_BLOCK_SIZE]) { u_int num; AES_KEY key; - u_char ivec[AES_BLOCK_SIZE] = { 0 }, ecount_buf[AES_BLOCK_SIZE] = { 0 }; + u_char ecount_buf[AES_BLOCK_SIZE] = { 0 }; int total = 0; if (!pInput || !inLen || !ppOutput) @@ -203,7 +204,7 @@ io_ctr_AES(u_char *pInput, int inLen, u_char **ppOutpu memset(ecount_buf, 0, sizeof ecount_buf); AES_ctr128_encrypt(pInput + total, (*ppOutput) + total, (inLen / (AES_BLOCK_SIZE - 1)) ? (AES_BLOCK_SIZE - 1) : inLen, - &key, ivec, ecount_buf, &num); + &key, IV, ecount_buf, &num); if (num < 1) { free(*ppOutput); *ppOutput = NULL;