mattosaurus / PgpCore

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

Unable to read verified file? #179

Closed danielcarlstrom closed 2 years ago

danielcarlstrom commented 2 years ago

I'm new to PGP but I've come to understand that a file is compressed once singed? So, if I call VerifyFileAsync() it's not decompressing the file.

public async Task<bool> VerifySignedFile(string publicKeyPath, string inputFilePath)
{
    EncryptionKeys encryptionKeys;
    using (var publicKeyStream = new FileStream(publicKeyPath, FileMode.Open))
    {
        encryptionKeys = new EncryptionKeys(publicKeyStream);
    }
    var pgp = new PGP(encryptionKeys);
    FileInfo inputFile = new FileInfo(inputFilePath);
    return await pgp.VerifyFileAsync(inputFile);
}

Is that intentional?

If not, how would I go about this? I have a signed file, I have the public key - and I would like to get the "original" version of the file once verification checks out.

Thanks

mattosaurus commented 2 years ago

A file can be compressed or not when encrypted but I don't believe it's compressed as part of signing.

The Verify method is just to verify that a message has been signed by the owner of the public key. This message can be signed and encrypted or just signed.

If it's just signed and not encrypted and you want the contents then you can use VerifyAndReadClearFileAsync (or equivlents) which will get the contents for you. Seems like these methods aren't in the readme so that's another thing I need to update.

danielcarlstrom commented 2 years ago

Thanks for the feedback, was not able to use the clearsign-versions since the files I'm working with are just signed and compressed and it was quicker for me to build my own solution just using Bouncy Castle but thanks for a nice lib.

mattosaurus commented 2 years ago

Glad you managed to figure it out. I'll try and add this functionality in when I get a chance.