Index was outside the bounds of the array. Exception when encrypting a file

24 views
Skip to first unread message

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 5:46:58 AM3/28/19
to DidiSoft Forum
The version used is 1.9.0. The sample code below:

        PGPLib pgp = new PGPLib();
        // should output be ASCII or binary
        bool asciiArmor = false;
        // encrypt
        pgp.EncryptFile(@"c:\queue\eurams1app1plugins_20190324001005.bak", @"c:\key\sqlbackupPubKey",
        @"c:\queue\eurams1app1plugins_20190324001005.bak.pgp", asciiArmor);


StackTrace:
   at DidX.BouncyCastle.Utilities.Zlib.Tree.d_code(Int32 dist)
   at DidX.BouncyCastle.Utilities.Zlib.Deflate.compress_block(Int16[] ltree, Int16[] dtree)
   at DidX.BouncyCastle.Utilities.Zlib.Deflate._tr_flush_block(Int32 buf, Int32 stored_len, Boolean eof)
   at DidX.BouncyCastle.Utilities.Zlib.Deflate.deflate_slow(Int32 flush)
   at DidX.BouncyCastle.Utilities.Zlib.Deflate.deflate(ZStream strm, Int32 flush)
   at DidX.BouncyCastle.Utilities.Zlib.ZOutputStream.Write(Byte[] b, Int32 off, Int32 len)
   at DidX.BouncyCastle.Utilities.IO.FilterStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at DidX.BouncyCastle.Bcpg.BcpgOutputStream.PartialFlush(Boolean isLast)
   at DidX.BouncyCastle.Bcpg.BcpgOutputStream.WritePartial(Byte[] buffer, Int32 off, Int32 len)
   at DidX.BouncyCastle.Bcpg.BcpgOutputStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at DidX.BouncyCastle.Utilities.IO.FilterStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at DidiSoft.BC.BaseLib. (Stream , Stream )
   at DidiSoft.Pgp.PGPLib. (FileInfo , PgpPublicKey[] , FileInfo , Boolean , Boolean , Boolean )
   at DidiSoft.Pgp.PGPLib. (FileInfo , PgpPublicKey[] , FileInfo , Boolean , Boolean )
   at DidiSoft.Pgp.PGPLib.EncryptFile(String dataFileName, Stream publicKeyStream, String outputFileName, Boolean asciiArmor, Boolean withIntegrityCheck)
   at DidiSoft.Pgp.PGPLib.EncryptFile(String dataFileName, String publicKeyFile, String outputFileName, Boolean asciiArmor, Boolean withIntegrityCheck)
   at DidiSoft.Pgp.PGPLib.EncryptFile(String dataFile, String publicKeyFile, String outputFile, Boolean asciiArmor)
   at PgpConsoleApp.Program.Main(String[] args) in C:\Users\vaskovskiy\source\repos\PgpConsoleApp\PgpConsoleApp\Program.cs:line 20

DidiSoft Support

unread,
Mar 28, 2019, 6:01:25 AM3/28/19
to didisof...@googlegroups.com, andrey.v...@targetprocess.com

Hi Andrey,

Can you send me a test file that throws this exception to our support email support(at)didisoft.com ?

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Phone: +1-256-907-7816 | Fax: +1-256-907-7816 | Web: www.didisoft.com
--
You received this message because you are subscribed to the Google Groups "DidiSoft Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 6:38:16 AM3/28/19
to DidiSoft Forum
The file is rather big, 55.9 MB compressed. I can not attach it here
To unsubscribe from this group and stop receiving emails from it, send an email to didisof...@googlegroups.com.

DidiSoft Support

unread,
Mar 28, 2019, 8:21:08 AM3/28/19
to didisof...@googlegroups.com, andrey.v...@targetprocess.com

Hi Andrey,

Please download the updated version 1.9.0.22 where this should have been fixed.

https://storage.googleapis.com/didisoftdownload/OpenPGP_Library_Setup_Trial.exe

or NuGet

Update-Package DidiSoft.Pgp.Trial

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Phone: +1-256-907-7816 | Fax: +1-256-907-7816 | Web: www.didisoft.com
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 8:32:45 AM3/28/19
to DidiSoft Forum
Hi, indeed the issue is not reproducible with the new version. Thanks

DidiSoft Support

unread,
Mar 28, 2019, 8:35:29 AM3/28/19
to didisof...@googlegroups.com, andrey.v...@targetprocess.com

You are welcome:)

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Phone: +1-256-907-7816 | Fax: +1-256-907-7816 | Web: www.didisoft.com
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 8:50:13 AM3/28/19
to DidiSoft Forum
Just one moment...the decrypted file is much smaller than the original file. 884 MB - before decryption and 39.0 MB after

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 9:13:37 AM3/28/19
to DidiSoft Forum
Seems like file is not fully restored to it's original size after decryption

DidiSoft Support

unread,
Mar 28, 2019, 9:58:43 AM3/28/19
to didisof...@googlegroups.com, andrey.v...@targetprocess.com

Hi Andrey,

Which version of .NET Framework are you using ?

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Phone: +1-256-907-7816 | Fax: +1-256-907-7816 | Web: www.didisoft.com
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 10:01:52 AM3/28/19
to DidiSoft Forum
Hi, I'm using .NET 4.5.

The test below fails. Legths differ

PGPLib pgp = new PGPLib();
        // should output be ASCII or binary
        bool asciiArmor = false;
        // encrypt
        pgp.EncryptFile(@"c:\queue\eurams1app1plugins_20190324001005.bak", @"c:\key\sqlbackupPubKey",
        @"c:\queue\eurams1app1plugins_20190324001005.bak.pgp", asciiArmor);

        pgp.DecryptFile(@"c:\queue\eurams1app1plugins_20190324001005.bak.pgp", @"c:\key\secret.asc", "MYPASSWORD",
@"c:\queue\eurams1app1plugins_20190324001005.bak.restore");

        Debug.Assert(new FileInfo(@"c:\queue\eurams1app1plugins_20190324001005.bak").Length ==
                     new FileInfo(@"c:\queue\eurams1app1plugins_20190324001005.bak.restore").Length);

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 10:42:15 AM3/28/19
to DidiSoft Forum
I guess the best way is to send you the original file with keys and password to reproduce the error

DidiSoft Support

unread,
Mar 28, 2019, 11:14:50 AM3/28/19
to didisof...@googlegroups.com, andrey.v...@targetprocess.com

Hi Andrey,

The file and public key will be enough. I will create test public and private key based on the algorithm preferences of your public key.

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Phone: +1-256-907-7816 | Fax: +1-256-907-7816 | Web: www.didisoft.com
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.

andrey.v...@targetprocess.com

unread,
Mar 28, 2019, 11:29:14 AM3/28/19
to DidiSoft Forum
https://www.dropbox.com/s/vws2w87gknwh1qb/eurams1app1plugins_20190324001005.zip?dl=0

That's the link to the file...the file is password protected, let me know where I can send you the password
sqlbackupPubKey
Reply all
Reply to author
Forward
0 new messages