(self, gpg, signer_filter=None)
return True
Decrypt the data

        Args:
            gpg           : Gpg object.
            signer_filter : Fingerprint of a target signer. If the message is
                            not signed by this fingerprint, drop it.

        Returns:
            True if the decryption was successful.
Decrypt the data
Decrypt the data
def decrypt(self, gpg, signer_filter=None):
        """Decrypt the data

        Args:
            gpg           : Gpg object.
            signer_filter : Fingerprint of a target signer. If the message is
                            not signed by this fingerprint, drop it.

        Returns:
            True if the decryption was successful.

        """

        decrypted_data = gpg.decrypt(self.data['encrypted'])

        if (not decrypted_data.ok):
            logger.info("Size: %7d bytes\t Decryption: FAILED\t" %
                        (len(self.data['encrypted'])) +
                        "Not encrypted for us (%s)" % (decrypted_data.status))
            return False

        # Is the message digitally signed?
        if (decrypted_data.fingerprint is not None):
            signed_by = decrypted_data.fingerprint
            verified = decrypted_data.trust_level is not None
            sign_str_short = "Signed"

            if verified:
                sign_str_long = \
                    "Signed by %s (verified w/ trust level: %s)" % (
                        signed_by, decrypted_data.trust_text)
            else:
                sign_str_long = "Signed by %s (unverified)" % (signed_by)
        else:
            sign_str_short = "Unsigned"
            sign_str_long = ""
            signed_by = None
            verified = False

        logger.info("Encrypted size: %7d bytes\t Decryption: OK    \t%s" %
                    (len(self.data['encrypted']), sign_str_short))

        if (len(sign_str_long) > 0):
            logger.info(sign_str_long)

        if (signer_filter is not None):
            if (not signed_by):
                logger.warning("Dropping message - not signed")
                return False

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

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

        logger.info("Decrypted size: %7d bytes" % (len(str(decrypted_data))))

        # We can't know whether decrypted data is encapsulated or not. So, for
        # now, put the data into both fields. If the decrypted data is
        # encapsulated, eventually "decapsulate" will be called and will
        # overwrite the "original" data container.
        self.data['original'] = decrypted_data.data
        self.data['encapsulated'] = decrypted_data.data

        return True
def decrypt ( self , gpg , signer_filter = None ) : decrypted_data = gpg . decrypt ( self . data [ 'encrypted' ] ) if ( not decrypted_data . ok ) : logger . info ( "Size: %7d bytes\t Decryption: FAILED\t" % ( len ( self . data [ 'encrypted' ] ) ) + "Not encrypted for us (%s)" % ( decrypted_data . status ) ) return False # Is the message digitally signed? if ( decrypted_data . fingerprint is not None ) : signed_by = decrypted_data . fingerprint verified = decrypted_data . trust_level is not None sign_str_short = "Signed" if verified : sign_str_long = "Signed by %s (verified w/ trust level: %s)" % ( signed_by , decrypted_data . trust_text ) else : sign_str_long = "Signed by %s (unverified)" % ( signed_by ) else : sign_str_short = "Unsigned" sign_str_long = "" signed_by = None verified = False logger . info ( "Encrypted size: %7d bytes\t Decryption: OK    \t%s" % ( len ( self . data [ 'encrypted' ] ) , sign_str_short ) ) if ( len ( sign_str_long ) > 0 ) : logger . info ( sign_str_long ) if ( signer_filter is not None ) : if ( not signed_by ) : logger . warning ( "Dropping message - not signed" ) return False if ( signer_filter != signed_by ) : logger . warning ( "Dropping message - not signed by the selected " "sender" ) return False if ( decrypted_data . trust_level < decrypted_data . TRUST_FULLY ) : logger . warning ( "Dropping message - signature unverified" ) return False logger . info ( "Decrypted size: %7d bytes" % ( len ( str ( decrypted_data ) ) ) ) # We can't know whether decrypted data is encapsulated or not. So, for # now, put the data into both fields. If the decrypted data is # encapsulated, eventually "decapsulate" will be called and will # overwrite the "original" data container. self . data [ 'original' ] = decrypted_data . data self . data [ 'encapsulated' ] = decrypted_data . data return True