TurboPack / LockBox3

LockBox3 is a Delphi and C++Builder library for cryptography.
Other
171 stars 58 forks source link

Intermittant error during encryption. #9

Closed SARTrack closed 6 years ago

SARTrack commented 6 years ago

I have a regular problem with this, and I have no idea how to fix it. Windows 8.1 Delphi XE7 I cannot find the actual version of the LockBox3, but I downloaded it only a few weeks ago.

Codec1.EncryptStream: TNoncibleEncryptor.End_Encrypt - Internal marshalling error. (....\LockBox3\run\cryptography\uTPLb_StreamToBlock.pas, line 883)
Stream.Size=382 bytes

The code line is: Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling);

The actual stream has a combination of text and binaries (integers, etc) in it. code:

INIT: Codec1 := TCodec.Create(nil); CryptographicLibrary1 := TCryptographicLibrary.Create(nil); Codec1.CryptoLibrary := CryptographicLibrary1; Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId; Codec1.BlockCipherId := 'native.AES-256'; Codec1.ChainModeId := uTPLb_Constants.CBC_ProgId; Codec1.Password := ***

Program: CryptStream := TMemoryStream.Create; try Codec1.Reset; except on E:Exception do // Unrecoverable "Privileged Instruction" error??? begin LocalLog('Codec1.Reset: '+E.Message,d_error); FreeAndNil(Codec1); DTBInitFinal; // Restart initializing the Codec. end; end; try Codec1.EncryptStream(DataStreams[0],CryptStream); except on E:Exception do // Unrecoverable error. Sometimes "Internal marshalling error." begin LocalLog('Codec1.EncryptStream: '+E.Message,d_error); FreeAndNil(Codec1); DTBInitFinal; // Restart initializing the Codec. CryptStream.Free; DataStreams.Delete(0); exit; end; end;

SARTrack commented 6 years ago

I forgot to mention that this happens in a Thread. While the stream itself is unique, it is possible that somewhere else the Interface is used at the same time...

SeanBDurkin commented 6 years ago

Hi Bart,

Can you write a very small self-contained program, with a fixed test case, that demonstrates the problem?

Faithfully, Sean B. Durkin

On 7/20/2017 10:49 AM, Bart Kindt wrote:

I have a regular problem with this, and I have no idea how to fix it. Windows 8.1 Delphi XE7 I cannot find the actual version of the LockBox3, but I downloaded it only a few weeks ago.

Codec1.EncryptStream: TNoncibleEncryptor.End_Encrypt - Internal marshalling error. (....\LockBox3\run\cryptography\uTPLb_StreamToBlock.pas, line 883) Stream.Size=382 bytes

The code line is: Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling);

The actual stream has a combination of text and binaries (integers, etc) in it. code:

INIT: Codec1 := TCodec.Create(nil); CryptographicLibrary1 := TCryptographicLibrary.Create(nil); Codec1.CryptoLibrary := CryptographicLibrary1; Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId; Codec1.BlockCipherId := 'native.AES-256'; Codec1.ChainModeId := uTPLb_Constants.CBC_ProgId; Codec1.Password := ***

Program: CryptStream := TMemoryStream.Create; try Codec1.Reset; except on E:Exception do // Unrecoverable "Privileged Instruction" error??? begin LocalLog('Codec1.Reset: '+E.Message,d_error); FreeAndNil(Codec1); DTBInitFinal; // Restart initializing the Codec. end; end; try Codec1.EncryptStream(DataStreams[0],CryptStream); except on E:Exception do // Unrecoverable error. Sometimes "Internal marshalling error." begin LocalLog('Codec1.EncryptStream: '+E.Message,d_error); FreeAndNil(Codec1); DTBInitFinal; // Restart initializing the Codec. CryptStream.Free; DataStreams.Delete(0); exit; end; end;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TurboPack/LockBox3/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/AF07WlGttSzXXjQgewSJaeMaCAjtUwN7ks5sPqQGgaJpZM4OdeOK.

SARTrack commented 6 years ago

Thanks for replying.

I will see if I can capture the actual stream in my database server, and see if the same problem happens when I send the same stream through a test program.

I will get back to you.

Thanks, Bart

On 20/07/2017 21:11, Sean B. Durkin wrote:

Hi Bart,

Can you write a very small self-contained program, with a fixed test case, that demonstrates the problem?

Faithfully, Sean B. Durkin

On 7/20/2017 10:49 AM, Bart Kindt wrote:

I have a regular problem with this, and I have no idea how to fix it. Windows 8.1 Delphi XE7 I cannot find the actual version of the LockBox3, but I downloaded it only a few weeks ago.

Codec1.EncryptStream: TNoncibleEncryptor.End_Encrypt - Internal marshalling error. (....\LockBox3\run\cryptography\uTPLb_StreamToBlock.pas, line 883) Stream.Size=382 bytes

The code line is: Assert( Fis2ndBufferFull, AS_BlockToStream_EndEncrypt_InternalMarshalling);

The actual stream has a combination of text and binaries (integers, etc) in it. code:

INIT: Codec1 := TCodec.Create(nil); CryptographicLibrary1 := TCryptographicLibrary.Create(nil); Codec1.CryptoLibrary := CryptographicLibrary1; Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId; Codec1.BlockCipherId := 'native.AES-256'; Codec1.ChainModeId := uTPLb_Constants.CBC_ProgId; Codec1.Password := ***

Program: CryptStream := TMemoryStream.Create; try Codec1.Reset; except on E:Exception do // Unrecoverable "Privileged Instruction" error??? begin LocalLog('Codec1.Reset: '+E.Message,d_error); FreeAndNil(Codec1); DTBInitFinal; // Restart initializing the Codec. end; end; try Codec1.EncryptStream(DataStreams[0],CryptStream); except on E:Exception do // Unrecoverable error. Sometimes "Internal marshalling error." begin LocalLog('Codec1.EncryptStream: '+E.Message,d_error); FreeAndNil(Codec1); DTBInitFinal; // Restart initializing the Codec. CryptStream.Free; DataStreams.Delete(0); exit; end; end;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/TurboPack/LockBox3/issues/9, or mute the thread

https://github.com/notifications/unsubscribe-auth/AF07WlGttSzXXjQgewSJaeMaCAjtUwN7ks5sPqQGgaJpZM4OdeOK.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TurboPack/LockBox3/issues/9#issuecomment-316645246, or mute the thread https://github.com/notifications/unsubscribe-auth/ASXcrFpibYHjveyYtiv5I7AL_GvHxM0pks5sPxnUgaJpZM4OdeOK.

-- Bart Kindt SARTrack Developer and CEO http://www.sartrack.nz/

SARTrack commented 6 years ago

Before I go through the trouble of debugging this, can you please confirm how thread-safe LockBox3 is? My current setup is this: Using the Indy-10, IdTCPServer inside a single Thread. In this Thread I create the LockBox3 Codec. But when multiple Clients are connected to the Server, and the Server pushes a Stream to all Clients (each Client its own copy of this stream) and I call the Codec.Encrypt in the OnExecute of the IdTCPServer... can that actually be done? As the OnExecute is called in a loop from Indy itself? Because if this setup is not possible, it would require that the entire creation and initializing of the Codec must be done on every OnExecute call ! Which would probably be a major performance issue, even if it is only done when outgoing data is in fact available to send out (else the OnExecute loops with a 1 millisecond delay).

Thanks, Bart.

SARTrack commented 6 years ago

Okay, I have found the problem, it was no my end. In a multi-thread situation, the codec was called more than once. Thanks for the reply,

Bart