Make -CSP option work again in pkcs12 utility by checking for
[openssl.git] / crypto / evp / p_lib.c
index 2760d7b1ed86f901d74e25d8e4c3f7c3a5edc58d..85caa478caf94118906e201f4060e9e00aa102d9 100644 (file)
@@ -64,6 +64,9 @@
 #include <openssl/evp.h>
 #include <openssl/asn1_mac.h>
 #include <openssl/x509.h>
 #include <openssl/evp.h>
 #include <openssl/asn1_mac.h>
 #include <openssl/x509.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
 
 static void EVP_PKEY_free_it(EVP_PKEY *x);
 
 
 static void EVP_PKEY_free_it(EVP_PKEY *x);
 
@@ -233,6 +236,15 @@ int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
                else
                        return(1);
                }
                else
                        return(1);
                }
+#endif
+#ifndef OPENSSL_NO_EC
+       if (a->type == EVP_PKEY_EC && b->type == EVP_PKEY_EC)
+               {
+               if (EC_GROUP_cmp(a->pkey.eckey->group, b->pkey.eckey->group, NULL))
+                       return 0;
+               else
+                       return 1;
+               }
 #endif
        return(-1);
        }
 #endif
        return(-1);
        }
@@ -242,14 +254,8 @@ int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
        if (a->type != b->type)
                return -1;
 
        if (a->type != b->type)
                return -1;
 
-       /* XXXXX
-          We should really check for != 0, but cmp_paramters doesn't compare EC
-          groups, and I'm currently unsure how to handle that case...  Except for
-          adding such functionality to cmp_parameters, but that would require
-          things like EC_GROUP_cmp(), which I'm not currently ready to write.
-          -- Richard Levitte */
-       if (EVP_PKEY_cmp_parameters(a, b) == 1)
-               return 1;
+       if (EVP_PKEY_cmp_parameters(a, b) == 0)
+               return 0;
 
        switch (a->type)
                {
 
        switch (a->type)
                {
@@ -445,6 +451,8 @@ void EVP_PKEY_free(EVP_PKEY *x)
                }
 #endif
        EVP_PKEY_free_it(x);
                }
 #endif
        EVP_PKEY_free_it(x);
+       if (x->attributes)
+               sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
        OPENSSL_free(x);
        }
 
        OPENSSL_free(x);
        }