Skip to content

Commit

Permalink
PGPKey.encrypt: add max_featureset option to limit version of SEIPD
Browse files Browse the repository at this point in the history
  • Loading branch information
dkg committed Aug 10, 2023
1 parent e7cb001 commit 4ae48f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pgpy/pgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,8 @@ def encrypt(self,
message: PGPMessage,
sessionkey: Optional[bytes] = None,
user: Optional[str] = None,
cipher: Optional[SymmetricKeyAlgorithm] = None) -> PGPMessage:
cipher: Optional[SymmetricKeyAlgorithm] = None,
max_featureset: Optional[Features] = None) -> PGPMessage:
"""Encrypt a PGPMessage using this key.
:param message: The message to encrypt.
Expand Down Expand Up @@ -2871,6 +2872,9 @@ def encrypt(self,
if compprefs is None:
compprefs = []

if max_featureset is not None:
features &= max_featureset

pref_cipher = next((c for c in cipherprefs if c.is_supported), SymmetricKeyAlgorithm.TripleDES)
cipher_algo = cipher if cipher is not None else pref_cipher

Expand Down

0 comments on commit 4ae48f4

Please sign in to comment.