From: Victor Wagner Date: Wed, 4 Jun 2014 20:38:12 +0000 (+0400) Subject: Removed x509 stuff from pkey.py and placed into separate file X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=7c390cd3c8d93a8fb5f1a769fa61c59c0bf9bdd0;p=oss%2Fctypescrypto.git Removed x509 stuff from pkey.py and placed into separate file --- 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):