For self signed root only indicate one error.
[oweals/openssl.git] / crypto / evp / digest.c
index 0abd3ce48da5931895b3a43de4a87559691bc653..af0044ff43d7486b1302c56b8e7d4e988d0b09b6 100644 (file)
 
 #ifdef OPENSSL_FIPS
 #include <openssl/fips.h>
+#include "evp_locl.h"
 #endif
 
 void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
@@ -145,14 +146,14 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
 int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
        {
        EVP_MD_CTX_clear_flags(ctx,EVP_MD_CTX_FLAG_CLEANED);
-#ifdef OPENSSL_FIPS_
+#ifdef OPENSSL_FIPS
        /* If FIPS mode switch to approved implementation if possible */
        if (FIPS_mode())
                {
                const EVP_MD *fipsmd;
                if (type)
                        {
-                       fipsmd = FIPS_get_digestbynid(EVP_MD_type(type));
+                       fipsmd = evp_get_fips_md(type);
                        if (fipsmd)
                                type = fipsmd;
                        }
@@ -379,8 +380,11 @@ int EVP_Digest(const void *data, size_t count,
 
 void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
        {
-       EVP_MD_CTX_cleanup(ctx);
-       OPENSSL_free(ctx);
+       if (ctx)
+               {
+               EVP_MD_CTX_cleanup(ctx);
+               OPENSSL_free(ctx);
+               }
        }
 
 /* This call frees resources associated with the context */