diff --git a/crypt.hpp b/crypt.hpp index e272add..b4aca98 100644 --- a/crypt.hpp +++ b/crypt.hpp @@ -16,7 +16,8 @@ public: }; crypt::crypt(std::string filename) : aes(filename) { - aesEncryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); + aesEncryptCtx = EVP_CIPHER_CTX_new(); + //aesEncryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); if(aesEncryptCtx == NULL) { exit(FAILURE); } @@ -24,9 +25,9 @@ crypt::crypt(std::string filename) : aes(filename) { } crypt::crypt(const crypt& _a) : aes::aes() { - this->clone(_a); - - aesEncryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); + this->clone(_a); + aesEncryptCtx = EVP_CIPHER_CTX_new(); + //aesEncryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); if(aesEncryptCtx == NULL) { exit(FAILURE); } @@ -69,7 +70,8 @@ int crypt::aesEncrypt(const unsigned char *msg, size_t msgLen, unsigned char **e crypt::~crypt() { aes::clear_all(); EVP_CIPHER_CTX_cleanup(aesEncryptCtx); - free(aesEncryptCtx); + EVP_CIPHER_CTX_free(aesEncryptCtx); + //free(aesEncryptCtx); } -#endif \ No newline at end of file +#endif diff --git a/data/file.enc b/data/file.enc index 730793c..958a5c9 100644 --- a/data/file.enc +++ b/data/file.enc @@ -1 +1 @@ -?aY|A \ No newline at end of file +e֗0?Γma \ No newline at end of file diff --git a/data/file.key b/data/file.key new file mode 100644 index 0000000..c8e663a --- /dev/null +++ b/data/file.key @@ -0,0 +1,4 @@ +{ + "IV" : "9魔\u0016FC6\u0001\"QX4QkU", + "key" : "\u0002\u0014\u0005\u0019=\u0006RxCIe\u0018Lczsz" +} \ No newline at end of file diff --git a/decrypt.hpp b/decrypt.hpp index de5e2f4..5f08097 100644 --- a/decrypt.hpp +++ b/decrypt.hpp @@ -31,9 +31,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_new(); - //aesDecryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); + this->clone(_a); + aesDecryptCtx = EVP_CIPHER_CTX_new(); if(aesDecryptCtx == NULL) { exit(FAILURE); } @@ -80,7 +79,6 @@ decrypt::~decrypt() { aes::clear_all(); EVP_CIPHER_CTX_cleanup(aesDecryptCtx); EVP_CIPHER_CTX_free(aesDecryptCtx); - //free(aesDecryptCtx); } #endif diff --git a/jsoncpp.o b/jsoncpp.o new file mode 100644 index 0000000..44cf9c2 Binary files /dev/null and b/jsoncpp.o differ diff --git a/mainCrypt.cpp b/mainCrypt.cpp index 9dd51c7..17cded5 100644 --- a/mainCrypt.cpp +++ b/mainCrypt.cpp @@ -15,7 +15,6 @@ int main(int argc, char* argv[]) { //******************************************************************* while a rajouté pour les gros fichier // readFile fait l'aloccation mémoire !!! pensé au free size_t fileLength = O->readFile(&file); - O->aesEncrypt(); printf("%d bytes to be encrypted\n", (int)fileLength);