mirror of
https://github.com/chatmail/relay.git
synced 2026-05-23 06:18:03 +00:00
Fix OpenPGP payload check
Replace \r\r\n in literal.eml test with \r\n to make `test_filtermail_no_literal_packets` actually reach `check_openpgp_payload()` and make `check_openpgp_payload()` more strict.
This commit is contained in:
@@ -39,6 +39,9 @@
|
||||
- add IMAP capabilities instead of overwriting them
|
||||
([#413](https://github.com/deltachat/chatmail/pull/413))
|
||||
|
||||
- fix OpenPGP payload check
|
||||
([#435](https://github.com/deltachat/chatmail/pull/435))
|
||||
|
||||
|
||||
## 1.4.1 2024-07-31
|
||||
|
||||
|
||||
@@ -60,10 +60,11 @@ def check_openpgp_payload(payload: bytes):
|
||||
i += body_len
|
||||
|
||||
if i == len(payload):
|
||||
if packet_type_id == 18:
|
||||
# Last packet should be
|
||||
# Symmetrically Encrypted and Integrity Protected Data Packet (SEIPD)
|
||||
return True
|
||||
#
|
||||
# This is the only place where this function may return `True`.
|
||||
return packet_type_id == 18
|
||||
elif packet_type_id not in [1, 3]:
|
||||
# All packets except the last one must be either
|
||||
# Public-Key Encrypted Session Key Packet (PKESK)
|
||||
@@ -71,14 +72,8 @@ def check_openpgp_payload(payload: bytes):
|
||||
# Symmetric-Key Encrypted Session Key Packet (SKESK)
|
||||
return False
|
||||
|
||||
if i == 0:
|
||||
return False
|
||||
|
||||
if i > len(payload):
|
||||
# Payload is truncated.
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def check_armored_payload(payload: str):
|
||||
prefix = "-----BEGIN PGP MESSAGE-----\r\n\r\n"
|
||||
|
||||
Reference in New Issue
Block a user