Compare parameters when comparing public keys.
[openssl.git] / crypto / dsa / dsa_ameth.c
index b9f7a4d687189638f8038e53dd769e6de2536d04..ce5e6574633a8694086a33f61900a3b3f6e4f487 100644 (file)
@@ -167,14 +167,6 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
        return 0;
        }
 
        return 0;
        }
 
-static int dsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
-       {
-       if (BN_cmp(b->pkey.dsa->pub_key,a->pkey.dsa->pub_key) != 0)
-               return 0;
-       else
-               return 1;
-       }
-
 /* In PKCS#8 DSA: you just get a private key integer and parameters in the
  * AlgorithmIdentifier the pubkey must be recalculated.
  */
 /* In PKCS#8 DSA: you just get a private key integer and parameters in the
  * AlgorithmIdentifier the pubkey must be recalculated.
  */
@@ -281,7 +273,6 @@ static int dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
        BN_CTX_free (ctx);
        sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
        DSA_free(dsa);
        BN_CTX_free (ctx);
        sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
        DSA_free(dsa);
-       EVP_PKEY_free(pkey);
        return 0;
        }
 
        return 0;
        }
 
@@ -390,6 +381,16 @@ static int dsa_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
                return 1;
        }
 
                return 1;
        }
 
+static int dsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
+       {
+       if (dsa_cmp_parameters(a, b) == 0)
+               return 0;
+       if (BN_cmp(b->pkey.dsa->pub_key,a->pkey.dsa->pub_key) != 0)
+               return 0;
+       else
+               return 1;
+       }
+
 static void int_dsa_free(EVP_PKEY *pkey)
        {
        DSA_free(pkey->pkey.dsa);
 static void int_dsa_free(EVP_PKEY *pkey)
        {
        DSA_free(pkey->pkey.dsa);