Make sure we get the definition of OPENSSL_NO_AES.
[openssl.git] / crypto / evp / e_aes.c
index 9d03a9602fddca0de33784f572682360cde0a920..bf7c45fa2c4ffe013ca6b92d7b830a3196050209 100644 (file)
@@ -48,6 +48,7 @@
  *
  */
 
+#include <openssl/opensslconf.h>
 #ifndef OPENSSL_NO_AES
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -88,7 +89,9 @@ IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
 static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
                   const unsigned char *iv, int enc) {
 
-       if (enc) 
+       if ((ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_CFB_MODE
+           || (ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_OFB_MODE
+           || enc) 
                AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
        else
                AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data);