def text_crlf(text): bio_in = BIO.MemoryBuffer(text) bio_out = BIO.MemoryBuffer() if m2.smime_crlf_copy(bio_in, bio_out): return bio_out.read() else: raise Err.get_error()
def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): """ Returns the key(pair) as a string in PEM format. """ bio = BIO.MemoryBuffer() self.save_key_bio(bio, cipher, callback) return bio.read()
def text_crlf_bio(bio_in): bio_out = BIO.MemoryBuffer() m2.smime_crlf_copy(bio_in, bio_out) if m2.smime_crlf_copy(bio_in, bio_out): return bio_out else: raise Err.get_error()
def as_pem(self): """ Returns the Diffie-Hellman parameters as a string in PEM format. """ assert m2.dh_type_check(self.dh), "'dh' type error" bio = BIO.MemoryBuffer() m2.dh_write_params(self.dh, bio._ptr()) return bio.read()
def load_key_string(string, callback=util.passphrase_callback): """ Load an RSA key pair from a string. @type string: string @param string: String containing RSA key pair in PEM format. @type callback: Python callable @param callback: A Python callable object that is invoked to acquire a passphrase with which to unlock the key. The default is util.passphrase_callback. @rtype: M2Crypto.RSA.RSA @return: M2Crypto.RSA.RSA object. """ bio = BIO.MemoryBuffer(string) return load_key_bio(bio, callback)
def get_error(): err = BIO.MemoryBuffer() m2.err_print_errors(err.bio_ptr()) return err.getvalue()
def __str__(self): assert m2.asn1_utctime_type_check( self.asn1_utctime), "'asn1_utctime' type error'" buf = BIO.MemoryBuffer() m2.asn1_utctime_print(buf.bio_ptr(), self.asn1_utctime) return buf.read_all()
def as_text(self, flags=0): buf = BIO.MemoryBuffer() m2.asn1_string_print_ex(buf.bio_ptr(), self.asn1str, flags) return buf.read_all()
def __str__(self): buf = BIO.MemoryBuffer() m2.asn1_string_print(buf.bio_ptr(), self.asn1str) return buf.read_all()
def text_crlf_bio(bio_in): bio_out = BIO.MemoryBuffer() if m2.smime_crlf_copy(bio_in._ptr(), bio_out._ptr()): return bio_out else: raise SMIME_Error(Err.get_error())