def handle_inline_pgp(gpg, body, attachments): # attachments might contain public key attachments = [crypto.decrypt_attachment(gpg, attachment) for attachment in attachments] crypto.import_public_keys_from_attachments(gpg, attachments) encryption_status, signature_status, reason = crypto.check_encryption_and_signature(gpg, body) return encryption_status, signature_status, reason
def handle_multipart_encrypted(gpg, body): encryption_status, signature_status, reason = crypto.check_encryption_and_signature(gpg, body) if encryption_status != crypto.Encryption.correct: return encryption_status, signature_status, reason # parse the decrypted data into body and attachments result = gpg.decrypt(body) _, _, body, attachments = parse_message(result.data) # attachments might contain public key attachments = [crypto.decrypt_attachment(gpg, attachment) for attachment in attachments] crypto.import_public_keys_from_attachments(gpg, attachments) return encryption_status, signature_status, reason