#1 2018-08-03 17:03:02

ertank
Member
Registered: 2016-03-16
Posts: 168

TAESCFB.EncryptPKCS7() raise SIGABRT when used in a thread

Hello,

I am using Lazarus 1.8.4 with fpc 3.0.4. Installed from official DEB files in lazarus web site. Target is Linux amd64.

When I use below code out of a thread, in a GUI application, it just runs fine. However, if I put it in thread run IdTCPServer1Execute() procedure I have subject exception in line marked below:

procedure TForm1.Button1Click(Sender: TObject);
const
  AKey : Array[0..47] of Byte =  (121, 81,  10,  23,  25,  35,  45,  199, 112, 129, 27,  113, 114, 164, 187, 119, 141, 157, 162, 171, 180, 197, 102, 110, 195, 185, 172, 45,  35,  00,  56,  01, 148, 147, 247, 213, 124, 137, 141, 155, 132, 133, 132, 139, 130, 137, 138, 135);

var
  NewUsername: string;
  Key: TSHA256Digest;
  Aes: TAESCFB;
  AUtf8String: RawByteString;
  CryptUsername: string;
  CryptText: RawByteString;
begin
  NewUsername := 'pars.6C3C66740B954028A56EA610314BFAC6';
  Key := SHA256Digest(Pointer(@AKey), SizeOf(AKey));
  Aes := TAESCFB.Create(Key, 256);
  try
    AUtf8String := StringToUTF8(NewUsername);
    try
      CryptText := Aes.EncryptPKCS7(AUtf8String, True);  // <===== Exception here
      AUtf8String := BinToBase64(CryptText);
    except
      on E: Exception do
      begin
        ShowMessage(E.Message);  // Thread code do not have any interaction with GUI at all.
      end;
    end;
    CryptUsername := UTF8ToString(AUtf8String);
  finally
    Aes.Free();
  end;
end;

I have been using same lines for a while. They are just working. I cannot figure if there is anything I am doing wrong.

Any help is appreciated.

Thanks & regards,
Ertan

Offline

#2 2018-08-03 21:07:07

ertank
Member
Registered: 2016-03-16
Posts: 168

Re: TAESCFB.EncryptPKCS7() raise SIGABRT when used in a thread

After reading below post, I installed a fresh fpc and Lazarus from trunk sources and problem disappeared.
https://synopse.info/forum/viewtopic.ph … 846#p27846

Sorry for the noise.

Thanks.
Ertan

Offline

Board footer

Powered by FluxBB