--- a/src/cpp/core/system/Crypto.cpp.orig 2017-10-14 15:59:52.561983799 +0900 +++ b/src/cpp/core/system/Crypto.cpp 2017-10-14 15:58:24.504542511 +0900 @@ -261,27 +261,26 @@ Error aesEncrypt(const std::vectoroperator[](0)), &outlen, &data[0], data.size())) + if(!EVP_CipherUpdate(ctx, &(pEncrypted->operator[](0)), &outlen, &data[0], data.size())) { - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); return lastCryptoError(ERROR_LOCATION); } bytesEncrypted += outlen; // perform final flush including left-over padding - if(!EVP_CipherFinal_ex(&ctx, &(pEncrypted->operator[](outlen)), &outlen)) + if(!EVP_CipherFinal_ex(ctx, &(pEncrypted->operator[](outlen)), &outlen)) { - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); return lastCryptoError(ERROR_LOCATION); } bytesEncrypted += outlen; - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); // resize the container to the amount of actual bytes encrypted (including padding) pEncrypted->resize(bytesEncrypted); @@ -298,27 +297,26 @@ Error aesDecrypt(const std::vectoroperator[](0)), &outlen, &data[0], data.size())) + if(!EVP_CipherUpdate(ctx, &(pDecrypted->operator[](0)), &outlen, &data[0], data.size())) { - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); return lastCryptoError(ERROR_LOCATION); } bytesDecrypted += outlen; // perform final flush - if(!EVP_CipherFinal_ex(&ctx, &(pDecrypted->operator[](outlen)), &outlen)) + if(!EVP_CipherFinal_ex(ctx, &(pDecrypted->operator[](outlen)), &outlen)) { - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); return lastCryptoError(ERROR_LOCATION); } bytesDecrypted += outlen; - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); // resize the container to the amount of actual bytes decrypted (padding is removed) pDecrypted->resize(bytesDecrypted);