(self, gpg, signer)
return True
Verify signed (but non-encrypted) message from target signer

        Detects whether the clearsigned plaintext messages comes from the
        specified signer. In the positive case, overwrite the "original" data
        container with the underlying data, excluding the signature. In other
        words, if the verification is succesful, remove the signature and leave
        the data only.

        Args:
            gpg    : Gpg object.
            signer : Fingerprint of a target signer.

        Returns:
            (bool) Whether the message is signed by the target signer.
Verify signed (but non-encrypted) message from target signer
Verify signed ( but non - encrypted ) message from target signer
def verify(self, gpg, signer):
        """Verify signed (but non-encrypted) message from target signer

        Detects whether the clearsigned plaintext messages comes from the
        specified signer. In the positive case, overwrite the "original" data
        container with the underlying data, excluding the signature. In other
        words, if the verification is succesful, remove the signature and leave
        the data only.

        Args:
            gpg    : Gpg object.
            signer : Fingerprint of a target signer.

        Returns:
            (bool) Whether the message is signed by the target signer.

        """
        assert (signer is not None)

        verif_obj = gpg.gpg.verify(self.data['original'])
        verified = verif_obj.trust_level is not None
        signed_by = verif_obj.fingerprint

        if (not signed_by):
            logger.info("Dropping message - not signed")
            return False

        if (signed_by != signer):
            logger.info("Dropping message - not signed by the selected "
                        "sender")
            return False

        if (not verified):
            logger.info("Dropping message - signature unverified")
            return False

        logger.info("Signed by {} (verified w/ trust level: {})".format(
            signed_by, verif_obj.trust_text))

        if (verif_obj.trust_level < verif_obj.TRUST_FULLY):
            logger.warning("Dropping message - signature unverified")
            return False

        # The signature has been verified. However, verif_obj does not return
        # the original data. In this case, gpg.decrypt() can be used to get the
        # original data, even though this is not strictly a decryption. In this
        # case, decrypted_data.ok returns false, but the data becomes available
        # on decrypted_data.data (although with a '\n' in the end).
        decrypted_data = gpg.decrypt(self.data['original'])
        assert (verif_obj.fingerprint == decrypted_data.fingerprint)
        assert (verif_obj.trust_level == decrypted_data.trust_level)
        assert (decrypted_data.data[-1] == ord('\n'))
        self.data['original'] = decrypted_data.data[:-1]

        return True
def verify ( self , gpg , signer ) : assert ( signer is not None ) verif_obj = gpg . gpg . verify ( self . data [ 'original' ] ) verified = verif_obj . trust_level is not None signed_by = verif_obj . fingerprint if ( not signed_by ) : logger . info ( "Dropping message - not signed" ) return False if ( signed_by != signer ) : logger . info ( "Dropping message - not signed by the selected " "sender" ) return False if ( not verified ) : logger . info ( "Dropping message - signature unverified" ) return False logger . info ( "Signed by {} (verified w/ trust level: {})" . format ( signed_by , verif_obj . trust_text ) ) if ( verif_obj . trust_level < verif_obj . TRUST_FULLY ) : logger . warning ( "Dropping message - signature unverified" ) return False # The signature has been verified. However, verif_obj does not return # the original data. In this case, gpg.decrypt() can be used to get the # original data, even though this is not strictly a decryption. In this # case, decrypted_data.ok returns false, but the data becomes available # on decrypted_data.data (although with a '\n' in the end). decrypted_data = gpg . decrypt ( self . data [ 'original' ] ) assert ( verif_obj . fingerprint == decrypted_data . fingerprint ) assert ( verif_obj . trust_level == decrypted_data . trust_level ) assert ( decrypted_data . data [ - 1 ] == ord ( '\n' ) ) self . data [ 'original' ] = decrypted_data . data [ : - 1 ] return True