Two utility patches
Conrad Steenberg <[email protected]>
| Newsgroups | gmane.comp.python.cryptography |
|---|---|
| Message-ID | <[email protected]> |
Hi Attached are two small patches that I've found useful and maintained for a while. I'd like to submit these for possible inclusion in the main tree. - The first patch wraps the library call int X509_verify(X509 *a, EVP_PKEY *r); and makes it available in the X509.X509 class. - The second provides a method to extract an RSA struct out of an EVP_PKEY struct, wrapping the library call RSA *EVP_PKEY_get1_RSA(EVP_PKEY *); These should obviously be adapted for the 0.15 branch eventually. Comments? Cheers Conrad
m2crypto-0.13.verify.diff
(text/x-patch, 1.2 KB)
--- M2Crypto/X509.py.orig Tue Mar 23 21:46:38 2004
+++ M2Crypto/X509.py Tue Dec 28 08:12:00 2004
@@ -139,6 +139,13 @@
m2.x509_name_print( buf.bio_ptr(), self.x509_name )
return buf.read_all()
+ def verify(self):
+ assert m2.x509_type_check(self.x509), "'x509' type error"
+ return m2.x509_verify(self.x509, m2.x509_get_pubkey(self.x509))
+
+ def verify_error_string(self,errnum):
+ assert m2.x509_type_check(self.x509), "'x509' type error"
+ return m2.x509_verify_error_string(errnum)
class X509:
--- SWIG/_x509.i.orig Sun Mar 21 04:37:46 2004
+++ SWIG/_x509.i Tue Dec 28 08:10:25 2004
@@ -27,7 +27,8 @@
%name(x509_set_issuer_name) extern int X509_set_issuer_name(X509 *, X509_NAME *);
%name(x509_set_subject_name) extern int X509_set_subject_name(X509 *, X509_NAME *);
-%name(x509_get_verify_error) extern const char *X509_verify_cert_error_string(long);
+%name(x509_verify) extern int X509_verify(X509 *a, EVP_PKEY *r);
+%name(x509_verify_error_string) extern const char *X509_verify_cert_error_string(long);
%name(x509_name_new) extern X509_NAME *X509_NAME_new( void );
%name(x509_name_free) extern void X509_NAME_free(X509_NAME *);
m2crypto-0.11.getkey.diff
(text/x-patch, 711 B)
--- SWIG/_rsa.i.orig Mon Jul 21 14:11:48 2003
+++ SWIG/_rsa.i Mon Jul 21 14:12:38 2003
@@ -6,15 +6,18 @@
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
+#include <openssl/evp.h>
%}
%apply Pointer NONNULL { RSA * };
%apply Pointer NONNULL { PyObject *pyfunc };
+%apply Pointer NONNULL { EVP_PKEY * };
%name(rsa_new) extern RSA *RSA_new(void);
%name(rsa_free) extern void RSA_free(RSA *);
%name(rsa_size) extern int RSA_size(const RSA *);
%name(rsa_check_key) extern int RSA_check_key(const RSA *);
+%name(rsa_from_pkey) extern RSA *EVP_PKEY_get1_RSA(EVP_PKEY *);
%constant int no_padding = RSA_NO_PADDING;
%constant int pkcs1_padding = RSA_PKCS1_PADDING;