diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2013-12-23 10:06:12 -0500 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2013-12-23 11:23:45 -0500 |
commit | e7d5fdbb7bb2969329070e6f1b35ec49e634f0b3 (patch) | |
tree | 0d824eac7708fb0347ac453ac091fd9bac68de0e | |
parent | ab51df1d664fafe1426748e38ddb125cf31d4052 (diff) | |
download | cryptography-e7d5fdbb7bb2969329070e6f1b35ec49e634f0b3.tar.gz cryptography-e7d5fdbb7bb2969329070e6f1b35ec49e634f0b3.tar.bz2 cryptography-e7d5fdbb7bb2969329070e6f1b35ec49e634f0b3.zip |
bind a few more things necessary for OpenSSL.crypto. Also tweak some existing definitions to be more functional.
-rw-r--r-- | cryptography/hazmat/backends/openssl/asn1.py | 10 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 1 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/bignum.py | 9 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/evp.py | 7 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/nid.py | 1 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/objects.py | 41 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/rsa.py | 2 |
7 files changed, 68 insertions, 3 deletions
diff --git a/cryptography/hazmat/backends/openssl/asn1.py b/cryptography/hazmat/backends/openssl/asn1.py index b56932fa..28ec0631 100644 --- a/cryptography/hazmat/backends/openssl/asn1.py +++ b/cryptography/hazmat/backends/openssl/asn1.py @@ -16,7 +16,14 @@ INCLUDES = """ """ TYPES = """ -typedef ... time_t; +/* + * XXX This typedef is wrong. + * https://bitbucket.org/cffi/cffi/issue/69/support-for-using-typedef-with-primitive + * http://paste.pound-python.org/show/iJcTUMkKeBeS6yXpZWUU/ + * < fijal> exarkun: I think you want to declare your value too large (e.g. long) + * < fijal> exarkun: that way you'll never pass garbage + */ +typedef long time_t; typedef int ASN1_BOOLEAN; typedef ... ASN1_INTEGER; @@ -118,6 +125,7 @@ int ASN1_INTEGER_cmp(ASN1_INTEGER *, ASN1_INTEGER *); long ASN1_INTEGER_get(ASN1_INTEGER *); BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *, BIGNUM *); +ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); """ CUSTOMIZATIONS = """ diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 6cc8275d..3d2fa01f 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -71,6 +71,7 @@ class Backend(object): "evp", "hmac", "nid", + "objects", "opensslv", "pem", "pkcs7", diff --git a/cryptography/hazmat/backends/openssl/bignum.py b/cryptography/hazmat/backends/openssl/bignum.py index 68d0c3a2..4885d5b4 100644 --- a/cryptography/hazmat/backends/openssl/bignum.py +++ b/cryptography/hazmat/backends/openssl/bignum.py @@ -17,7 +17,14 @@ INCLUDES = """ TYPES = """ typedef ... BIGNUM; -typedef ... BN_ULONG; +/* + * XXX This typedef is wrong. + * https://bitbucket.org/cffi/cffi/issue/69/support-for-using-typedef-with-primitive + * http://paste.pound-python.org/show/iJcTUMkKeBeS6yXpZWUU/ + * < fijal> exarkun: I think you want to declare your value too large (e.g. long) + * < fijal> exarkun: that way you'll never pass garbage + */ +typedef unsigned long long BN_ULONG; """ FUNCTIONS = """ diff --git a/cryptography/hazmat/backends/openssl/evp.py b/cryptography/hazmat/backends/openssl/evp.py index 7e50a6b3..68bff2b7 100644 --- a/cryptography/hazmat/backends/openssl/evp.py +++ b/cryptography/hazmat/backends/openssl/evp.py @@ -24,7 +24,9 @@ typedef struct { ...; } EVP_CIPHER_CTX; typedef ... EVP_MD; -typedef struct env_md_ctx_st EVP_MD_CTX; +typedef struct env_md_ctx_st { + ...; +} EVP_MD_CTX; typedef struct evp_pkey_st { int type; @@ -32,6 +34,7 @@ typedef struct evp_pkey_st { } EVP_PKEY; static const int EVP_PKEY_RSA; static const int EVP_PKEY_DSA; +static const int EVP_MAX_MD_SIZE; static const int Cryptography_EVP_CTRL_GCM_SET_IVLEN; static const int Cryptography_EVP_CTRL_GCM_GET_TAG; static const int Cryptography_EVP_CTRL_GCM_SET_TAG; @@ -92,6 +95,8 @@ int EVP_VerifyInit(EVP_MD_CTX *, const EVP_MD *); int EVP_VerifyUpdate(EVP_MD_CTX *, const void *, size_t); int EVP_VerifyFinal(EVP_MD_CTX *, const unsigned char *, unsigned int, EVP_PKEY *); + +const EVP_MD *EVP_md5(void); """ MACROS = """ diff --git a/cryptography/hazmat/backends/openssl/nid.py b/cryptography/hazmat/backends/openssl/nid.py index 111f82f9..40aed19f 100644 --- a/cryptography/hazmat/backends/openssl/nid.py +++ b/cryptography/hazmat/backends/openssl/nid.py @@ -37,6 +37,7 @@ static const int NID_ecdsa_with_SHA384; static const int NID_ecdsa_with_SHA512; static const int NID_crl_reason; static const int NID_pbe_WithSHA1And3_Key_TripleDES_CBC; +static const int NID_subject_alt_name; """ FUNCTIONS = """ diff --git a/cryptography/hazmat/backends/openssl/objects.py b/cryptography/hazmat/backends/openssl/objects.py new file mode 100644 index 00000000..b981252b --- /dev/null +++ b/cryptography/hazmat/backends/openssl/objects.py @@ -0,0 +1,41 @@ +# 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 <openssl/objects.h> +""" + +TYPES = """ +""" + +FUNCTIONS = """ +ASN1_OBJECT * OBJ_nid2obj(int n); +const char * OBJ_nid2ln(int n); +const char * OBJ_nid2sn(int n); +int OBJ_obj2nid(const ASN1_OBJECT *o); +int OBJ_ln2nid(const char *ln); +int OBJ_sn2nid(const char *sn); +int OBJ_txt2nid(const char *s); +ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); +int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); +int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b); +ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o); +int OBJ_create(const char *oid,const char *sn,const char *ln); +void OBJ_cleanup(void); +""" + +MACROS = """ +""" + +CUSTOMIZATIONS = """ +""" diff --git a/cryptography/hazmat/backends/openssl/rsa.py b/cryptography/hazmat/backends/openssl/rsa.py index e3a24d0f..f9d9cb59 100644 --- a/cryptography/hazmat/backends/openssl/rsa.py +++ b/cryptography/hazmat/backends/openssl/rsa.py @@ -33,6 +33,7 @@ static const int RSA_SSLV23_PADDING; static const int RSA_NO_PADDING; static const int RSA_PKCS1_OAEP_PADDING; static const int RSA_X931_PADDING; +static const int RSA_F4; """ FUNCTIONS = """ @@ -50,6 +51,7 @@ int RSA_public_decrypt(int, const unsigned char *, unsigned char *, RSA *, int); int RSA_private_decrypt(int, const unsigned char *, unsigned char *, RSA *, int); +int RSA_print(BIO *bp, const RSA *r,int offset); """ MACROS = """ |