aboutsummaryrefslogtreecommitdiffstats
path: root/src/_cffi_src
diff options
context:
space:
mode:
authorAviv Palivoda <palaviv@gmail.com>2017-05-20 01:24:17 +0300
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-05-19 17:24:17 -0500
commit0d92ff8a1680911019dab64deeb4f7ea67224492 (patch)
tree9e9dece647e892753439ff2f12c84d42ab21f64f /src/_cffi_src
parentd2574f5b9d8fd6a8e26fad6fd0f439ed6e494391 (diff)
downloadcryptography-0d92ff8a1680911019dab64deeb4f7ea67224492.tar.gz
cryptography-0d92ff8a1680911019dab64deeb4f7ea67224492.tar.bz2
cryptography-0d92ff8a1680911019dab64deeb4f7ea67224492.zip
Add PEM_write_bio_DHxparams, d2i_DHxparams_bio, i2d_DHxparams_bio (#3485)
* Add PEM_write_bio_DHxparams * Define PEM_write_bio_DHxparams only if EVP_PKEY_DHX defined. Both added in commit afb14cda in openssl * Add d2i_DHxparams_bio and i2d_DHxparams_bio bindings * Fix bindings addition * change condtional bindings to be after 1.1.0f * Change i2d_DHxparams_bio return type * define Cryptography_d2i_DHxparams_bio and Cryptography_i2d_DHxparams_bio * Remove d2i_DHxparams_bio, i2d_DHxparams_bio bindings * Add declarations for Cryptography_d2i_DHxparams_bio and Cryptography_i2d_DHxparams_bio * Move Cryptography_d2i_DHxparams_bio and Cryptography_i2d_DHxparams_bio declaration to MACROS * Add Cryptography_d2i_DHxparams_bio, Cryptography_i2d_DHxparams_bio and PEM_write_bio_DHxparams to _coditionals.py * Make sure we did not define EVP_PKEY_DHX
Diffstat (limited to 'src/_cffi_src')
-rw-r--r--src/_cffi_src/openssl/dh.py16
-rw-r--r--src/_cffi_src/openssl/pem.py4
2 files changed, 20 insertions, 0 deletions
diff --git a/src/_cffi_src/openssl/dh.py b/src/_cffi_src/openssl/dh.py
index 922f5e9f..42309e40 100644
--- a/src/_cffi_src/openssl/dh.py
+++ b/src/_cffi_src/openssl/dh.py
@@ -41,6 +41,8 @@ MACROS = """
int DH_generate_parameters_ex(DH *, int, int, BN_GENCB *);
DH *d2i_DHparams_bio(BIO *, DH **);
int i2d_DHparams_bio(BIO *, DH *);
+DH *Cryptography_d2i_DHxparams_bio(BIO *bp, DH **x);
+int Cryptography_i2d_DHxparams_bio(BIO *bp, DH *x);
"""
CUSTOMIZATIONS = """
@@ -227,4 +229,18 @@ int Cryptography_DH_check(const DH *dh, int *ret) {
return DH_check(dh, ret);
}
#endif
+
+/* These functions were added in OpenSSL 1.1.0f commit d0c50e80a8 */
+/* Define our own to simplify support across all versions. */
+#if defined(EVP_PKEY_DHX) && EVP_PKEY_DHX != -1
+DH *Cryptography_d2i_DHxparams_bio(BIO *bp, DH **x) {
+ return ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x);
+}
+int Cryptography_i2d_DHxparams_bio(BIO *bp, DH *x) {
+ return ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x);
+}
+#else
+DH *(*Cryptography_d2i_DHxparams_bio)(BIO *bp, DH **x) = NULL;
+int (*Cryptography_i2d_DHxparams_bio)(BIO *bp, DH *x) = NULL;
+#endif
"""
diff --git a/src/_cffi_src/openssl/pem.py b/src/_cffi_src/openssl/pem.py
index 1d292a2e..5c1bc180 100644
--- a/src/_cffi_src/openssl/pem.py
+++ b/src/_cffi_src/openssl/pem.py
@@ -82,7 +82,11 @@ int PEM_write_bio_ECPrivateKey(BIO *, EC_KEY *, const EVP_CIPHER *,
unsigned char *, int, pem_password_cb *,
void *);
int PEM_write_bio_DHparams(BIO *, DH *);
+int PEM_write_bio_DHxparams(BIO *, DH *);
"""
CUSTOMIZATIONS = """
+#if !defined(EVP_PKEY_DHX) || EVP_PKEY_DHX == -1
+int (*PEM_write_bio_DHxparams)(BIO *, DH *) = NULL;
+#endif
"""