From 5e66092907c6c6f461f30165b0910dea1fc314d5 Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 11:48:47 -0700 Subject: Basic skeleton for ECDH bindings --- cryptography/hazmat/bindings/openssl/ecdh.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cryptography/hazmat/bindings/openssl/ecdh.py diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py new file mode 100644 index 00000000..6793ea4b --- /dev/null +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import, division, print_function + +INCLUDES = """ +""" + +TYPES = """ +""" + +FUNCTIONS = """ +""" + +MACROS = """ +""" + +CUSTOMIZATIONS = """ +""" + +CONDITIONAL_NAMES = { +} -- cgit v1.2.3 From 8fc02962958f85feaab168248503854b6e0d50aa Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 11:55:56 -0700 Subject: Fill in the INCLUDES part --- cryptography/hazmat/bindings/openssl/ecdh.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py index 6793ea4b..ca448f9f 100644 --- a/cryptography/hazmat/bindings/openssl/ecdh.py +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -14,6 +14,9 @@ from __future__ import absolute_import, division, print_function INCLUDES = """ +#ifdef OPENSSL_NO_ECDH +#include +#endif """ TYPES = """ -- cgit v1.2.3 From 377b4db41dd0c575aac9cc3d65cadef7052d7b07 Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 12:23:18 -0700 Subject: And then the TYPES --- cryptography/hazmat/bindings/openssl/ecdh.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py index ca448f9f..7de791da 100644 --- a/cryptography/hazmat/bindings/openssl/ecdh.py +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -20,6 +20,9 @@ INCLUDES = """ """ TYPES = """ +static const int Cryptography_HAS_ECDH; + +typedef ... ECDH_METHOD; """ FUNCTIONS = """ -- cgit v1.2.3 From 42a509350bcc5b117d09e448ac64cc857832935e Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 12:34:24 -0700 Subject: And then the FUNCTIONS --- cryptography/hazmat/bindings/openssl/ecdh.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py index 7de791da..21a0d6d9 100644 --- a/cryptography/hazmat/bindings/openssl/ecdh.py +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -26,6 +26,15 @@ typedef ... ECDH_METHOD; """ FUNCTIONS = """ +int ECDH_compute_key(void *, size_t, const EC_POINT *, EC_KEY *, + void *(*)(const void *, size_t, void *, size_t *)); + +int ECDH_get_ex_new_index(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup *, + CRYPTO_EX_free *); + +int ECDH_set_ex_data(EC_KEY *, int, void *); + +void *ECDH_get_ex_data(EC_KEY *, int); """ MACROS = """ -- cgit v1.2.3 From d2e6563733a59d08cf46af7e93800539391c8d8d Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 12:43:30 -0700 Subject: Customize --- cryptography/hazmat/bindings/openssl/ecdh.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py index 21a0d6d9..c74abb96 100644 --- a/cryptography/hazmat/bindings/openssl/ecdh.py +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -41,6 +41,19 @@ MACROS = """ """ CUSTOMIZATIONS = """ +#ifdef OPENSSL_NO_ECDH +static const Cryptography_HAS_ECDH = 0; +typedef void ECDH_METHOD; + +int (*ECDH_compute_key)(void *, size_t, const EC_POINT *, EC_KEY *, + void *(*)(const void *, size_t, void *, size_t *)) = NULL; + +int (*ECDH_get_ex_new_index)(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup *, + CRYPTO_EX_free *) = NULL; + +int (*ECDH_set_ex_data)(EC_KEY *, int, void *) = NULL; + +void *(*ECDH_get_ex_data)(EC_KEY *, int) = NULL; """ CONDITIONAL_NAMES = { -- cgit v1.2.3 From e43fffb7614a39b454421798a415625a59687e19 Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 12:47:24 -0700 Subject: Define CONDITIONAL_NAMES --- cryptography/hazmat/bindings/openssl/ecdh.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py index c74abb96..6b9b50ce 100644 --- a/cryptography/hazmat/bindings/openssl/ecdh.py +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -57,4 +57,10 @@ void *(*ECDH_get_ex_data)(EC_KEY *, int) = NULL; """ CONDITIONAL_NAMES = { + "Cryptography_HAS_ECDH": [ + "ECDH_compute_key", + "ECDH_get_ex_new_index", + "ECDH_set_ex_data", + "ECDH_get_ex_data", + ], } -- cgit v1.2.3 From c5331de78f9f8496f6400b3816f31bee073abf32 Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Thu, 1 May 2014 13:32:57 -0700 Subject: Fix alignment and close an #ifdef --- cryptography/hazmat/bindings/openssl/ecdh.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/ecdh.py b/cryptography/hazmat/bindings/openssl/ecdh.py index 6b9b50ce..6f2fb5b5 100644 --- a/cryptography/hazmat/bindings/openssl/ecdh.py +++ b/cryptography/hazmat/bindings/openssl/ecdh.py @@ -27,10 +27,10 @@ typedef ... ECDH_METHOD; FUNCTIONS = """ int ECDH_compute_key(void *, size_t, const EC_POINT *, EC_KEY *, - void *(*)(const void *, size_t, void *, size_t *)); + void *(*)(const void *, size_t, void *, size_t *)); int ECDH_get_ex_new_index(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup *, - CRYPTO_EX_free *); + CRYPTO_EX_free *); int ECDH_set_ex_data(EC_KEY *, int, void *); @@ -46,14 +46,19 @@ static const Cryptography_HAS_ECDH = 0; typedef void ECDH_METHOD; int (*ECDH_compute_key)(void *, size_t, const EC_POINT *, EC_KEY *, - void *(*)(const void *, size_t, void *, size_t *)) = NULL; + void *(*)(const void *, size_t, void *, + size_t *)) = NULL; int (*ECDH_get_ex_new_index)(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup *, - CRYPTO_EX_free *) = NULL; + CRYPTO_EX_free *) = NULL; int (*ECDH_set_ex_data)(EC_KEY *, int, void *) = NULL; void *(*ECDH_get_ex_data)(EC_KEY *, int) = NULL; + +#else +static const Cryptography_HAS_ECDH = 1; +#endif """ CONDITIONAL_NAMES = { -- cgit v1.2.3