evp/e_aes_cbc_hmac_sha256.c: enable is on all AES-NI platforms, not only on AVX.
[openssl.git] / crypto / evp / p_lib.c
index 6715c154b29c99252e2fddae350e4ad7d39576b5..109188c45b50e95c8faeaa11d36a6ad2cf4d771e 100644 (file)
@@ -161,13 +161,13 @@ int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
        if (a->type != b->type)
                return -1;
 
-       if (a->meth)
+       if (a->ameth)
                {
                int ret;
                /* Compare parameters if the algorithm has them */
-               if (a->meth->param_cmp)
+               if (a->ameth->param_cmp)
                        {
-                       ret = a->meth->param_cmp(a, b);
+                       ret = a->ameth->param_cmp(a, b);
                        if (ret <= 0)
                                return ret;
                        }
@@ -220,7 +220,10 @@ static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
 #ifndef OPENSSL_NO_ENGINE
                /* If we have an ENGINE release it */
                if (pkey->engine)
+                       {
                        ENGINE_finish(pkey->engine);
+                       pkey->engine = NULL;
+                       }
 #endif
                }
        if (str)
@@ -345,7 +348,7 @@ int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
 
 DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey)
        {
-       if(pkey->type != EVP_PKEY_DH) {
+       if(pkey->type != EVP_PKEY_DH && pkey->type != EVP_PKEY_DHX) {
                EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY);
                return NULL;
        }
@@ -408,7 +411,10 @@ void EVP_PKEY_free(EVP_PKEY *x)
 static void EVP_PKEY_free_it(EVP_PKEY *x)
        {
        if (x->ameth && x->ameth->pkey_free)
+               {
                x->ameth->pkey_free(x);
+               x->pkey.ptr = NULL;
+               }
 #ifndef OPENSSL_NO_ENGINE
        if (x->engine)
                {