Print Page | Close Window

AES decryption Linux

Printed From: TMS Software
Category: VCL Components
Forum Name: VCL / FMX Cryptography Pack
Forum Discription:
URL: http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=12757
Printed Date: 26 Aug 2019 at 6:45am


Topic: AES decryption Linux
Posted By: Michael Schumann
Subject: AES decryption Linux
Date Posted: 24 Dec 2018 at 2:44pm
I am developing a cross platform application for Windows, OSX and Linux and stubled upon an AES problem in LINUX. This code works well in both Windows and OSX but crashes on decryption in Linux. The key is 32 chars fixed in code. It is used for encrypting a DBServer password in the config file. 

function TBaseConfig.encrypt(s: string): string;
var
  aes: TAESEncryption;
begin
  aes := TAESEncryption.Create;
  aes.AType := atCBC;
  aes.KeyLength := kl256;
  aes.Unicode := noUni;
  aes.Key := APPKEY;
  aes.OutputFormat := base64;
  aes.PaddingMode := TpaddingMode.PKCS7;
  aes.IVMode := TIVMode.rand;
  result := aes.encrypt(s);
  aes.Free;
end;

function TBaseConfig.decrypt(s: string): string;
var
  aes: TAESEncryption;
begin
  aes := TAESEncryption.Create;
  aes.AType := atCBC;
  aes.KeyLength := kl256;
  aes.Unicode :=noUni;
  aes.Key := APPKEY;
  aes.outputFormat := base64;
  aes.PaddingMode := TpaddingMode.PKCS7;
  aes.IVMode := TIVMode.rand;
  result := aes.decrypt(s);
  aes.Free;
end;

Thanks for any help and merry christmas!



Replies:
Posted By: Michael Schumann
Date Posted: 24 Dec 2018 at 3:15pm
I forgot to add the error message I receive in Linux: "in AES the cipher text mus have a length multiple of 128 bits"


Posted By: Michael Schumann
Date Posted: 24 Dec 2018 at 3:19pm
Finally: Using hecxa as Outputformat it works on all three platforms.


Posted By: Michael Schumann
Date Posted: 28 Dec 2018 at 11:30am
Hello, using HEXA ist no real option for me as its size is very big compared to AES64. SO I would be grateful if you could help me solving that problem. As I stated when decryptiong unter Linux using AES and base64 I get the error:

... in AES, the cipher text must have a length multiple of 128 bits!

I tried padding the base64 string to multiples of 16 characters but this did not solve the problem.

Thanks in advance and a happy new year!

Michael



Posted By: Marion Candau
Date Posted: 03 Jan 2019 at 8:48am
Hi Michael,
I will take a look to your issue today.
Best regards,
Marion


Posted By: Marion Candau
Date Posted: 03 Jan 2019 at 10:43am
Hi Michael,
Your issue will be fixed in the 3.3.1.2 version that will be released soon.
Best regards,
Marion



Print Page | Close Window