From e16ebfba8777bc05cf4a13d939e9710177b22340 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 4 Mar 2014 16:38:18 -0800 Subject: Expose EC_get_builtin_curves --- cryptography/hazmat/bindings/openssl/ec.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cryptography/hazmat/bindings/openssl/ec.py b/cryptography/hazmat/bindings/openssl/ec.py index 39403ff2..777860e1 100644 --- a/cryptography/hazmat/bindings/openssl/ec.py +++ b/cryptography/hazmat/bindings/openssl/ec.py @@ -23,6 +23,7 @@ TYPES = """ static const int Cryptography_HAS_EC; typedef ... EC_KEY; +typedef ... EC_builtin_curve; static const int NID_X9_62_prime192v1; static const int NID_X9_62_prime192v2; @@ -39,14 +40,18 @@ FUNCTIONS = """ MACROS = """ EC_KEY *EC_KEY_new_by_curve_name(int); void EC_KEY_free(EC_KEY *); + +size_t EC_get_builtin_curves(EC_builtin_curve *, size_t); """ CUSTOMIZATIONS = """ #ifdef OPENSSL_NO_EC static const long Cryptography_HAS_EC = 0; typedef void EC_KEY; +typdef void EC_builtin_curve; EC_KEY* (*EC_KEY_new_by_curve_name)(int) = NULL; void (*EC_KEY_free)(EC_KEY *) = NULL; +size_t (*EC_get_builtin_curves)(EC_builtin_curve *, size_t) = NULL; #else static const long Cryptography_HAS_EC = 1; #endif -- cgit v1.2.3 From 2619da79f1fb9432331aa4904cd47640aa7f0594 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 4 Mar 2014 16:58:48 -0800 Subject: pff --- cryptography/hazmat/bindings/openssl/ec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptography/hazmat/bindings/openssl/ec.py b/cryptography/hazmat/bindings/openssl/ec.py index 777860e1..7ecd5979 100644 --- a/cryptography/hazmat/bindings/openssl/ec.py +++ b/cryptography/hazmat/bindings/openssl/ec.py @@ -48,7 +48,7 @@ CUSTOMIZATIONS = """ #ifdef OPENSSL_NO_EC static const long Cryptography_HAS_EC = 0; typedef void EC_KEY; -typdef void EC_builtin_curve; +typedef void EC_builtin_curve; EC_KEY* (*EC_KEY_new_by_curve_name)(int) = NULL; void (*EC_KEY_free)(EC_KEY *) = NULL; size_t (*EC_get_builtin_curves)(EC_builtin_curve *, size_t) = NULL; -- cgit v1.2.3 From a5c58b9b590b0a2f6e94d371c1c18963e3ca1df7 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 4 Mar 2014 18:13:14 -0800 Subject: Expose the fields --- cryptography/hazmat/bindings/openssl/ec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cryptography/hazmat/bindings/openssl/ec.py b/cryptography/hazmat/bindings/openssl/ec.py index 7ecd5979..c0c4f887 100644 --- a/cryptography/hazmat/bindings/openssl/ec.py +++ b/cryptography/hazmat/bindings/openssl/ec.py @@ -23,7 +23,10 @@ TYPES = """ static const int Cryptography_HAS_EC; typedef ... EC_KEY; -typedef ... EC_builtin_curve; +typedef struct { + int nid; + const char *comment; +} EC_builtin_curve; static const int NID_X9_62_prime192v1; static const int NID_X9_62_prime192v2; -- cgit v1.2.3 From 664030c13c0b62b872e6f1e9169ec5b570b73533 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 4 Mar 2014 19:10:10 -0800 Subject: Fix for systems without EC --- cryptography/hazmat/bindings/openssl/ec.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/ec.py b/cryptography/hazmat/bindings/openssl/ec.py index c0c4f887..c3ca6e93 100644 --- a/cryptography/hazmat/bindings/openssl/ec.py +++ b/cryptography/hazmat/bindings/openssl/ec.py @@ -23,10 +23,7 @@ TYPES = """ static const int Cryptography_HAS_EC; typedef ... EC_KEY; -typedef struct { - int nid; - const char *comment; -} EC_builtin_curve; +typedef ... EC_builtin_curve; static const int NID_X9_62_prime192v1; static const int NID_X9_62_prime192v2; @@ -45,6 +42,8 @@ EC_KEY *EC_KEY_new_by_curve_name(int); void EC_KEY_free(EC_KEY *); size_t EC_get_builtin_curves(EC_builtin_curve *, size_t); + +int Cryptography_EC_builtin_curve_get_nid(EC_builtin_curve); """ CUSTOMIZATIONS = """ @@ -55,8 +54,13 @@ typedef void EC_builtin_curve; EC_KEY* (*EC_KEY_new_by_curve_name)(int) = NULL; void (*EC_KEY_free)(EC_KEY *) = NULL; size_t (*EC_get_builtin_curves)(EC_builtin_curve *, size_t) = NULL; +int (*Cryptography_EC_builtin_curve_get_nid)(EC_builtin_curve) = NULL; #else static const long Cryptography_HAS_EC = 1; + +int Cryptography_EC_builtin_curve_get_nid(EC_builtin_curve c) { + return c.nid; +} #endif """ @@ -64,5 +68,8 @@ CONDITIONAL_NAMES = { "Cryptography_HAS_EC": [ "EC_KEY_new_by_curve_name", "EC_KEY_free", + "EC_get_builtin_curves", + + "Cryptography_EC_builtin_curve_get_nid", ], } -- cgit v1.2.3 From 27898f4fcc560e9bf01b88d8083ad7a6f0e77592 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 4 Mar 2014 19:19:43 -0800 Subject: Ugh, C --- cryptography/hazmat/bindings/openssl/ec.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/ec.py b/cryptography/hazmat/bindings/openssl/ec.py index c3ca6e93..9fca1ef0 100644 --- a/cryptography/hazmat/bindings/openssl/ec.py +++ b/cryptography/hazmat/bindings/openssl/ec.py @@ -43,7 +43,7 @@ void EC_KEY_free(EC_KEY *); size_t EC_get_builtin_curves(EC_builtin_curve *, size_t); -int Cryptography_EC_builtin_curve_get_nid(EC_builtin_curve); +int Cryptography_EC_builtin_curve_get_nid(EC_builtin_curve *); """ CUSTOMIZATIONS = """ @@ -54,12 +54,12 @@ typedef void EC_builtin_curve; EC_KEY* (*EC_KEY_new_by_curve_name)(int) = NULL; void (*EC_KEY_free)(EC_KEY *) = NULL; size_t (*EC_get_builtin_curves)(EC_builtin_curve *, size_t) = NULL; -int (*Cryptography_EC_builtin_curve_get_nid)(EC_builtin_curve) = NULL; +int (*Cryptography_EC_builtin_curve_get_nid)(EC_builtin_curve *) = NULL; #else static const long Cryptography_HAS_EC = 1; -int Cryptography_EC_builtin_curve_get_nid(EC_builtin_curve c) { - return c.nid; +int Cryptography_EC_builtin_curve_get_nid(EC_builtin_curve *c) { + return c->nid; } #endif """ -- cgit v1.2.3