add missing evp_cnf.c file
[openssl.git] / crypto / evp / evp_enc.c
index 691072655b4f0e50cfc1f0e32eb8b596a634a118..6da323077a2ac01bd7d325e9ccc223bff77426ee 100644 (file)
@@ -170,8 +170,16 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
 #endif
 
 #ifdef OPENSSL_FIPS
-               return FIPS_cipherinit(ctx, cipher, key, iv, enc);
-#else
+               if (FIPS_mode())
+                       {
+                       const EVP_CIPHER *fcipher;
+                       if (cipher)
+                               fcipher = FIPS_get_cipherbynid(EVP_CIPHER_type(cipher));
+                       if (fcipher)
+                               cipher = fcipher;
+                       return FIPS_cipherinit(ctx, cipher, key, iv, enc);
+                       }
+#endif
                ctx->cipher=cipher;
                if (ctx->cipher->ctx_size)
                        {
@@ -196,7 +204,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
                                return 0;
                                }
                        }
-#endif
                }
        else if(!ctx->cipher)
                {
@@ -207,8 +214,9 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *imp
 skip_to_init:
 #endif
 #ifdef OPENSSL_FIPS
-       return FIPS_cipherinit(ctx, cipher, key, iv, enc);
-#else
+       if (FIPS_mode())
+               return FIPS_cipherinit(ctx, cipher, key, iv, enc);
+#endif
        /* we assume block size is a power of 2 in *cryptUpdate */
        OPENSSL_assert(ctx->cipher->block_size == 1
            || ctx->cipher->block_size == 8
@@ -255,7 +263,6 @@ skip_to_init:
        ctx->final_used=0;
        ctx->block_mask=ctx->cipher->block_size-1;
        return 1;
-#endif
        }
 
 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,