From fd809cfdbd6e32b6b67b68c59f6d55fbed7a9327 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 14 Jun 2016 15:48:16 +0200 Subject: Constify the parameter getters for RSA, DSA and DH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Including documentation changes Reviewed-by: Stephen Henson Reviewed-by: Emilia Käsper --- crypto/dsa/dsa_lib.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'crypto/dsa') diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 14cb35f82e..8146330a54 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -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) { -- cgit v1.2.3