EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Encryption failed : Unexpected end of data.

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#13151
Posted: 04/29/2010 03:32:32
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. I tried to decrypt attached file, and everything goes fine with the current SBB code.

Does PGPFilesDemo show the same error as your code?
#13163
Posted: 04/30/2010 11:43:12
by Ankur Patel (Standard support level)
Joined: 09/24/2007
Posts: 6

Mykola,
Tried it with PGPFilesDemo and it works. However, the demo app prompts for the passphrase and my app assigns it and as you can see from the error, it is coming when a call is made to for "SBPGP.TElPGPReader.Synchronize()" synchronization.
Our app decrypts also (not 100% of time). It is not consistent. The same EXACT code worked all the time when using the older library, so I do not believe that anything in our code is causing the issue and must be a thread synchronization that is throwing the error internally by the method call.
Also to mention, if we try to decrypt, it usually fails only on first try. If we issue another decrypt command, it succeeds which is very weird.
Let me know if I can do any other tests on my side or if you need more code, but as I said it has been working fine for 2 years and all of sudden we have the issue.
#13168
Posted: 04/30/2010 14:25:52
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. Our 'Synchronize' method doesn't deal with thread synchronization, it's just a name.
Do you use multithreaded application, and does readingKeyring is shared between different threads? Did you try to isolate attached code snippet, and see if error persists?
#13170
Posted: 04/30/2010 15:33:35
by Ankur Patel (Standard support level)
Joined: 09/24/2007
Posts: 6

Mykola,
Our app is mulithreaded, but this is only on one thread as you can see from the code. I think the only time we use a different thread for your application is for Verify, we have:
pgpReader.OnSignatures += new SBPGPStreams.TSBPGPSignaturesEvent(pgpReader_OnSignatures);
and that would be on another thread of course, but for Decrypt only we do not subscribe to the event handler, so no secondary thread is used in this case.

And like I said this code has been working for 2 years, nothings changed. Like to keep this issue open and I will investigate more later.
#13172
Posted: 05/01/2010 07:35:35
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. Another question is how are you transfering or producing input files? The idea is to check if input file is really written and fully available before DecryptAndVerify is called.
#13173
Posted: 05/03/2010 10:01:27
by Ankur Patel (Standard support level)
Joined: 09/24/2007
Posts: 6

Mykola,
The input file is read from the disk. There is already a check first to make sure the file exist before proceeding with the decrypt portion. Then its read in line:
streamInput = new FileStream(FileName, FileMode.Open);
The strange thing is that when I hover over the streamInput in Visual Studio, it shows the same exact number of bytes in both versions of your library used, so I am not sure why it would give an 'Encryption failed : Unexpected end of data.' in one and not the other. That is why I turned to you guys for suggestions since all other possibilities I could think of were checked first.
And again, the strange thing is that it works some of the times (same encrypted file decrypts with same keyring only a fraction of the time). It does point to the file not being available sometimes, but I checked the stream already, it was full. Scratching my head here!
#13174
Posted: 05/03/2010 10:36:01
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Please try to write somewhere to the log file (or console) information about opened FileStream: Size (before DecryptAndVerify), and Position (in exception handling code, or after DecryptAndVerify). We need to isolate the problem, and see if it is file-related.
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

Topic viewed 6653 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!