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

DecryptFileAsync: Message is not a simple encrypted file. #214

Closed
martinstenhoff opened this issue Jun 8, 2023 · 1 comment
Closed

DecryptFileAsync: Message is not a simple encrypted file. #214

martinstenhoff opened this issue Jun 8, 2023 · 1 comment

Comments

@martinstenhoff
Copy link

Seems like this issues has been reported before in other places of PgpCore.

In our case it is triggered in the private async Task DecryptAsync(Stream inputStream, Stream outputStream)

If we change if (message is PgpOnePassSignatureList) in PGP.cs L5030
to if (message is PgpOnePassSignatureList || message is PgpSignatureList) then the file we have received can successfully be decrypted.

I don't know how the file has been generated other than it seems to be done by BouncyCastle Java?:

-----BEGIN PGP MESSAGE-----
Version: BCPG v1.61

I had a quick look at private async Task DecryptAndVerifyAsync(Stream inputStream, Stream outputStream) as well and the following should perhaps be added:

else if (message is PgpSignatureList pgpSignatureList)
{
    var keyIdToVerify = pgpSignatureList[0].KeyId;
    var verified = Utilities.FindPublicKey(keyIdToVerify, EncryptionKeys.VerificationKeys,
                            out PgpPublicKey _);
    if (verified == false)
         throw new PgpException("Failed to verify file.");
						
    message = plainFact.NextPgpObject();
}

But I can't verify that at the moment cause I only have the public key, that I believe was used to sign, in a scanned document and I don't want to transcribe it. I'll update this when I receive it in proper format.

@mattosaurus
Copy link
Owner

Hi, yes we pretty much just have a big if statement here for each type so we occasionally get ones I haven't thought of yet which cause the same error.

I think this could definitely need some improvement so if you're happy to put in a PR to fix it for use case or to add the else in then that would be great.

mattosaurus added a commit that referenced this issue Oct 10, 2023
…erify-async-with-pgp-signatur-list

Add message is PgpSignatureList on Decrypt and DecryptAndVerify #214
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