From 7c390cd3c8d93a8fb5f1a769fa61c59c0bf9bdd0 Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Thu, 5 Jun 2014 00:38:12 +0400 Subject: [PATCH] Removed x509 stuff from pkey.py and placed into separate file --- ctypescrypto/pkey.py | 30 -------------------- ctypescrypto/x509.py | 65 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 30 deletions(-) create mode 100644 ctypescrypto/x509.py diff --git a/ctypescrypto/pkey.py b/ctypescrypto/pkey.py index 63bdfd8..d5e09ce 100644 --- a/ctypescrypto/pkey.py +++ b/ctypescrypto/pkey.py @@ -119,33 +119,3 @@ class PKey: libcrypto.EVP_PKEY_CTX_free(ctx) return PKey(key,True) -class X509: - def __init__(self,ptr): - self.cert = ptr - def __del__(self): - libcrypto.X509_free(self.cert) - def __str__(self): - """ Returns der string of the certificate """ - def pubkey(self): - """ Returns EVP PKEy object of certificate public key""" - return PKey(libcrypto.X509_get_pubkey(self.cert,False) - def verify(self,key): - """ Verify self on given issuer key """ - def frompem(s): - """ Create X509 object from pem string """ - def fromder(s): - """ Create X509 object from der string """ - -class Verifier: - def __init__(self,filename): - - def verify_cert(self,cert): - -class Signer: - def __init__(self,key): - self.key = key - def sign(self,digest): - if not self.key.cansign: - raise ValueError("Current PKey doesn't contain private part") - def verify(self,signature,digest): - diff --git a/ctypescrypto/x509.py b/ctypescrypto/x509.py new file mode 100644 index 0000000..28c587c --- /dev/null +++ b/ctypescrypto/x509.py @@ -0,0 +1,65 @@ +from ctypes import c_void_p +from ctypescrypto.bio import Membio +from ctypescrypto.exception import LibCryptoError +from crypescrypto import libcrypto + +class X509Name: + def __init__(self,ptr): + self.ptr=ptr + def __del__(self): + libcrypto.X509_NAME_free(self.ptr) + def __str__(self): + + def __len__(self): + return libcrypto.X509_NAME_entry_count(self.ptr) + + def __getattr__(self,key): + + def __setattr__(self,key,val): + +class X509_extlist: + def __init__(self,ptr): + self.ptr=ptr + def __del__(self): + libcrypto.X509_NAME_free(self.ptr) + def __str__(self): + + def __len__(self): + return libcrypto.X509_NAME_entry_count(self.ptr) + + def __getattr__(self,key): + + def __setattr__(self,key,val): + + + + + +class X509: + def __init__(self,ptr): + self.cert = ptr + def __del__(self): + libcrypto.X509_free(self.cert) + def __str__(self): + """ Returns der string of the certificate """ + def pubkey(self): + """ Returns EVP PKEy object of certificate public key""" + return PKey(libcrypto.X509_get_pubkey(self.cert,False) + def verify(self,key): + """ Verify self on given issuer key """ + def frompem(s): + """ Create X509 object from pem string """ + def fromder(s): + """ Create X509 object from der string """ + def subject(self): + return X509Name(libcrypto.X509_get_subject_name(self.cert)) + def issuer(self): + return X509Name(libcrypto.X509_get_issuer_name(self.cert)) + def serial(self): + return + + def startDate(self): + + def endDate(self); + + def extensions(self): -- 2.39.5