aboutsummaryrefslogtreecommitdiffstats
path: root/src/_cffi_src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-06-27 20:26:28 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2016-06-27 21:26:28 -0400
commit827070edc110b8a7d7ff27831a492a8fdb824b89 (patch)
treea791f96b51ecad8c1b6e7a9ba5792ee718e9fb83 /src/_cffi_src
parent4bdb7758749e12dcd741ffd20b9c55a8dae4a784 (diff)
downloadcryptography-827070edc110b8a7d7ff27831a492a8fdb824b89.tar.gz
cryptography-827070edc110b8a7d7ff27831a492a8fdb824b89.tar.bz2
cryptography-827070edc110b8a7d7ff27831a492a8fdb824b89.zip
update DSA opaque getters/setters to latest code from openssl 1.1.0 master (#3020)
constify + a few small changes to the null checks
Diffstat (limited to 'src/_cffi_src')
-rw-r--r--src/_cffi_src/openssl/dsa.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/_cffi_src/openssl/dsa.py b/src/_cffi_src/openssl/dsa.py
index 5df79455..c9f33778 100644
--- a/src/_cffi_src/openssl/dsa.py
+++ b/src/_cffi_src/openssl/dsa.py
@@ -24,9 +24,10 @@ int DSA_verify(int, const unsigned char *, int, const unsigned char *, int,
DSA *);
/* added in 1.1.0 to access the opaque struct */
-void DSA_get0_pqg(const DSA *, BIGNUM **, BIGNUM **, BIGNUM **);
+void DSA_get0_pqg(const DSA *, const BIGNUM **, const BIGNUM **,
+ const BIGNUM **);
int DSA_set0_pqg(DSA *, BIGNUM *, BIGNUM *, BIGNUM *);
-void DSA_get0_key(const DSA *, BIGNUM **, BIGNUM **);
+void DSA_get0_key(const DSA *, const BIGNUM **, const BIGNUM **);
int DSA_set0_key(DSA *, BIGNUM *, BIGNUM *);
"""
@@ -38,7 +39,8 @@ int DSA_generate_parameters_ex(DSA *, int, unsigned char *, int,
CUSTOMIZATIONS = """
/* These functions were added in OpenSSL 1.1.0-pre5 (beta2) */
#if OPENSSL_VERSION_NUMBER < 0x10100005 || defined(LIBRESSL_VERSION_NUMBER)
-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;
@@ -49,14 +51,14 @@ 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) {
BN_free(d->p);
d->p = p;
@@ -69,9 +71,11 @@ int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
BN_free(d->g);
d->g = 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;
@@ -80,16 +84,13 @@ 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) {
BN_free(d->pub_key);
d->pub_key = pub_key;
@@ -98,6 +99,7 @@ int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
BN_free(d->priv_key);
d->priv_key = priv_key;
}
+
return 1;
}
#endif