SecurityInnovation / PGPy

Pretty Good Privacy for Python
BSD 3-Clause "New" or "Revised" License
317 stars 99 forks source link

Cannot use _require_usage_flags #382

Open spartacruz opened 2 years ago

spartacruz commented 2 years ago

Hi, as title says I cannot use as it mention on documentation image

Here is my sample code: image

and still, pgpy reject my key.. image

Could somebody assist me how to bypass flag checking?

Thanks. -Yuri

spartacruz commented 2 years ago

I already try to fetch pgpy on this gihub and it still not running at all image

J-M0 commented 2 years ago

Hi @spartacruz,

Could you put your sample code and error messages in code blocks please? This is better than screenshots as it would make it easier to test your code and read the errors.

Thanks!

scottmschafer commented 2 years ago

Just confirming that this is still an issue.

import pgpy
from pgpy.constants import PubKeyAlgorithm, KeyFlags, HashAlgorithm, SymmetricKeyAlgorithm, CompressionAlgorithm

#Generate key using documentation, but comment out EncryptCommunications and EncryptStorage
key = pgpy.PGPKey.new(PubKeyAlgorithm.RSAEncryptOrSign, 4096)
uid = pgpy.PGPUID.new('Abraham Lincoln', comment='Honest Abe', email='abraham.lincoln@whitehouse.gov')
key.add_uid(uid, usage={KeyFlags.Sign
#                         , KeyFlags.EncryptCommunications, KeyFlags.EncryptStorage
                       },
            hashes=[HashAlgorithm.SHA256, HashAlgorithm.SHA384, HashAlgorithm.SHA512, HashAlgorithm.SHA224],
            ciphers=[SymmetricKeyAlgorithm.AES256, SymmetricKeyAlgorithm.AES192, SymmetricKeyAlgorithm.AES128],
            compression=[CompressionAlgorithm.ZLIB, CompressionAlgorithm.BZ2, CompressionAlgorithm.ZIP, CompressionAlgorithm.Uncompressed])

#Attempt to encrypt new message without requiring usage flags
text_message = pgpy.PGPMessage.new("This is a brand spankin' new message!")
key._require_usage_flags = False
encrypted_message = key.encrypt(text_message)

image

drnw commented 2 years ago

This is still an issue as of 2022-07-13. Inspecting the code I see that the commit for this feature was 12 months ago. The release on PyPi is from 15 months ago => this feature is currently not available unless installing from source.