correction des malloc des AES_EVP_CONTEXT utilisation des fonctions proposé par openSSL
This commit is contained in:
parent
714d30e8d7
commit
34e67caa15
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
bin/*
|
||||||
|
obj/*
|
||||||
|
|
||||||
|
!.empty
|
4
Makefile
4
Makefile
@ -5,7 +5,7 @@ main: main.cpp jsoncpp.o
|
|||||||
@echo "compilation de aes"
|
@echo "compilation de aes"
|
||||||
@g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) obj/jsoncpp.o -lcrypto --std=c++14
|
@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"
|
@echo "compilation de jsoncpp"
|
||||||
@g++ -I ../lib/jsoncpp-master/include/ -Wall -Wextra -std=c++11 -c -ggdb jsoncpp.cpp -o obj/jsoncpp.o
|
@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:
|
run:
|
||||||
@./$(EXEC) file
|
@./$(EXEC) file
|
||||||
|
|
||||||
decrypt.ex: mainDecrypt.cpp jsoncpp.o aes.hpp
|
decrypt.ex: mainDecrypt.cpp obj/jsoncpp.o aes.hpp
|
||||||
@echo "compilation de decrypt.ex"
|
@echo "compilation de decrypt.ex"
|
||||||
@g++ -Wall -Wextra -ggdb -o bin/decrypt.ex mainDecrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14
|
@g++ -Wall -Wextra -ggdb -o bin/decrypt.ex mainDecrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14
|
||||||
|
|
||||||
|
0
bin/.empty
Normal file
0
bin/.empty
Normal file
13
decrypt.hpp
13
decrypt.hpp
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class decrypt : public aes {
|
class decrypt : public aes {
|
||||||
private:
|
private:
|
||||||
EVP_CIPHER_CTX* aesDecryptCtx;
|
EVP_CIPHER_CTX* aesDecryptCtx;
|
||||||
public:
|
public:
|
||||||
decrypt(std::string filename, unsigned char* aesKey=0, unsigned char* aesIV=0);
|
decrypt(std::string filename, unsigned char* aesKey=0, unsigned char* aesIV=0);
|
||||||
decrypt(const decrypt& a);
|
decrypt(const decrypt& a);
|
||||||
@ -16,7 +16,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
decrypt::decrypt(std::string filename, unsigned char* aesKey, unsigned char* aesIV) : aes(filename) {
|
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) {
|
if(aesDecryptCtx == NULL) {
|
||||||
exit(FAILURE);
|
exit(FAILURE);
|
||||||
}
|
}
|
||||||
@ -31,7 +32,8 @@ decrypt::decrypt(std::string filename, unsigned char* aesKey, unsigned char* aes
|
|||||||
|
|
||||||
decrypt::decrypt(const decrypt& _a) : aes::aes() {
|
decrypt::decrypt(const decrypt& _a) : aes::aes() {
|
||||||
this->clone(_a);
|
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) {
|
if(aesDecryptCtx == NULL) {
|
||||||
exit(FAILURE);
|
exit(FAILURE);
|
||||||
}
|
}
|
||||||
@ -77,7 +79,8 @@ int decrypt::aesDecrypt(unsigned char *encMsg, size_t encMsgLen, unsigned char *
|
|||||||
decrypt::~decrypt() {
|
decrypt::~decrypt() {
|
||||||
aes::clear_all();
|
aes::clear_all();
|
||||||
EVP_CIPHER_CTX_cleanup(aesDecryptCtx);
|
EVP_CIPHER_CTX_cleanup(aesDecryptCtx);
|
||||||
free(aesDecryptCtx);
|
EVP_CIPHER_CTX_free(aesDecryptCtx);
|
||||||
|
//free(aesDecryptCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
0
obj/.empty
Normal file
0
obj/.empty
Normal file
Loading…
Reference in New Issue
Block a user