aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2018-01-05 09:58:35 -0600
committerAlex Gaynor <alex.gaynor@gmail.com>2018-01-05 10:58:35 -0500
commitbade58f1566683cb5b110b341e01e3d3397b972f (patch)
tree0f920d42af3ea40ce5856cb5abecab840fa89f84 /src
parent754c693bc76e91150ad06de13f74c42b48f59231 (diff)
downloadcryptography-bade58f1566683cb5b110b341e01e3d3397b972f.tar.gz
cryptography-bade58f1566683cb5b110b341e01e3d3397b972f.tar.bz2
cryptography-bade58f1566683cb5b110b341e01e3d3397b972f.zip
just a quick confirmation that it really is an x25519 evp key (#4070)
* just a quick confirmation that it really is an x25519 evp key * openssl assert. take that python -O
Diffstat (limited to 'src')
-rw-r--r--src/_cffi_src/openssl/evp.py9
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py3
-rw-r--r--src/cryptography/hazmat/bindings/openssl/_conditional.py1
3 files changed, 13 insertions, 0 deletions
diff --git a/src/_cffi_src/openssl/evp.py b/src/_cffi_src/openssl/evp.py
index 3fcac0c2..715bfe19 100644
--- a/src/_cffi_src/openssl/evp.py
+++ b/src/_cffi_src/openssl/evp.py
@@ -21,6 +21,7 @@ static const int EVP_PKEY_DSA;
static const int EVP_PKEY_DH;
static const int EVP_PKEY_DHX;
static const int EVP_PKEY_EC;
+static const int EVP_PKEY_X25519;
static const int EVP_MAX_MD_SIZE;
static const int EVP_CTRL_AEAD_SET_IVLEN;
static const int EVP_CTRL_AEAD_GET_TAG;
@@ -241,4 +242,12 @@ int (*EVP_PKEY_set1_tls_encodedpoint)(EVP_PKEY *, const unsigned char *,
#if !defined(EVP_CTRL_AEAD_SET_TAG)
# define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
#endif
+
+/* This is tied to X25519 support so we reuse the Cryptography_HAS_X25519
+ conditional to remove it. OpenSSL 1.1.0 didn't have this define, but
+ 1.1.1 will when it is released. We can remove this in the distant
+ future when we drop 1.1.0 support. */
+#ifndef EVP_PKEY_X25519
+#define EVP_PKEY_X25519 NID_X25519
+#endif
"""
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index ca1aafe0..c0b3afe0 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -1914,6 +1914,9 @@ class Backend(object):
evp_pkey = backend._lib.d2i_PrivateKey_bio(bio.bio, self._ffi.NULL)
self.openssl_assert(evp_pkey != self._ffi.NULL)
evp_pkey = self._ffi.gc(evp_pkey, self._lib.EVP_PKEY_free)
+ self.openssl_assert(
+ self._lib.EVP_PKEY_id(evp_pkey) == self._lib.EVP_PKEY_X25519
+ )
return _X25519PrivateKey(self, evp_pkey)
def x25519_generate_key(self):
diff --git a/src/cryptography/hazmat/bindings/openssl/_conditional.py b/src/cryptography/hazmat/bindings/openssl/_conditional.py
index 8bc74c97..b87ae906 100644
--- a/src/cryptography/hazmat/bindings/openssl/_conditional.py
+++ b/src/cryptography/hazmat/bindings/openssl/_conditional.py
@@ -232,6 +232,7 @@ def cryptography_has_x509_store_ctx_get_issuer():
def cryptography_has_x25519():
return [
+ "EVP_PKEY_X25519",
"NID_X25519",
]