#1 2022-06-05 20:30:39

tbo
Member
Registered: 2015-04-20
Posts: 337

TAesPkcs7Reader, exception EReadError

Delphi 11.1, mORMot 2.0.3394, Image TestSaveLoad.png has 1.913.744 bytes

I get an exception EReadError in TAesPkcs7Reader when I try to decrypt data encrypted with TAesPkcs7Writer. You can easily reproduce it with the following:

AesPkcs7File('f:\TestSaveLoad.png', 'f:\_TestSaveLoad.dat', True, 'Thomas');
AesPkcs7File('f:\_TestSaveLoad.dat', 'f:\_TestSaveLoad.png', False, 'Thomas');

With best regards
Thomas

Offline

#2 2022-06-06 08:27:28

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

Re: TAesPkcs7Reader, exception EReadError

There was no problem on FPC.
But Delphi has a diverse - and unexpected - TStream.CopyFrom() implementation: it uses Size and ReadBuffer() whereas the output is not of the same size than the input due to PKCS7 padding... sad

I have therefore added StreamCopyUntilEnd() which has no such restriction, and is faster:
https://github.com/synopse/mORMot2/commit/c019755b

Offline

Board footer

Powered by FluxBB