modification crypt.hpp pour fonctionné avec le nouvelle openSSL 'plus de malloc pour les structs EVP'

This commit is contained in:
antoine 2017-07-19 19:30:44 +02:00 committed by Antoine
parent 34e67caa15
commit 9d71174ffc
6 changed files with 15 additions and 12 deletions

View File

@ -16,7 +16,8 @@ public:
}; };
crypt::crypt(std::string filename) : aes(filename) { 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) { if(aesEncryptCtx == NULL) {
exit(FAILURE); exit(FAILURE);
} }
@ -25,8 +26,8 @@ crypt::crypt(std::string filename) : aes(filename) {
crypt::crypt(const crypt& _a) : aes::aes() { crypt::crypt(const crypt& _a) : aes::aes() {
this->clone(_a); this->clone(_a);
aesEncryptCtx = EVP_CIPHER_CTX_new();
aesEncryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX)); //aesEncryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX));
if(aesEncryptCtx == NULL) { if(aesEncryptCtx == NULL) {
exit(FAILURE); exit(FAILURE);
} }
@ -69,7 +70,8 @@ int crypt::aesEncrypt(const unsigned char *msg, size_t msgLen, unsigned char **e
crypt::~crypt() { crypt::~crypt() {
aes::clear_all(); aes::clear_all();
EVP_CIPHER_CTX_cleanup(aesEncryptCtx); EVP_CIPHER_CTX_cleanup(aesEncryptCtx);
free(aesEncryptCtx); EVP_CIPHER_CTX_free(aesEncryptCtx);
//free(aesEncryptCtx);
} }
#endif #endif

View File

@ -1 +1 @@
?aîÈ×Y|°AöòÑï³ eЫЦ—Џ0?О­вЬmaО

4
data/file.key Normal file
View File

@ -0,0 +1,4 @@
{
"IV" : "ж9╞╞И╜■\u0016FCгчА6\u0001и\"СQX4Q╞Б╨йъkАUР╨",
"key" : "│\u0002\u0014\u0005╩\u0019=н\u0006ТСоУ├⌠┌╦xCIe\u0018┐нLcЛzsz"
}

View File

@ -33,7 +33,6 @@ 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_new(); aesDecryptCtx = EVP_CIPHER_CTX_new();
//aesDecryptCtx = (EVP_CIPHER_CTX*)malloc(sizeof(EVP_CIPHER_CTX));
if(aesDecryptCtx == NULL) { if(aesDecryptCtx == NULL) {
exit(FAILURE); exit(FAILURE);
} }
@ -80,7 +79,6 @@ decrypt::~decrypt() {
aes::clear_all(); aes::clear_all();
EVP_CIPHER_CTX_cleanup(aesDecryptCtx); EVP_CIPHER_CTX_cleanup(aesDecryptCtx);
EVP_CIPHER_CTX_free(aesDecryptCtx); EVP_CIPHER_CTX_free(aesDecryptCtx);
//free(aesDecryptCtx);
} }
#endif #endif

BIN
jsoncpp.o Normal file

Binary file not shown.

View File

@ -15,7 +15,6 @@ int main(int argc, char* argv[]) {
//******************************************************************* while a rajouté pour les gros fichier //******************************************************************* while a rajouté pour les gros fichier
// readFile fait l'aloccation mémoire !!! pensé au free // readFile fait l'aloccation mémoire !!! pensé au free
size_t fileLength = O->readFile(&file); size_t fileLength = O->readFile(&file);
O->aesEncrypt();
printf("%d bytes to be encrypted\n", (int)fileLength); printf("%d bytes to be encrypted\n", (int)fileLength);