openssl/openssl — pull request #172 by alokmenghrajani (2014-09-08 21:57:19+00:00)
Title: Ensures that EVP encryption & decryption operations check the encrypt flag on the context.

I'm new to this codebase, so sorry if I made any style mistakes. Also, I have a couple questions:
1. do we need to set EVPerr before returning 0;
2. should we unittest this case?

I believe EVP should make it hard to shoot yourself in the foot this change ensures that a user cannot accidentally decrypt data with an encryption context
or vice-versa. Without the check, if an encryption context is used to decrypt
EVP_aes_256_gcm encrypted data, the code will fail to validate the TAG.

Example code availabe at: http://quaxio.com/wtf/openssl_wtf.html