Cinchoo / ChoPGP

PGP library for .NET / c#
MIT License
60 stars 29 forks source link

Using subkey for encryption in EncryptAndSign #39

Open clayschaad opened 2 years ago

clayschaad commented 2 years ago

Hi

I have an issue with the usage of a subkeys in the method EncryptAndSign. This method uses the master key for encryption, even if there is a subkey for encryption. Have a look at the comment on IsEncryptionKey in the BouncyCastle Library: "Note: with version 4 keys KeyFlags subpackets should also be considered when present for determining the preferred use of the key." Your method Encrypt() already uses the right logic, but EncryptAndSign() uses the method GetFirstPublicKey() which does't care about the logic with KeyFlags of subkeys.

I'll make a pull request with a possible solution. Perhaps you can check it out.

Thanks Claudio

clayschaad commented 2 years ago

unfortunately I can't push to the repo, so I've made a path file

0001-add-support-of-subkey.patch.txt