Constify the parameter getters for RSA, DSA and DH
[openssl.git] / crypto / dsa / dsa_lib.c
index 14cb35f82e28f374afa67adff817d61d228a6fb1..8146330a549015014cc6ad492d6644a1e77e03c4 100644 (file)
@@ -253,7 +253,8 @@ DH *DSA_dup_DH(const DSA *r)
 }
 #endif
 
-void DSA_get0_pqg(const DSA *d, BIGNUM **p, BIGNUM **q, BIGNUM **g)
+void DSA_get0_pqg(const DSA *d,
+                  const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
 {
     if (p != NULL)
         *p = d->p;
@@ -265,13 +266,12 @@ void DSA_get0_pqg(const DSA *d, BIGNUM **p, BIGNUM **q, BIGNUM **g)
 
 int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
 {
-    /* If the fields in d are NULL, the corresponding input
+    /* If the fields p, q and g in d are NULL, the corresponding input
      * parameters MUST be non-NULL.
-     *
-     * It is an error to give the results from get0 on d
-     * as input parameters.
      */
-    if (p == d->p || q == d->q || g == d->g)
+    if (d->p == NULL && p == NULL
+        || d->q == NULL && q == NULL
+        || d->g == NULL && g == NULL)
         return 0;
 
     if (p != NULL) {
@@ -290,7 +290,8 @@ int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
     return 1;
 }
 
-void DSA_get0_key(const DSA *d, BIGNUM **pub_key, BIGNUM **priv_key)
+void DSA_get0_key(const DSA *d,
+                  const BIGNUM **pub_key, const BIGNUM **priv_key)
 {
     if (pub_key != NULL)
         *pub_key = d->pub_key;
@@ -300,15 +301,11 @@ void DSA_get0_key(const DSA *d, BIGNUM **pub_key, BIGNUM **priv_key)
 
 int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
 {
-    /* If the pub_key in d is NULL, the corresponding input
+    /* If the field pub_key in d is NULL, the corresponding input
      * parameters MUST be non-NULL.  The priv_key field may
      * be left NULL.
-     *
-     * It is an error to give the results from get0 on d
-     * as input parameters.
      */
-    if (d->pub_key == pub_key
-        || (d->priv_key != NULL && priv_key == d->priv_key))
+    if (d->pub_key == NULL && pub_key == NULL)
         return 0;
 
     if (pub_key != NULL) {