From bc77663c0b937b05ca18269ffdb6e26f3c32d530 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 30 Sep 2013 11:25:58 -0700 Subject: Added bindings for OpenSSL's bn.h --- cryptography/bindings/openssl/api.py | 1 + cryptography/bindings/openssl/bignum.py | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 cryptography/bindings/openssl/bignum.py diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index d648d491..0270f9b6 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -25,6 +25,7 @@ class API(object): OpenSSL API wrapper. """ _modules = [ + "bignum", "evp", "opensslv", ] diff --git a/cryptography/bindings/openssl/bignum.py b/cryptography/bindings/openssl/bignum.py new file mode 100644 index 00000000..137eb3bd --- /dev/null +++ b/cryptography/bindings/openssl/bignum.py @@ -0,0 +1,35 @@ +# 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. + +INCLUDES = """ +#include +""" + +TYPES = """ +typedef ... BIGNUM; + +// Possibly belongs in an asn1.py +typedef ... ASN1_INTEGER; +""" + +FUNCTIONS = """ +BIGNUM *BN_new(); +void BN_free(BIGNUM *); + +int BN_set_word(BIGNUM *, unsigned long); + +char *BN_bn2hex(const BIGNUM *); +int BN_hex2bn(BIGNUM **, const char *); + +ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *, ASN1_INTEGER *); +""" -- cgit v1.2.3 From 6366934837b741aee8c1a77646378b81974b61c3 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 2 Oct 2013 10:55:37 -0700 Subject: Fixes to match teh C headers --- cryptography/bindings/openssl/bignum.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cryptography/bindings/openssl/bignum.py b/cryptography/bindings/openssl/bignum.py index 137eb3bd..258847a5 100644 --- a/cryptography/bindings/openssl/bignum.py +++ b/cryptography/bindings/openssl/bignum.py @@ -17,6 +17,7 @@ INCLUDES = """ TYPES = """ typedef ... BIGNUM; +typedef ... BN_ULONG; // Possibly belongs in an asn1.py typedef ... ASN1_INTEGER; @@ -26,10 +27,13 @@ FUNCTIONS = """ BIGNUM *BN_new(); void BN_free(BIGNUM *); -int BN_set_word(BIGNUM *, unsigned long); +int BN_set_word(BIGNUM *, BN_ULONG); char *BN_bn2hex(const BIGNUM *); int BN_hex2bn(BIGNUM **, const char *); -ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *, ASN1_INTEGER *); +ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *, ASN1_INTEGER *); +""" + +MACROS = """ """ -- cgit v1.2.3 From eec5c3c77f53b3d5542a6984e5321d0860b8317a Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 2 Oct 2013 11:05:27 -0700 Subject: Thsi is a macro --- cryptography/bindings/openssl/bignum.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cryptography/bindings/openssl/bignum.py b/cryptography/bindings/openssl/bignum.py index 258847a5..40397a54 100644 --- a/cryptography/bindings/openssl/bignum.py +++ b/cryptography/bindings/openssl/bignum.py @@ -31,9 +31,8 @@ int BN_set_word(BIGNUM *, BN_ULONG); char *BN_bn2hex(const BIGNUM *); int BN_hex2bn(BIGNUM **, const char *); - -ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *, ASN1_INTEGER *); """ MACROS = """ +ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *, ASN1_INTEGER *); """ -- cgit v1.2.3 From 069f0024a7de3399333dac2d6b5e4cdab28e81b6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 2 Oct 2013 14:59:10 -0700 Subject: Remove this, it properly belongs to ASN1, and that's for a seperate PR --- cryptography/bindings/openssl/bignum.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cryptography/bindings/openssl/bignum.py b/cryptography/bindings/openssl/bignum.py index 40397a54..72d467c3 100644 --- a/cryptography/bindings/openssl/bignum.py +++ b/cryptography/bindings/openssl/bignum.py @@ -18,9 +18,6 @@ INCLUDES = """ TYPES = """ typedef ... BIGNUM; typedef ... BN_ULONG; - -// Possibly belongs in an asn1.py -typedef ... ASN1_INTEGER; """ FUNCTIONS = """ @@ -34,5 +31,4 @@ int BN_hex2bn(BIGNUM **, const char *); """ MACROS = """ -ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *, ASN1_INTEGER *); """ -- cgit v1.2.3