#1 2019-02-18 19:26:18

keinn
Member
Registered: 2014-10-20
Posts: 100

SynCrypto AES encrytion results seems wrong

I use serval online enc/dec services to check the AESECB encryption/decryption result ,
it seems that our SynCrypto TAESECB mode can not get any result same with the online services.

what is your result when do such enc/dec with TAESECB?
the utf8 string key is '123456'
utf8String Data is 'ABC'
All online services results:
PKCS7padding, keysize 256 : h3ivt+HEEOkunT75PoB199xf3tD1LRO/p1/l6Tdrg6I=
PKCS7padding, keysize 128 : FevVdP5MovJAiVEClsvBBQ==

none of them is same as our syncrypto results.

my code like this :

  
CONST
  KEY:RawByteString='123456';
VAR
  aKey: TSHA256Digest;
  AES:TAESECB;
  aa:TAESCFB;
  DAT:RawByteString;
  sr:RawByteString;
begin
  DAT:='ABC';
  aKey :=SHA256Digest(KEY);
  AES:=TAESECB.Create(aKey,256);
  sr:=AES.EncryptPKCS7(DAT);
  mmoLog.Lines.Add(BinToBase64(sr));
end;

result is EUouYChaLyxO7ArP0k3G4A==

what is your result with syncrypto?

Last edited by keinn (2019-02-18 19:40:19)

Offline

#2 2019-02-18 21:33:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: SynCrypto AES encrytion results seems wrong

ECB is correct for sure - it is tested against regular Windows API calls in the SynSelfTests unit.

Something is wrong with your expectation.

Also note that ECB is pretty unsafe, and other modes are recommended - with the proper IV.

Offline

Board footer

Powered by FluxBB