def pkcs7_seal(self, text, recip=None,pin="safenet123$"): self.session.login(pin=pin) if (None==recip): recip=self.barium_cert buf = makebuf(text) print text print buf sm = SMIME.SMIME() sm.pkey = self.my_pkey sm.x509 = self.my_cert M2Crypto.EVP.PKey p7 = sm.sign(buf) x509 = X509.load_cert('recipient.pem') stk = X509.X509_Stack() stk.push(x509) sm.set_x509_stack(stk) sm.set_x509_stack(stk) sm.set_cipher(SMIME.Cipher('des_ede3_cbc')) tmp = BIO.MemoryBuffer() m2.pkcs7_write_bio(p7._ptr(),tmp._ptr()) p7a = sm.encrypt(tmp) out = BIO.MemoryBuffer() sm.write(out, p7a) self.session.logout() return out.read()
def write(self, bio): # type: (BIO.BIO) -> int return m2.pkcs7_write_bio(self.pkcs7, bio._ptr())
def write(self, bio): return m2.pkcs7_write_bio(self.pkcs7, bio._ptr())