From 34e67caa1553c4bfa87f855ea4ca42e453ad6c01 Mon Sep 17 00:00:00 2001 From: antoine Date: Wed, 19 Jul 2017 11:44:33 +0200 Subject: [PATCH] =?UTF-8?q?correction=20des=20malloc=20des=20AES=5FEVP=5FC?= =?UTF-8?q?ONTEXT=20utilisation=20des=20fonctions=20propos=C3=A9=20par=20o?= =?UTF-8?q?penSSL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ Makefile | 4 ++-- bin/.empty | 0 decrypt.hpp | 13 ++++++++----- obj/.empty | 0 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 bin/.empty create mode 100644 obj/.empty diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5941e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/* +obj/* + +!.empty diff --git a/Makefile b/Makefile index 730b3c9..f79e80b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ main: main.cpp jsoncpp.o @echo "compilation de aes" @g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) obj/jsoncpp.o -lcrypto --std=c++14 -jsoncpp.o: jsoncpp.cpp json/json.h json/json-forwards.h +obj/jsoncpp.o: jsoncpp.cpp json/json.h json/json-forwards.h @echo "compilation de jsoncpp" @g++ -I ../lib/jsoncpp-master/include/ -Wall -Wextra -std=c++11 -c -ggdb jsoncpp.cpp -o obj/jsoncpp.o @@ -15,7 +15,7 @@ run2: run: @./$(EXEC) file -decrypt.ex: mainDecrypt.cpp jsoncpp.o aes.hpp +decrypt.ex: mainDecrypt.cpp obj/jsoncpp.o aes.hpp @echo "compilation de decrypt.ex" @g++ -Wall -Wextra -ggdb -o bin/decrypt.ex mainDecrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14 diff --git a/bin/.empty b/bin/.empty new file mode 100644 index 0000000..e69de29 diff --git a/decrypt.hpp b/decrypt.hpp index 8c082bd..de5e2f4 100644 --- a/decrypt.hpp +++ b/decrypt.hpp @@ -5,7 +5,7 @@ class decrypt : public aes { private: - EVP_CIPHER_CTX* aesDecryptCtx; + EVP_CIPHER_CTX* aesDecryptCtx; public: decrypt(std::string filename, unsigned char* aesKey=0, unsigned char* aesIV=0); decrypt(const decrypt& a); @@ -16,7 +16,8 @@ public: }; decrypt::decrypt(std::string filename, unsigned char* aesKey, unsigned char* aesIV) : aes(filename) { - aesDecryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); + aesDecryptCtx = EVP_CIPHER_CTX_new(); + //aesDecryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); if(aesDecryptCtx == NULL) { exit(FAILURE); } @@ -31,7 +32,8 @@ decrypt::decrypt(std::string filename, unsigned char* aesKey, unsigned char* aes decrypt::decrypt(const decrypt& _a) : aes::aes() { this->clone(_a); - aesDecryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); + aesDecryptCtx = EVP_CIPHER_CTX_new(); + //aesDecryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); if(aesDecryptCtx == NULL) { exit(FAILURE); } @@ -77,7 +79,8 @@ int decrypt::aesDecrypt(unsigned char *encMsg, size_t encMsgLen, unsigned char * decrypt::~decrypt() { aes::clear_all(); EVP_CIPHER_CTX_cleanup(aesDecryptCtx); - free(aesDecryptCtx); + EVP_CIPHER_CTX_free(aesDecryptCtx); + //free(aesDecryptCtx); } -#endif \ No newline at end of file +#endif diff --git a/obj/.empty b/obj/.empty new file mode 100644 index 0000000..e69de29