--- libaitio/src/crypt.c 2012/08/02 00:47:47 1.8 +++ libaitio/src/crypt.c 2013/03/13 14:54:39 1.9 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: crypt.c,v 1.8 2012/08/02 00:47:47 misho Exp $ +* $Id: crypt.c,v 1.9 2013/03/13 14:54:39 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -51,7 +51,7 @@ SUCH DAMAGE. * * @pInput = input buffer * @inLen = input buffer len - * @ppOutput = output allocated buffe, must be io_free after use + * @ppOutput = output allocated buffe, must be e_free after use * @Cipher = cipher engine, like EVP_bf_cbc() or etc... * @pKey = key * @pIV = IV, salt (8 bytes) @@ -68,7 +68,7 @@ ioCipher(u_char *pInput, int inLen, u_char **ppOutput, if (!pInput || !inLen || !ppOutput || nMode & 0xFFFFFFFE) return 0; - buf = io_malloc(inLen + EVP_MAX_BLOCK_LENGTH); + buf = e_malloc(inLen + EVP_MAX_BLOCK_LENGTH); if (!buf) { LOGERR; goto end; @@ -84,7 +84,7 @@ ioCipher(u_char *pInput, int inLen, u_char **ppOutput, if (!EVP_CipherUpdate(&ctx, buf + outlen, &buflen, pos, chunk)) { EVP_CIPHER_CTX_cleanup(&ctx); outlen = 0; - io_free(buf); + e_free(buf); buf = NULL; goto end; } else { @@ -97,7 +97,7 @@ ioCipher(u_char *pInput, int inLen, u_char **ppOutput, } if (!EVP_CipherFinal_ex(&ctx, buf + outlen, &buflen)) { outlen = 0; - io_free(buf); + e_free(buf); buf = NULL; } else outlen += buflen; @@ -113,7 +113,7 @@ end: * * @pInput = input buffer * @inLen = input buffer len - * @ppOutput = output allocated buffe, must be io_free after use + * @ppOutput = output allocated buffe, must be e_free after use * @pKey = key * @pIV = IV, salt (8 bytes) * @nMode = Mode 0 - decrypting or 1 - encrypting @@ -132,10 +132,10 @@ io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp if (nMode) { len = strlen((char*) pInput); - str = io_strdup((char*) pInput); + str = e_strdup((char*) pInput); } else { len = strlen((char*) pInput) / 2; - str = io_malloc(len + 1); + str = e_malloc(len + 1); if (!str) { LOGERR; return 0; @@ -149,11 +149,11 @@ io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp } ret = len = ioCipher((u_char*) str, len, &buf, EVP_bf_cbc(), pKey, pIV, nMode); - io_free(str); + e_free(str); if (nMode) { ret *= 2; - *ppOutput = io_malloc(ret + 1); + *ppOutput = e_malloc(ret + 1); if (!*ppOutput) { LOGERR; return 0; @@ -167,7 +167,7 @@ io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp } } else if (ret && buf) - *ppOutput = (u_char*) io_strdup((char*) buf); + *ppOutput = (u_char*) e_strdup((char*) buf); return ret; } @@ -177,7 +177,7 @@ io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp * * @pInput = Input buffer with ASCII * @inLen = Input buffer data length - * @ppOutput = Output buffer with cipher data, must be io_free after use + * @ppOutput = Output buffer with cipher data, must be e_free after use * @pKey = Key * @IV = IVector/Nonce/Counter, Warning: IV must be variable, because we write there!!! * return: -1 error or >-1 how many cipher blocks proceeded @@ -193,7 +193,7 @@ io_ctr_AES(u_char *pInput, int inLen, u_char **ppOutpu if (!pInput || !inLen || !ppOutput) return -1; - *ppOutput = io_malloc(inLen); + *ppOutput = e_malloc(inLen); if (!*ppOutput) { LOGERR; return -1; @@ -209,7 +209,7 @@ io_ctr_AES(u_char *pInput, int inLen, u_char **ppOutpu (inLen / (AES_BLOCK_SIZE - 1)) ? (AES_BLOCK_SIZE - 1) : inLen, &key, IV, ecount_buf, &num); if (num < 1) { - io_free(*ppOutput); + e_free(*ppOutput); *ppOutput = NULL; total = -1; break;