Merge pull request #635 from reaperhulk/openssl-pss-bindings
Conditionally bind PSS constant if available
diff --git a/cryptography/hazmat/bindings/openssl/rsa.py b/cryptography/hazmat/bindings/openssl/rsa.py
index b6f7d04..359305c 100644
--- a/cryptography/hazmat/bindings/openssl/rsa.py
+++ b/cryptography/hazmat/bindings/openssl/rsa.py
@@ -33,7 +33,10 @@
static const int RSA_NO_PADDING;
static const int RSA_PKCS1_OAEP_PADDING;
static const int RSA_X931_PADDING;
+static const int RSA_PKCS1_PSS_PADDING;
static const int RSA_F4;
+
+static const int Cryptography_HAS_PSS_PADDING;
"""
FUNCTIONS = """
@@ -70,10 +73,14 @@
"""
CUSTOMIZATIONS = """
-#if OPENSSL_VERSION_NUMBER < 0x10000000
+#if OPENSSL_VERSION_NUMBER >= 0x10000000
+static const long Cryptography_HAS_PSS_PADDING = 1;
+#else
// see evp.py for the definition of Cryptography_HAS_PKEY_CTX
+static const long Cryptography_HAS_PSS_PADDING = 0;
int (*EVP_PKEY_CTX_set_rsa_padding)(EVP_PKEY_CTX *, int) = NULL;
int (*EVP_PKEY_CTX_set_rsa_pss_saltlen)(EVP_PKEY_CTX *, int) = NULL;
+static const long RSA_PKCS1_PSS_PADDING = 0;
#endif
"""
@@ -81,5 +88,8 @@
"Cryptography_HAS_PKEY_CTX": [
"EVP_PKEY_CTX_set_rsa_padding",
"EVP_PKEY_CTX_set_rsa_pss_saltlen",
- ]
+ ],
+ "Cryptography_HAS_PSS_PADDING": [
+ "RSA_PKCS1_PSS_PADDING",
+ ],
}