+ This function is called when the piece_type of a payload piece is
+ TxtType.message, or GPG Message block. This should be encrypted text. If
+ the encryted block is correclty signed, a sig will be attached to
+ .target_key unless there is already one there.
+
+ Args:
+ piece: a PayloadPiece object.
+ replyinfo_obj: object which gets updated with decryption status, etc.
+
+ Returns:
+ Nothing
+
+ Pre:
+ the piece.payload_piece value should be TxtType.message.
+
+ Post:
+ replyinfo_obj gets updated with decryption status, signing status, a
+ potential signing key, posession status of the public key for the
+ signature and encryption capability status if that key is missing.
+ """
+
+ if piece.gpg_data.plainobj == None:
+ replyinfo_obj.decrypt_failure = True
+ return
+
+ replyinfo_obj.decrypt_success = True
+
+ # we already have a key (and a message)
+ if replyinfo_obj.target_key != None:
+ return
+
+ if piece.gpg_data.sigs == []:
+ if piece.gpg_data.sigkey_missing == True:
+ replyinfo_obj.sigkey_missing = True
+
+ if piece.gpg_data.key_cannot_encrypt == True:
+ replyinfo_obj.key_cannot_encrypt = True
+
+ # only include a signed message in the reply.
+ get_signed_part = True
+
+ else:
+ replyinfo_obj.target_key = piece.gpg_data.sigs[0]
+ replyinfo_obj.sig_success = True
+ get_signed_part = False
+
+ flatten_decrypted_payloads(piece.gpg_data.plainobj, replyinfo_obj, get_signed_part)
+
+ # to catch public keys in encrypted blocks
+ prepare_for_reply(piece.gpg_data.plainobj, replyinfo_obj)
+
+
+def prepare_for_reply_pubkey (piece, replyinfo_obj):
+ """Helper function for prepare_for_reply(). Marks pubkey import status.
+
+ Marks replyinfo_obj with pub key import status.
+
+ Args:
+ piece: a PayloadPiece object
+ replyinfo_obj: a ReplyInfo object
+
+ Pre:
+ piece.piece_type should be set to TxtType.pubkey .
+
+ Post:
+ replyinfo_obj has its fields updated.
+ """
+
+ if piece.gpg_data.keys == []:
+ if piece.gpg_data.key_cannot_encrypt == True:
+ replyinfo_obj.key_cannot_encrypt = True
+ else:
+ replyinfo_obj.pubkey_success = True
+
+ # prefer public key as a fallback for the encrypted reply
+ replyinfo_obj.fallback_target_key = piece.gpg_data.keys[0]