mattosaurus / PgpCore

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

Encryption with the latest subkey not possible #210

Open gree1502 opened 1 year ago

gree1502 commented 1 year ago

Hi, We have a requirement where the new subkey is created by the vendor and current subkey is valid until June 1st. I have exported the public.asc file. I do see 1 primary key - flagged as certify. 1 subkey - flagged as encrypt (current - expires june 1st) 1 subkey - flagged as encrypt (new - expires after 2 years) After exporting the new public key provided by the vendor, the PGP library encrypts with current subkey instead of new one. Is there a functionality where I can specify which subkey to use or use the latest subkey based on date the subkey was created?

Screenshot 2023-04-19 155342

mattosaurus commented 1 year ago

Hi, unfortunately this isn't possible at the moment.

The code that picks the correct key to use at the moment is essentially a fixed hierarchy and doesn't take account of expiry dates.

I'm planning to update this to allow a subkey to be specified by ID as well but haven't started on this yet. Taking account of expiry dates would also be a good option.

Feel free to submit a PR with these changes, otherwise I'll do them when I get a chance.