After the latest round of header-hacking, regenerate the dependencies in
[openssl.git] / crypto / evp / p_lib.c
index 1056e4bffdf0f395f1312123dbe3114bfaff1131..934f8ff8be3ef23ada717531b36264b3f130ca74 100644 (file)
@@ -64,6 +64,9 @@
 #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);
 
@@ -117,7 +120,7 @@ int EVP_PKEY_size(EVP_PKEY *pkey)
                if (pkey->type == EVP_PKEY_DSA)
                return(DSA_size(pkey->pkey.dsa));
 #endif
-#ifndef OPENSSL_NO_EC
+#ifndef OPENSSL_NO_ECDSA
                if (pkey->type == EVP_PKEY_EC)
                return(ECDSA_size(pkey->pkey.eckey));
 #endif
@@ -150,7 +153,7 @@ int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
        return(0);
        }
 
-int EVP_PKEY_copy_parameters(EVP_PKEY *to, EVP_PKEY *from)
+int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
        {
        if (to->type != from->type)
                {
@@ -198,7 +201,7 @@ err:
        return(0);
        }
 
-int EVP_PKEY_missing_parameters(EVP_PKEY *pkey)
+int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)
        {
 #ifndef OPENSSL_NO_DSA
        if (pkey->type == EVP_PKEY_DSA)
@@ -221,7 +224,7 @@ int EVP_PKEY_missing_parameters(EVP_PKEY *pkey)
        return(0);
        }
 
-int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b)
+int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
        {
 #ifndef OPENSSL_NO_DSA
        if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA))
@@ -233,10 +236,68 @@ int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b)
                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);
        }
 
+int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
+       {
+       if (a->type != b->type)
+               return -1;
+
+       if (EVP_PKEY_cmp_parameters(a, b) == 0)
+               return 0;
+
+       switch (a->type)
+               {
+#ifndef OPENSSL_NO_RSA
+       case EVP_PKEY_RSA:
+               if (BN_cmp(b->pkey.rsa->n,a->pkey.rsa->n) != 0
+                       || BN_cmp(b->pkey.rsa->e,a->pkey.rsa->e) != 0)
+                       return 0;
+               break;
+#endif
+#ifndef OPENSSL_NO_DSA
+       case EVP_PKEY_DSA:
+               if (BN_cmp(b->pkey.dsa->pub_key,a->pkey.dsa->pub_key) != 0)
+                       return 0;
+               break;
+#endif
+#ifndef OPENSSL_NO_EC
+       case EVP_PKEY_EC:
+               {
+               int  r = EC_POINT_cmp(b->pkey.eckey->group, 
+                       b->pkey.eckey->pub_key,a->pkey.eckey->pub_key,NULL);
+               if (r != 0)
+                       {
+                       if (r == 1)
+                               return 0;
+                       else
+                               return -2;
+                       }
+               }
+               break;
+#endif
+#ifndef OPENSSL_NO_DH
+       case EVP_PKEY_DH:
+               return -2;
+#endif
+       default:
+               return -2;
+               }
+
+       return 1;
+       }
+
 EVP_PKEY *EVP_PKEY_new(void)
        {
        EVP_PKEY *ret;