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

Provide a custom SignatureValidationStrategy #62

Open
bjansen opened this issue May 3, 2021 · 2 comments
Open

Provide a custom SignatureValidationStrategy #62

bjansen opened this issue May 3, 2021 · 2 comments

Comments

@bjansen
Copy link

bjansen commented May 3, 2021

I have a use case where I need to check that decrypted data has been signed by any of two given keys. The current API RequireSpecificSignatureValidationStrategy supports an "AND" verification, but I need an "OR" verification.

I think it would be nice if users had the possibility to provide their own instance of SignatureValidationStrategy. This way they can use custom strategies without having to submit PRs here and wait for a release.

Maybe a new method named andValidateSignatureMatches(SignatureValidationStrategy) in name.neuhalfen.projects.crypto.bouncycastle.openpgp.BuildDecryptionInputStreamAPI.Validation:

BouncyGPG
	.decryptAndVerifyStream()
	.withConfig(...)
	.andValidateSignatureMatches(mySignatureValidationStrategy)
	.fromEncryptedInputStream(cipherTextStream);
@bjansen
Copy link
Author

bjansen commented May 4, 2021

Well I guess I can bypass the builder API and use this instead:

DecryptionStreamFactory.create(
	getKeyringConfig(),
	myStrategy
).wrapWithDecryptAndVerify(cipherTextStream)

Is it safe to use DecryptionStreamFactory directly? Is there a chance this API will change or be removed in the future?

@Sauhardstark
Copy link
Contributor

I think your point on being able to specify a custom SignatureValidationStrategy is nice and should be further discussed with the author.
In the interim however, you might be able to take care of the issue by using the below function (if the two keys are present in the decryption key ring)

andValidateSomeoneSigned

But it would only validate that one of the keys in the keyring signed this message (not a particular subset)
So, something like

BouncyGPG
	.decryptAndVerifyStream()
	.withConfig(...)
	.andValidateSomeoneSigned(mySignatureValidationStrategy)
	.fromEncryptedInputStream(cipherTextStream);

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

2 participants