Fix set0 reuse test
authorViktor Dukhovni <openssl-users@dukhovni.org>
Wed, 27 Apr 2016 19:08:33 +0000 (15:08 -0400)
committerViktor Dukhovni <openssl-users@dukhovni.org>
Wed, 27 Apr 2016 20:16:34 +0000 (16:16 -0400)
We must test for new object == current object, not !=.

Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c

index 644508d7848075c1fde6e997b01eb25d5d1ba686..9db45763faffe92c1555dd1f99236905fe4406e5 100644 (file)
@@ -303,7 +303,7 @@ int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
      * as input parameters.
      */
     if (dh->pub_key == pub_key
-        || (dh->priv_key != NULL && priv_key != dh->priv_key))
+        || (dh->priv_key != NULL && priv_key == dh->priv_key))
         return 0;
 
     if (pub_key != NULL) {
index 383b48ba464c1d5ae022720f8c1fb5eedfeccd6c..7b751a961d2854cb37972d909ffcc67d27abbf64 100644 (file)
@@ -358,7 +358,7 @@ int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
      * as input parameters.
      */
     if (d->pub_key == pub_key
-        || (d->priv_key != NULL && priv_key != d->priv_key))
+        || (d->priv_key != NULL && priv_key == d->priv_key))
         return 0;
 
     if (pub_key != NULL) {