Ejemplo n.º 1
0
    def verify(self, store, flags, data=None, certs=None):
        """
        Verifies signature under CMS message using trusted cert store

        @param store -  X509Store object with trusted certs
        @param flags - OR-ed combination of flag consants
        @param data - message data, if messge has detached signature
        param certs - list of certificates to use during verification
                If Flags.NOINTERN is specified, these are only
                sertificates to search for signing certificates
        @returns True if signature valid, False otherwise
        """
        bio = None
        if data != None:
            bio_obj = Membio(data)
            bio = bio_obj.bio
        if certs is not None and len(certs) > 0:
            certstack_obj = StackOfX509(
                certs)  # keep reference to prevent immediate __del__ call
            certstack = certstack_obj.ptr
        else:
            certstack = None
        res = libcrypto.CMS_verify(self.ptr, certstack, store.store, bio, None,
                                   flags)
        return res > 0
Ejemplo n.º 2
0
 def data(self):
     """
     Returns signed data if present in the message
     """
     bio = Membio()
     if not libcrypto.CMS_verify(self.ptr, None, None, None, bio.bio,
                                 Flags.NO_VERIFY):
         raise CMSError("extract data")
     return str(bio)