-
Notifications
You must be signed in to change notification settings - Fork 20
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
Signature verification when signature is present #40
Comments
Currently it doesn't allow for that. JPGPJ was originally designed for the use-case of machine-to-machine (or human-to-machine) encrypting & signing files, where you generally know ahead of time which keys should be used for encryption & signing, and whether or not files should be signed. But I can see how for other use-cases you might want to decrypt a file or message first, and then later make some further decisions about what to do with it based on whether or not it was signed by a known key. To allow for that, what if we add a
States 1) and 2) would work like the single |
I am not sure if you are saying the same thing for state 3 but this is what I thought of:
This is the output I get from the command line when I try to decrypt when only the decryption key is present
|
I'm envisioning that state 3 would follow the same logic as state 1, but just not raise any verification exceptions. I can't imagine a scenario where someone would want to reject messages that were signed by unknown keys, but accept messages that weren't signed at all. State 1 would reject all messages that weren't signed by a known key, whereas states 2 and 3 would accept all messages regardless of signing. But unlike state 2, state 3 would go through the same verification process as state 1, and like state 1, record when valid signatures were found. So with state 3, messages would be decrypted regardless of signing; but if a message was signed, you'd be able to access the signing keys via the |
This is actually the case we have since we are migrating away from gnupg command line, we are trying to keep parity with the command line which does just that:
|
Well in that case, I'm still in favor of modifying the Decryptor to have the three verification-processing states I suggested previously:
In cases like yours, where neither 1 nor 2 do what you need, you would at least be able to use state 3, and raise exceptions in your application logic as appropriate based on the metadata results from the Decryptor. But to satisfy your use case, we'd also have to record some additional information in the
(Plus with friendly accessors as appropriate like And then adding a
And then the
That way, your application can run the Decryptor in state 3, and check the
This would also allow for different uses cases with other signature-verification requirements, like say a requirement that all messages be signed by at least 2 known keys; or a requirement that if the decrypted message turned out to contain a purchase order for more than $1000, the message must be signed by a specific key; etc. |
I think that would work perfectly with our application logic. |
As long as the Decryptor records the PGP key ID of each signature it encounters (including those it can't verify), the And currently if you turn on JPGPJ's logging, it will log the following message at an INFO level if it encounters a signature with an unknown key:
And the following message if it encounters a signature for a known key that isn't configured for verification:
Today (in state 1) if it encounters a bad signature with a known key, it will raise a JPGPJ
So if for state 3 we log a similar message (instead of raising an exception), that would give you the 3 reasons via logging why JPGPJ wouldn't verify a signature: 1) unknown key, 2) known key but not configured for verification, 3) known key but bad signature. (And if a signature packet itself was malformed, you'd still get a |
I implemented what I was envisioning for this issue via PR #41 -- please take a look at it when you get a chance and let me know what you think. Instead of adding a new
|
I merged PR #41, and released as version 1.3. |
Is there a way to set the
Decryptor
to verifiy signatures only if the signature exists.I am trying to have parity with the way GnuPG operates.
GnuPG only verifies a signature if it is present but however with JPGPJ you need to control that with
setVerificationRequired
and in the event when a signature is not present it throws an error sayingThe text was updated successfully, but these errors were encountered: