mattosaurus / PgpCore

.NET Core class library for using PGP
MIT License
245 stars 98 forks source link

ReadPublicKey doesn't check KeyFlags of SubKeys #127

Closed DanNsk closed 2 years ago

DanNsk commented 3 years ago

I think because of condition you have in utilities - keys.Where(k => k.Version >= 4 && k.IsMasterKey) you only read signatures and KeyFlags for the masterkey, but not subkeys. Most of the keys I used - use subkeys for encryption, and master key - for signature. So I think condition needs to be changed to just keys.Where(k => k.Version >= 4) ..maybe you can order by descending k.IsMasterKey to make it verify masterkey first, otherwise you always use masterkey, even when it is just signature key.

Also maybe in a future you can make key selection filter as a delegate parameter for EncryptionKeys class, to make key filtering more flexible for both public and private keys.

Thank You

mattosaurus commented 3 years ago

Thanks, I'll see how easy it is to add this in.