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

Missing Bytes After Encrypt and Decrypt Large files #70

Closed
jhkuan1989 opened this issue Jun 1, 2020 · 4 comments
Closed

Missing Bytes After Encrypt and Decrypt Large files #70

jhkuan1989 opened this issue Jun 1, 2020 · 4 comments

Comments

@jhkuan1989
Copy link

jhkuan1989 commented Jun 1, 2020

Not too sure if anyone have experience this, I've tried to test if the PGP works on large files using the settings below.

        using (PGP pgp = new PGP()
        {
            CompressionAlgorithm = Org.BouncyCastle.Bcpg.CompressionAlgorithmTag.Uncompressed,
            SymmetricKeyAlgorithm = Org.BouncyCastle.Bcpg.SymmetricKeyAlgorithmTag.Aes256,
            PublicKeyAlgorithm = Org.BouncyCastle.Bcpg.PublicKeyAlgorithmTag.RsaSign,
            HashAlgorithmTag = Org.BouncyCastle.Bcpg.HashAlgorithmTag.Sha512,
            FileType = PGPFileType.Binary,
            PgpSignatureType = PgpSignature.BinaryDocument
        })

So far for smaller files (<1GB) I'm getting exactly same size after the encrypt and decrypt process. but for 1 of my sql server db backup that is sized at 6GB, there's a 53KB mismatched, and resulting in a corrupted file.

image

@mattosaurus
Copy link
Owner

Strange, I haven't experienced that before. I don't suppose you're able to open the file and see if there's anything obviously wrong with it (missing characters from the end maybe)?

I don't have any 6GB SQL backups available but I'll see if I can replicate this with a txt file.

@jhkuan1989
Copy link
Author

yeap, did a quick check using large text file editor. Indeed it was truncated from the end.

left being the original, right being the decrypted
image

I've also tried simply zipping a random folder in my harddisk with size 5gb+, also having missing bytes.

@mattosaurus
Copy link
Owner

Ok, thanks for checking. It sounds like it's probably closing the stream before it's flushed so is leaving off the end so I'll have a look into that.

Can you confirm that the issue is with the latest v2.4.0 version of the library?

@mattosaurus
Copy link
Owner

This was an issue with the encryption method not writing all bytes for large files. I've fixed it now and have published v2.4.1.

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