diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2019-03-30 08:54:13 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2019-03-30 09:51:54 +0100 |
commit | 71888aa50c28da59ebbde925c8f82e546180f057 (patch) | |
tree | 4bfaa2eec95c1b1c2958c96cb50c54cf734a7e29 /M2Crypto_ext.i | |
parent | 1851abc4e3f6adeaa1d41168a75b1a87f763c0eb (diff) | |
download | m2crypto_ext-71888aa50c28da59ebbde925c8f82e546180f057.tar.gz m2crypto_ext-71888aa50c28da59ebbde925c8f82e546180f057.tar.bz2 m2crypto_ext-71888aa50c28da59ebbde925c8f82e546180f057.zip |
Add separate compare function to work around the segfault.
Diffstat (limited to 'M2Crypto_ext.i')
-rw-r--r-- | M2Crypto_ext.i | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/M2Crypto_ext.i b/M2Crypto_ext.i index fb4565c..95d0524 100644 --- a/M2Crypto_ext.i +++ b/M2Crypto_ext.i @@ -3,6 +3,7 @@ %include "constraints.i" %{ +#include <stdbool.h> #include <openssl/x509.h> typedef STACK_OF(X509_EXTENSION) X509_EXTENSION_STACK; %} @@ -13,18 +14,14 @@ typedef STACK_OF(X509_EXTENSION) X509_EXTENSION_STACK; X509_EXTENSION_STACK *x509_req_get_extensions(X509_REQ *req) { return X509_REQ_get_extensions(req); } -%} -%inline %{ -PyObject *x509_extension_get_data(X509_EXTENSION *ext) { - ASN1_OCTET_STRING *octet_str = X509_EXTENSION_get_data(ext); - const unsigned char* octet_str_data = octet_str->data; - long xlen; - int tag, xclass; - ASN1_get_object(&octet_str_data, &xlen, &tag, &xclass, octet_str->length); +ASN1_OCTET_STRING *x509_extension_get_data(X509_EXTENSION *ext) { + return X509_EXTENSION_get_data(ext); +} - PyObject * encodedString; - encodedString = PyString_FromStringAndSize((const char*)octet_str_data, xlen); - return encodedString; +bool x509_extension_cmp(X509_EXTENSION *ext1, X509_EXTENSION *ext2) { + ASN1_OCTET_STRING *data1 = X509_EXTENSION_get_data(ext1); + ASN1_OCTET_STRING *data2 = X509_EXTENSION_get_data(ext2); + return ASN1_OCTET_STRING_cmp(data1, data2) == 0; } %} |