本文整理汇总了Python中mailpile.crypto.gpgi.GnuPG.get_minimal_key方法的典型用法代码示例。如果您正苦于以下问题:Python GnuPG.get_minimal_key方法的具体用法?Python GnuPG.get_minimal_key怎么用?Python GnuPG.get_minimal_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailpile.crypto.gpgi.GnuPG
的用法示例。
在下文中一共展示了GnuPG.get_minimal_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TransformOutgoing
# 需要导入模块: from mailpile.crypto.gpgi import GnuPG [as 别名]
# 或者: from mailpile.crypto.gpgi.GnuPG import get_minimal_key [as 别名]
def TransformOutgoing(self, sender, rcpts, msg, **kwargs):
matched = False
keydata = mutual = sender_keyid = key_binary = None
gnupg = GnuPG(self.config, event=GetThreadEvent())
profile = self._get_sender_profile(sender, kwargs)
vcard = profile['vcard']
if vcard is not None:
crypto_format = vcard.crypto_format
sender_keyid = vcard.pgp_key
if sender_keyid and 'autocrypt' in crypto_format:
key_binary = gnupg.get_minimal_key(key_id=sender_keyid,
user_id=sender)
if key_binary:
mutual = 'E' in crypto_format.split('+')[0].split(':')[-1]
msg["Autocrypt"] = make_autocrypt_header(
sender, key_binary, prefer_encrypt_mutual=mutual)
if 'encrypt' in msg.get('Encryption', '').lower():
gossip_list = []
for rcpt in rcpts:
# FIXME: Check if any of the recipients are in the BCC
# header; omit their keys if so?
try:
# This *should* always succeed: if we are encrypting,
# then the key we encrypt to should already be in
# the keychain.
if '#' in rcpt:
rcpt, rcpt_keyid = rcpt.split('#')
else:
# This happens when composing in the CLI.
rcpt_keyid = rcpt
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