Ejemplo n.º 1
0
Archivo: etoken.py Proyecto: zbo/zbodo
 def pkcs7_unseal(self, text, sender=None):
     if (None==sender): sender=self.barium_cert
     sm = SMIME.SMIME()
     sm.pkey = self.my_pkey
     sm.x509 = self.my_cert
     bio = BIO.MemoryBuffer(text)
     p7 = SMIME.PKCS7(m2.pkcs7_read_bio_der(bio._ptr()))
     out = sm.decrypt(p7)
     stk = X509.X509_Stack()
     stk.push(sender)
     store = self.ssl_ctx.get_cert_store()
     p7b = makebuf(out)
     p7final = m2.pkcs7_read_bio_der(p7b._ptr())
     return m2.pkcs7_verify0(p7final, stk._ptr(), store._ptr(), 0)
Ejemplo n.º 2
0
 def verify(self, pkcs7, data_bio=None, flags=0):
     # type: (PKCS7, BIO.BIO, int) -> Optional[bytes]
     if not hasattr(self, 'x509_stack'):
         raise SMIME_Error('no signer certs: use set_x509_stack()')
     if not hasattr(self, 'x509_store'):
         raise SMIME_Error('no x509 cert store: use set_x509_store()')
     assert isinstance(pkcs7, PKCS7), 'pkcs7 not an instance of PKCS7'
     p7 = pkcs7._ptr()
     if data_bio is None:
         blob = m2.pkcs7_verify0(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(), flags)
     else:
         blob = m2.pkcs7_verify1(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(),
                                 data_bio._ptr(), flags)
     return blob
Ejemplo n.º 3
0
 def verify(self, pkcs7, data_bio=None, flags=0):
     # type: (PKCS7, BIO.BIO, int) -> Optional[bytes]
     if not hasattr(self, 'x509_stack'):
         raise SMIME_Error('no signer certs: use set_x509_stack()')
     if not hasattr(self, 'x509_store'):
         raise SMIME_Error('no x509 cert store: use set_x509_store()')
     assert isinstance(pkcs7, PKCS7), 'pkcs7 not an instance of PKCS7'
     p7 = pkcs7._ptr()
     if data_bio is None:
         blob = m2.pkcs7_verify0(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(), flags)
     else:
         blob = m2.pkcs7_verify1(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(),
                                 data_bio._ptr(), flags)
     return blob
Ejemplo n.º 4
0
 def verify(self, pkcs7, data_bio=None, flags=0):
     if not hasattr(self, 'x509_stack'):
         raise SMIME_Error('no signer certs: use set_x509_stack()')
     if not hasattr(self, 'x509_store'):
         raise SMIME_Error('no x509 cert store: use set_x509_store()')
     assert isinstance(pkcs7, PKCS7), 'pkcs7 not an instance of PKCS7'
     p7 = pkcs7._ptr()
     if data_bio is None:
         blob = m2.pkcs7_verify0(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(), flags)
     else:
         blob = m2.pkcs7_verify1(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(),
                                 data_bio._ptr(), flags)
     if blob is None:
         raise SMIME_Error(Err.get_error())
     return blob
Ejemplo n.º 5
0
 def verify(self, pkcs7, data_bio=None, flags=0):
     if not hasattr(self, 'x509_stack'):
         raise SMIME_Error('no signer certs: use set_x509_stack()')
     if not hasattr(self, 'x509_store'):
         raise SMIME_Error('no x509 cert store: use set_x509_store()')
     assert isinstance(pkcs7, PKCS7), 'pkcs7 not an instance of PKCS7'
     p7 = pkcs7._ptr()
     if data_bio is None:
         blob = m2.pkcs7_verify0(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(), flags)
     else:
         blob = m2.pkcs7_verify1(p7, self.x509_stack._ptr(),
                                 self.x509_store._ptr(), data_bio._ptr(),
                                 flags)
     if blob is None:
         raise SMIME_Error(Err.get_error())
     return blob