Skip to content

Commit

Permalink
encfs_common.c: Fixes for compatibility with OpenSSL 1.1. See #2355
Browse files Browse the repository at this point in the history
  • Loading branch information
magnumripper committed Dec 10, 2016
1 parent 4859f4d commit aaeff8b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/encfs_common_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,26 @@ int encfs_common_streamDecode(encfs_common_custom_salt *cur_salt, unsigned char
{
unsigned char ivec[ MAX_IVLENGTH ];
int dstLen=0, tmpLen=0;
EVP_CIPHER_CTX stream_dec;
EVP_CIPHER_CTX *stream_dec = EVP_CIPHER_CTX_new();

encfs_common_setIVec(cur_salt, ivec, iv64 + 1, key);
EVP_CIPHER_CTX_init(&stream_dec);
EVP_DecryptInit_ex( &stream_dec, cur_salt->streamCipher, NULL, NULL, NULL);
EVP_CIPHER_CTX_set_key_length( &stream_dec, cur_salt->keySize );
EVP_CIPHER_CTX_set_padding( &stream_dec, 0 );
EVP_DecryptInit_ex( &stream_dec, NULL, NULL, key, NULL);

EVP_DecryptInit_ex( &stream_dec, NULL, NULL, NULL, ivec);
EVP_DecryptUpdate( &stream_dec, buf, &dstLen, buf, size );
EVP_DecryptFinal_ex( &stream_dec, buf+dstLen, &tmpLen );
EVP_CIPHER_CTX_init(stream_dec);
EVP_DecryptInit_ex( stream_dec, cur_salt->streamCipher, NULL, NULL, NULL);
EVP_CIPHER_CTX_set_key_length( stream_dec, cur_salt->keySize );
EVP_CIPHER_CTX_set_padding( stream_dec, 0 );
EVP_DecryptInit_ex( stream_dec, NULL, NULL, key, NULL);

EVP_DecryptInit_ex( stream_dec, NULL, NULL, NULL, ivec);
EVP_DecryptUpdate( stream_dec, buf, &dstLen, buf, size );
EVP_DecryptFinal_ex( stream_dec, buf+dstLen, &tmpLen );
unshuffleBytes( buf, size );
flipBytes( buf, size );

encfs_common_setIVec(cur_salt, ivec, iv64, key );
EVP_DecryptInit_ex( &stream_dec, NULL, NULL, NULL, ivec);
EVP_DecryptUpdate( &stream_dec, buf, &dstLen, buf, size );
EVP_DecryptFinal_ex( &stream_dec, buf+dstLen, &tmpLen );
EVP_CIPHER_CTX_cleanup(&stream_dec);
EVP_DecryptInit_ex( stream_dec, NULL, NULL, NULL, ivec);
EVP_DecryptUpdate( stream_dec, buf, &dstLen, buf, size );
EVP_DecryptFinal_ex( stream_dec, buf+dstLen, &tmpLen );
EVP_CIPHER_CTX_cleanup(stream_dec);

unshuffleBytes( buf, size );
dstLen += tmpLen;
Expand Down

7 comments on commit aaeff8b

@claudioandre-br
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen the "ERROR: LeakSanitizer: detected memory leaks"?

@magnumripper
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the EVP_CIPHER_CTX_cleanup(stream_dec); would free it. Perhaps there's something like EVP_CIPHER_CTX_free() that should be added?

@magnumripper
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah it was and you already made a PR 😆

@claudioandre-br
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record since it migh be a problem sooner or later.

  • EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result, EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared.

@magnumripper
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh, so we need different code paths with #ifdef's now? I hate OpenSSL.

@claudioandre-br
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was guessing it was defined as {}, for example, not vanished. On a 2nd thought, disappear is a strong word.

@magnumripper
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So they did the job for us. Sounds much better!

Please sign in to comment.