Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change request: Allow custom signature cipher implementations in PgpSignatureGenerator #556

Open
ulrichb opened this issue Aug 5, 2024 · 0 comments

Comments

@ulrichb
Copy link

ulrichb commented Aug 5, 2024

TL;DR:

  • We'd like to use BouncyCastle's OpenPGP RSA/ECDSA keys with HSM-backed private keys.
  • This is a change request proposal to open PgpSignatureGenerator for extension to enable to adapt the signature operations to HSM calls.
  • Can provide a PR.

Background:

  • We want to use the great OpenPGP implementation of BouncyCastle .NET with external (HSM-backed) RSA or ECDSA keys.
  • Currently PgpSignatureGenerator.InitSign() creates the ISigner instance based on the provided PublicKeyAlgorithmTag and PgpPrivateKey via the PgpUtilities.CreateSigner() factory.
    • E.g. for a PublicKeyAlgorithmTag.RsaSign it always creates the RsaDigestSigner: ISigner implementation which uses an (in-memory / software) RsaPrivateCrtKeyParameters key.

Change request: Open PgpSignatureGenerator for extension (custom ISigner implementation)

One option (there are others; this is only the least invasive one): Add a PgpSignatureGenerator.InitSign() overload which takes an ISigner instance as input (instead of calling the PgpUtilities.CreateSigner() static factory method) and store it for later signing calls in the sig field. (Can provide alternative suggestions.)

That way a library user can provide either the full ISigner implementation, or a GenericSigner instance with an IAsymmetricBlockCipher implementation to adapt the ProcessBlock() call to e.g. an HSM call. We've already tested this E2E with RSA and ECDSA by "faking" the InitSign() call with reflection calls and it works: Can self-sign GPG keys and create BinaryDocument signatures.

Non-goal: Custom cipher algorithms (in addition to PublicKeyAlgorithmTag); it's just about the implementation of the signature operations (of the existing algos).

In case you approve the general idea, we can provide details for the change request (+ alternatives) as well as a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant