From b5d07b7f723ca101bbe4b78584df367c014eed96 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 13 Nov 2018 07:46:34 -0500 Subject: Ed bindings (#4586) * add evp_pkey_ed25519 * ed448 bindings --- src/_cffi_src/openssl/evp.py | 14 ++++++++++++++ src/_cffi_src/openssl/nid.py | 7 +++++++ src/cryptography/hazmat/bindings/openssl/_conditional.py | 9 +++++++++ 3 files changed, 30 insertions(+) diff --git a/src/_cffi_src/openssl/evp.py b/src/_cffi_src/openssl/evp.py index 84b91086..3c10aabf 100644 --- a/src/_cffi_src/openssl/evp.py +++ b/src/_cffi_src/openssl/evp.py @@ -22,7 +22,9 @@ 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_PKEY_ED25519; static const int EVP_PKEY_X448; +static const int EVP_PKEY_ED448; static const int EVP_MAX_MD_SIZE; static const int EVP_CTRL_AEAD_SET_IVLEN; static const int EVP_CTRL_AEAD_GET_TAG; @@ -298,4 +300,16 @@ static const long Cryptography_HAS_RAW_KEY = 1; #ifndef EVP_PKEY_X448 #define EVP_PKEY_X448 NID_X448 #endif + +/* This is tied to ED25519 support so we reuse the Cryptography_HAS_ED25519 + conditional to remove it. */ +#ifndef EVP_PKEY_ED25519 +#define EVP_PKEY_ED25519 NID_ED25519 +#endif + +/* This is tied to ED448 support so we reuse the Cryptography_HAS_ED448 + conditional to remove it. */ +#ifndef EVP_PKEY_ED448 +#define EVP_PKEY_ED448 NID_ED448 +#endif """ diff --git a/src/_cffi_src/openssl/nid.py b/src/_cffi_src/openssl/nid.py index 226229e9..bf445aa8 100644 --- a/src/_cffi_src/openssl/nid.py +++ b/src/_cffi_src/openssl/nid.py @@ -11,6 +11,7 @@ INCLUDES = """ TYPES = """ static const int Cryptography_HAS_X25519; static const int Cryptography_HAS_X448; +static const int Cryptography_HAS_ED448; static const int Cryptography_HAS_ED25519; static const int NID_undef; @@ -249,4 +250,10 @@ static const int NID_X448 = 0; #else static const long Cryptography_HAS_X448 = 1; #endif +#ifndef NID_ED448 +static const long Cryptography_HAS_ED448 = 0; +static const int NID_ED448 = 0; +#else +static const long Cryptography_HAS_ED448 = 1; +#endif """ diff --git a/src/cryptography/hazmat/bindings/openssl/_conditional.py b/src/cryptography/hazmat/bindings/openssl/_conditional.py index 6da48a56..06199f4a 100644 --- a/src/cryptography/hazmat/bindings/openssl/_conditional.py +++ b/src/cryptography/hazmat/bindings/openssl/_conditional.py @@ -231,9 +231,17 @@ def cryptography_has_x448(): ] +def cryptography_has_ed448(): + return [ + "EVP_PKEY_ED448", + "NID_ED448", + ] + + def cryptography_has_ed25519(): return [ "NID_ED25519", + "EVP_PKEY_ED25519", ] @@ -370,6 +378,7 @@ CONDITIONAL_NAMES = { ), "Cryptography_HAS_X25519": cryptography_has_x25519, "Cryptography_HAS_X448": cryptography_has_x448, + "Cryptography_HAS_ED448": cryptography_has_ed448, "Cryptography_HAS_ED25519": cryptography_has_ed25519, "Cryptography_HAS_ONESHOT_EVP_DIGEST_SIGN_VERIFY": ( cryptography_has_oneshot_evp_digest_sign_verify -- cgit v1.2.3