Beispiel #1
0
            elif 'sign' in crypto_policy:
                wrapper = OpenPGPMimeSigningWrapper
            elif 'encrypt' in crypto_policy:
                wrapper = OpenPGPMimeEncryptingWrapper
            if wrapper:
                msg = wrapper(self.config,
                              sender=sender,
                              cleaner=cleaner,
                              recipients=rcpts).wrap(
                                  msg, prefer_inline=prefer_inline)
                matched = True

        return sender, rcpts, msg, matched, (not matched)


_plugins.register_outgoing_email_content_transform('500_gnupg', ContentTxf)
_plugins.register_outgoing_email_crypto_transform('500_gnupg', CryptoTxf)

##[ Misc. GPG-related API commands ]##########################################


class GPGKeySearch(Command):
    """Search for a GPG Key."""
    ORDER = ('', 0)
    SYNOPSIS = (None, 'crypto/gpg/searchkey', 'crypto/gpg/searchkey',
                '<terms>')
    HTTP_CALLABLE = ('GET', )
    HTTP_QUERY_VARS = {'q': 'search terms'}

    class CommandResult(Command.CommandResult):
        def as_text(self):
Beispiel #2
0
                obscured = {}

            if wrapper:
                msg = wrapper(self.config,
                              sender=sender,
                              cleaner=cleaner,
                              recipients=rcpts,
                              use_html_wrapper=self.config.prefs.gpg_html_wrap,
                              obscured_headers=obscured
                              ).wrap(msg, prefer_inline=prefer_inline)
                matched = True

        return sender, rcpts, msg, matched, (not matched)


_plugins.register_outgoing_email_content_transform('500_gnupg', ContentTxf)
_plugins.register_outgoing_email_crypto_transform('500_gnupg', CryptoTxf)

##[ Misc. GPG-related API commands ]##########################################

class GPGKeySearch(Command):
    """Search for a GPG Key."""
    ORDER = ('', 0)
    SYNOPSIS = (None, 'crypto/gpg/searchkey', 'crypto/gpg/searchkey', '<terms>')
    HTTP_CALLABLE = ('GET', )
    HTTP_QUERY_VARS = {'q': 'search terms'}

    class CommandResult(Command.CommandResult):
        def as_text(self):
            if self.result:
                return '\n'.join(["%s: %s <%s>" % (keyid, x["name"], x["email"]) for keyid, det in self.result.iteritems() for x in det["uids"]])
Beispiel #3
0
                            if (rcpt != sender) and rcpt_keyid:
                                kb = gnupg.get_minimal_key(key_id=rcpt_keyid,
                                                           user_id=rcpt)
                                if kb:
                                    gossip_list.append(
                                        make_autocrypt_header(
                                            rcpt,
                                            kb,
                                            prefix='Autocrypt-Gossip'))
                        except (ValueError, IndexError):
                            pass
                    if len(gossip_list) > 1:
                        # No point gossiping peoples keys back to them alone.
                        for hdr in gossip_list:
                            msg.add_header('Autocrypt-Gossip', hdr)

                matched = True

        return sender, rcpts, msg, matched, True


_plugins.register_meta_kw_extractor('autocrypt', autocrypt_meta_kwe)
_plugins.register_commands(AutoCryptSearch, AutoCryptForget, AutoCryptParse,
                           AutoCryptPeers)

# Note: we perform our transformations BEFORE the GnuPG transformations
# (prio 500), so the memory hole transformation can take care of hiding
# the Autocrypt-Gossip headers.
_plugins.register_outgoing_email_content_transform('400_autocrypt',
                                                   AutoCryptTxf)
Beispiel #4
0
                            if (rcpt != sender) and rcpt_keyid:
                                kb = gnupg.get_minimal_key(key_id=rcpt_keyid,
                                                           user_id=rcpt)
                                if kb:
                                    gossip_list.append(make_autocrypt_header(
                                        rcpt, kb, prefix='Autocrypt-Gossip'))
                        except (ValueError, IndexError):
                            pass
                    if len(gossip_list) > 1:
                        # No point gossiping peoples keys back to them alone.
                        for hdr in gossip_list:
                            msg.add_header('Autocrypt-Gossip', hdr)

                matched = True

        return sender, rcpts, msg, matched, True


_plugins.register_meta_kw_extractor('autocrypt', autocrypt_meta_kwe)
_plugins.register_commands(
    AutoCryptSearch,
    AutoCryptForget,
    AutoCryptParse,
    AutoCryptPeers)

# Note: we perform our transformations BEFORE the GnuPG transformations
# (prio 500), so the memory hole transformation can take care of hiding
# the Autocrypt-Gossip headers.
_plugins.register_outgoing_email_content_transform(
    '400_autocrypt', AutoCryptTxf)