mattosaurus / PgpCore

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

When creating a new key, can a key expiry date, or key lifetime be specified? #184

Closed davegreen closed 1 year ago

davegreen commented 2 years ago

I'm a user of a project that leverages the dll used here. I've got a new use-case, but it requires a PGP key suitable for encryption with an expiry date set. Is this possible?

I can't figure out with this implementation how to create a PGP key with an expiry. At the moment I'm editing the keys after creation with some command line tools to add this in, but that's less than ideal.

Can anyone give me an idea of where to look? I'm happy to create PR's etc., but I just can't figure out where to look!

Thanks

mattosaurus commented 2 years ago

Hi, PgpCore doesn't currently support adding an expiry date when keys are generated. The key generation is pretty barebones as generally I find people like to create their keys elsewhere (though that's not saying it shouldn't be better).

I think the GenerateKey method was based on an example I found in the Bouncy Castle code somewhere. Expiry dates and other options are supported by Bouncy Castle as can be seen here. In order to enable setting of expiry dates we'd need to replace the current way keys are generated with something like that in the previous example. If this is something you're able to create a PR for that would be great.