diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-06-27 20:32:52 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-06-27 21:32:52 -0400 |
commit | b5a01118949825585f2624bded8a3822173ab990 (patch) | |
tree | 9203b69eac2b047735e9d1c45d3b5f897210239f /src/_cffi_src | |
parent | 827070edc110b8a7d7ff27831a492a8fdb824b89 (diff) | |
download | cryptography-b5a01118949825585f2624bded8a3822173ab990.tar.gz cryptography-b5a01118949825585f2624bded8a3822173ab990.tar.bz2 cryptography-b5a01118949825585f2624bded8a3822173ab990.zip |
update DH opaque getters/setters to latest code from openssl 1.1.0 master (#3021)
constify + a few small changes to the null checks
Diffstat (limited to 'src/_cffi_src')
-rw-r--r-- | src/_cffi_src/openssl/dh.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/_cffi_src/openssl/dh.py b/src/_cffi_src/openssl/dh.py index 7998a1bd..ab0f3969 100644 --- a/src/_cffi_src/openssl/dh.py +++ b/src/_cffi_src/openssl/dh.py @@ -28,9 +28,10 @@ int DHparams_print_fp(FILE *, const DH *); int DHparams_print(BIO *, const DH *); /* added in 1.1.0 when the DH struct was opaqued */ -void DH_get0_pqg(const DH *, BIGNUM **, BIGNUM **, BIGNUM **); +void DH_get0_pqg(const DH *, const BIGNUM **, const BIGNUM **, + const BIGNUM **); int DH_set0_pqg(DH *, BIGNUM *, BIGNUM *, BIGNUM *); -void DH_get0_key(const DH *, BIGNUM **, BIGNUM **); +void DH_get0_key(const DH *, const BIGNUM **, const BIGNUM **); int DH_set0_key(DH *, BIGNUM *, BIGNUM *); """ @@ -41,7 +42,8 @@ int DH_generate_parameters_ex(DH *, int, int, BN_GENCB *); CUSTOMIZATIONS = """ /* These functions were added in OpenSSL 1.1.0-pre5 (beta2) */ #if OPENSSL_VERSION_NUMBER < 0x10100005 || defined(LIBRESSL_VERSION_NUMBER) -void DH_get0_pqg(const DH *dh, BIGNUM **p, BIGNUM **q, BIGNUM **g) +void DH_get0_pqg(const DH *dh, + const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) { if (p != NULL) *p = dh->p; @@ -55,11 +57,9 @@ int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) { /* If the fields p and g in d are NULL, the corresponding input * parameters MUST be non-NULL. q may remain NULL. - * - * It is an error to give the results from get0 on d - * as input parameters. */ - if (p == dh->p || (dh->q != NULL && q == dh->q) || g == dh->g) + if ((dh->p == NULL && p == NULL) + || (dh->g == NULL && g == NULL)) return 0; if (p != NULL) { @@ -82,7 +82,7 @@ int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) return 1; } -void DH_get0_key(const DH *dh, BIGNUM **pub_key, BIGNUM **priv_key) +void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) { if (pub_key != NULL) *pub_key = dh->pub_key; @@ -92,15 +92,11 @@ void DH_get0_key(const DH *dh, BIGNUM **pub_key, BIGNUM **priv_key) int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) { - /* If the pub_key in dh is NULL, the corresponding input + /* If the field pub_key in dh 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 dh - * as input parameters. */ - if (dh->pub_key == pub_key - || (dh->priv_key != NULL && priv_key == dh->priv_key)) + if (dh->pub_key == NULL && pub_key == NULL) return 0; if (pub_key != NULL) { |